00001 #ifndef JITTEROMETER_H 00002 #define JITTEROMETER_H 00003 00004 00005 class Jitterometer 00006 { 00007 public: 00008 Jitterometer(char *name, int num_cycles); 00009 ~Jitterometer(); 00010 00011 00012 /* Jitterometer usage. There are 2 ways to use this: 00013 00014 ------------------------------------------------------------------ 00015 00016 1. Every 100 iterations of the for loop, RecordCycleTime() will 00017 print a report about the mean time to execute the loop, and 00018 the jitter in the recorded times. 00019 00020 my_jmeter = new Jitterometer("forloop", 100); 00021 for ( ) { 00022 00023 ... some stuff ... 00024 00025 my_jmeter->RecordCycleTime(); 00026 } 00027 00028 ------------------------------------------------------------------- 00029 00030 2. Every 42 times Weird_Operation() is run, RecordEndTime() will 00031 print a report about the mean time to do a Weird_Operation(), and 00032 the jitter in the recorded times. 00033 00034 beer = new Jitterometer("weird operation", 42); 00035 for( ) { 00036 ... 00037 beer->RecordStartTime(); 00038 Weird_Operation(); 00039 beer->RecordEndTime(); 00040 ... 00041 } 00042 */ 00043 00044 bool RecordCycleTime(); 00045 00046 void RecordStartTime(); 00047 bool RecordEndTime(); 00048 00049 private: 00050 int count; 00051 int num_cycles; 00052 00053 struct timeval starttime; 00054 int starttime_valid; 00055 unsigned *times; // array of cycle lengths, in uS 00056 00057 char *name; 00058 }; 00059 00060 #endif // JITTEROMETER_H 00061 00062
1.5.5