00001
00002
00003
00004
00005
00006
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <sys/types.h>
00010 #include <sys/time.h>
00011 #include <unistd.h>
00012 #define TEST_DELAY 16
00013
00014 int main (int argc, char **argv) {
00015 unsigned long long t1, t2;
00016 unsigned int t1l, t2l, t1h, t2h;
00017 struct timeval to = { 0, 0 };
00018 int delay;
00019
00020 if ( argc<2 || (delay = atoi(argv[1])) < 1 )
00021 {
00022 fprintf (stderr,
00023 "\nUsage:\n\n"
00024 "%s <delay>\n\n"
00025 "Specify a delay in seconds to calibrate. A longer delay will provide a more\n"
00026 "accurate result. 8-32 seconds should be sufficient for most purposes. Define\n"
00027 "TIME_FILTER, define TF_TYPE as TSC, and define TF_TSC_TICKS as the reported\n"
00028 "value when building filters in order to use TSC benchmarks reported in frames\n"
00029 "per second instead of ticks per frame.\n\n",
00030 argv[0]);
00031 exit (1);
00032 }
00033
00034 to.tv_sec = delay;
00035 asm ("rdtsc" :"=a" (t1l), "=d" (t1h));
00036 select (0,0,0,0, &to);
00037 asm ("rdtsc" :"=a" (t2l), "=d" (t2h));
00038 t1 = t1l + ((unsigned long long)t1h<<32);
00039 t2 = t2l + ((unsigned long long)t2h<<32);
00040 printf ("TF_TSC_TICKS for this system: %llu\n", (t2-t1+delay/2)/delay);
00041 }