[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need time in nano seconds





Micheal Mukherji wrote:
On Mon, 13 Dec 2004 08:43:28 -0600, Ron Johnson <ron.l.johnson@cox.net> wrote:

Remember, though, that a ns is 1 billionth of a second, and so a
3GHz CPU will onll does 3 cycles in a ns.  Unless you are coding
to the bare metal with a *minimal* OS, like DOS, you can't do
anything useful in 3 clock ticks.



On a 1.4 GHz processor, I use JVMPI( an abbreviation for Java Virtual
Machine Programming Interface). It has a method called
GetThreadCPUTime(), which it claims gives thread execution time in
nanoseconds. He does not mention any hardware support. How do you
think he is going to provide it?? I am getting values in tens of nano
seconds also..



This hilights the difference between 'accuracy' and 'precision'.

When an interface claims to offer nanosecond time information, it's not
making any claim about how accurate its information will be.

So, for example, you might be able to read values like the following
from the timer, if you have a sufficiently fast program:
 21223232000
 21223233000
 21223234000
 21223235000
 21223236000

Those values are very precise (down to the ns), but in general they're
not any more *accurate* than a *microsecond* timer could be.

I suspect that people write APIs in terms of nanoseconds so that,
if/when the hardware/os actually supports measuring time that
accurately, the API doesn't need to change.

--
Christian Convey
Computer Scientist,
Naval Undersea Warfare Center
Newport, RI



Reply to: