• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

timertest.c

Go to the documentation of this file.
00001 /** @file timertest.c test harness for timer.
00002  */
00003 
00004 
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 #include "x86timer.h"
00008 
00009 
00010 int main(int argc, char* argv[])
00011 {
00012         unsigned long long raw[10];
00013         unsigned long times[10];
00014         unsigned int delay = 1;
00015         int ii;
00016 
00017         if (argc > 1) delay = atoi(argv[1]);
00018         
00019         get_cpu_clock_speed();    /** inits library */
00020 
00021         printf("timertest get_cpu_clock_speed %d\n", get_cpu_clock_speed());
00022 
00023         printf("raw\n");
00024         for (ii = 0; ii != 10; ++ii){
00025                 raw[ii] = get_cpu_ticks();
00026         }
00027 
00028         for (ii = 0; ii != 10; ++ii){
00029                 printf("%2d ticks 0x%016Lx %16Lu usecs %10Lu\n", 
00030                        ii, raw[ii], raw[ii], raw[ii]/get_cpu_clock_speed());
00031         }       
00032 
00033         
00034 
00035 
00036         for (ii = 0; ii != 10; ++ii){
00037                 times[ii] = get_elapsed_microseconds(ii == 0);
00038         }
00039 
00040         printf("No Delay Loop\n");
00041 
00042         for (ii = 0; ii != 10; ++ii){
00043                 printf("%2d usecs %10lu\n", ii, times[ii]);
00044         }       
00045 
00046         printf("Delay Loop %d\n", delay);
00047 
00048         for (ii = 0; ii != 10; ++ii){
00049                 times[ii] = get_elapsed_microseconds(ii == 0);
00050                 cpu_delay_awhile(delay);
00051         }
00052 
00053         for (ii = 0; ii != 10; ++ii){
00054                 printf("%2d usecs %10lu\n", ii, times[ii]);
00055         }       
00056         return 0;
00057 }

Generated on Wed Jan 5 2011 for llcontrol by  doxygen 1.7.1