[vox-tech] Easiest way to calculate date in 100 ns increments?

Rick Moen rick at linuxmafia.com
Wed Jun 23 15:28:41 PDT 2004


Quoting Mark K. Kim (lugod at cbreak.org):

> Having said that, `date` is a nice tool for converting from human readable
> format to hour/minute/sec/nanosec if you're scripting, and the source is
> freely available if you're using C!

Most likely, the results wouldn't be meaningful since the querent is
looking for 100 ns resolution.  I believe that date uses gettimeofday,
which is at best accurate to about two microseconds.  It'd be a
challenge to converge in 100 ns accuracy with a suitable algorithm --
under rather rare conditions, I would think.  I used to know how to do
this, but that would have been in structured Fortran.  ;->  [1]

If you need 100 ns resolution, therefore, it's better to use something
like Robert G. Brown's nanotimer utility, which reads and uses
information from the on-board cycle counter accessible on pretty much
all modern CPUs.  See:

http://www.beowulf.org/pipermail/beowulf/2004-January/009028.html

[1] No, that language is not dead; it just smells that way.  Quit
sniggering, sonny, or I'll whack you with my cane.

-- 
Cheers,        "A raccoon tangled with a 23,000 volt line, today.  The results
Rick Moen       blacked out 1400 homes and, of course, one raccoon."
rick at linuxmafia.com                                  -- Steel City News


More information about the vox-tech mailing list