Re: Measure time

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Wed May 08 2002 - 07:21:00 EST


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.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 14 2002 - 12:00:09 EST