Thanks, Chris. My concern with using gettimeofday() is that I don't want to pay the performance cost of doing a timezone calculation. In fact I don't require the real time. I simply want to measure the elapsed time of an operation. A simple counter running at the clock frequency of the processor would suffice; as long as I can also determine the clock frequency. I understand that the pentium processor has such a function and it requires only a small amount of assembly code to access it, however I'd prefer to not write the assembly code if I don't have to. Mike > -----Original Message----- > From: Chris McKinley [mailto:lamfada at lugh.net] > Sent: Friday, August 30, 2002 9:31 AM > To: Mike Bresnahan > Cc: tclug-devel at mn-linux.org > Subject: Re: [TCLUG-DEVEL] High Resolution Timer > > > On Fri, 30 Aug 2002, Mike Bresnahan wrote: > > > Is there a high resolution timer C API on Linux? If so, what > is it's name? > > I need a timer that will give me time with a precision better > than seconds, > > e.g. milliseconds. I'm looking for a C function equivalent to the Java > > function System.currentTimeMillis() and the Win32 functions > > QueryPerformanceCounter() and QueryPerformanceFrequency. > > gettimeofday(2) > > gettimeof day gets the time into a struct timeval, which is defined as: > > struct timeval { > long tv_sec; /* seconds */ > long tv_usec; /* microseconds */ > }; > > and gives the number of seconds and usec since the epoch. > > -Chris McKinley > >