00001 #ifndef TIMER_H
00002 #define TIMER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdio.h>
00027 #include "tsc.h"
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033
00034
00035 extern FILE * timerFP;
00036 extern int timerCount;
00037 extern double time_Master;
00038
00039 extern void Timer_Start(void);
00040 extern void Timer_Stop(void);
00041
00042 #ifdef DO_TIMER //}{
00043
00044 #pragma message("timer ON")
00045
00046 #define TIMER_VARS(func) static double time_##func =0.0; static tsc_type tsc_##func##1,tsc_##func##2;
00047
00048 #define TIMER_P(func) readTSC(tsc_##func##1)
00049 #define TIMER_Q(func) do { readTSC(tsc_##func##2); time_##func += diffTSC(tsc_##func##1,tsc_##func##2); } while(0)
00050
00051 #define TIMER_REPORT(func) fprintf(timerFP,"%-20s : %1.6f : %2.1f %%\n", (#func) , (time_##func)/(double)timerCount , (time_##func)*100.0/(time_Master) );
00052
00053 #define TIMER_COUNT() timerCount++
00054
00055 #define TIMER_START() Timer_Start();
00056 #define TIMER_STOP() Timer_Stop();
00057
00058 #else //}{
00059
00060 #pragma message("timer OFF")
00061
00062 #define TIMER_VARS(func)
00063 #define TIMER_P(func)
00064 #define TIMER_Q(func)
00065 #define TIMER_REPORT(func)
00066
00067 #define TIMER_COUNT()
00068
00069 #define TIMER_START()
00070 #define TIMER_STOP()
00071
00072 #endif //}{
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116
00117 #endif // TIMER_H
00118