Interesting concern.  I show that each call takes only about 1usec on a
PIV 1.8GHz and about 0.4usec on a 1GHz Athlon.

Here is a page which has more exact methods for doing it in assembly ...

http://www.ncsa.uiuc.edu/UserInfo/Resources/Hardware/IA32LinuxCluster/Doc/timing.html#linuxasm

Good luck.

On Fri, 30 Aug 2002, Mike Bresnahan wrote:

> 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.

-Chris McKinley
finger lamfada at lugh.net for GPG key