Re: Measure time
"Richard B. Johnson" <[email protected]>
| Newsgroups | org.kernel.vger.linux-gcc,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 8 May 2002, Serguei I. Ivantsov wrote:
> Hello!
>
> Is there any function for high precision time measuring.
> time() returns only in second. I need nanoseconds.
>
> --
> Regards,
> Serguei I. Ivantsov
> GSC Game World
>
gettimeofday() returns seconds/microseconds. If you need nanoseconds,
you can read CPU clock cycles in Intel machines with (assembly) rdtsc
instructions and convert, based upon the CPU clock.
If you really need nanosecond resolution in code that may be
interrupted or preempted at any time, you are in a world of hurt.
I suggest you review the requirement. You may need a TMS320C30 or
similar DSP standing alone.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Windows-2000/Professional isn't.