Announcing the release of nanotime v0.1
nanotime is a shell callable utility which reads and returns a 64 bit high resolution time stamp on cpus which support the TSC register. The TSC register increments at the basic system clock rate, making this a very high speed counter. [Editor's note: Not your every day story, but interesting, thus I posted it. :) ]
|
|
/*
* nanotime
*
* version 0.1
*
* Copyright 2004 under the terms of the GNU General Public License (GPL)
*
* nanotime is a shell callable utility which reads and
* returns a 64 bit high resolution time stamp on cpus
* which support the TSC register. Results are returned
* as a decimal number. The TSC register begins counting
* at CPU reset time and increments at the basic system
* clock rate, making this a very high speed counter.
*
* example: a 2.8GHz clock on an Intel P4 results in a
* nanotime resolution of 0.357 nanoseconds.
*
*
*/
#include <stdio.h>
#define get_nanotime(nanotime) __asm__ __volatile__ (
"rdtscntmovl %%eax, %0ntmovl %%edx, %%eaxntmovl %%eax, 4%0n"
: "=m" (nanotime) :: "eax", "edx" );
int main(int argc, char *argv[])
{
unsigned long long tm;
if (argc > 1) {
printf("Usage:t %snnanotime v0.1 nCopyright 2004 GPLn",argv[0]);
return 0;
}
get_nanotime(tm);
printf("%Lun",tm);
return 0;
}
|
This topic does not have any threads posted yet!
You cannot post until you login.