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