00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <sys/time.h>
00025
00026 #if defined(REPOS_PERF_DEBUG)
00027
00028 #if defined(__cplusplus)
00029
00030 class LongId;
00031
00032 extern "C" {
00033 #endif // defined(__cplusplus)
00034
00035
00036 void timing_start_call(unsigned int proc);
00037
00038 #define TIMING_START_CALL(proc) timing_start_call(proc)
00039
00040
00041
00042 void timing_dupe_status(int new_call);
00043
00044 #define TIMING_DUPE_STATUS(new_call) timing_dupe_status(new_call)
00045
00046
00047 void timing_record_time_point(const char *file, unsigned int line);
00048
00049 #define RECORD_TIME_POINT timing_record_time_point(__FILE__, __LINE__)
00050
00051
00052
00053 void timing_end_call( struct timeval *delta_time);
00054
00055 #define TIMING_END_CALL(delta) timing_end_call(delta)
00056
00057
00058 int timing_in_call();
00059
00060 #define TIMING_IN_CALL timing_in_call()
00061
00062 #if defined(__cplusplus)
00063
00064
00065 void timing_control(bool enable);
00066
00067 void timing_record_LongId(const LongId &lid);
00068
00069 #define TIMING_RECORD_LONGID(lid) timing_record_LongId(lid)
00070
00071 }
00072
00073 #include <stdio.h>
00074
00075 #define TIMING_RECORDER_BUF_SIZE 32768
00076
00077 extern "C"
00078 {
00079 void Timing_Recorder_exit_cleanup_setup() throw();
00080 void Timing_Recorder_exit_cleanup() throw();
00081 }
00082
00083 class Timing_Recorder
00084 {
00085 private:
00086
00087 FILE *timing_record_stream;
00088
00089
00090 unsigned long file_end_time;
00091
00092
00093 struct timeval start_time;
00094
00095
00096 char write_buffer[TIMING_RECORDER_BUF_SIZE];
00097
00098
00099 unsigned int current_byte_count;
00100
00101
00102 struct timeval record_delta();
00103
00104
00105 static Timing_Recorder *first;
00106 Timing_Recorder *next;
00107
00108
00109 void start_new_file(struct timeval *current_time = 0);
00110
00111 public:
00112 Timing_Recorder();
00113 ~Timing_Recorder();
00114
00115 void start(unsigned int proc);
00116
00117 void dupe_status(bool new_call);
00118
00119 void time_point(const char *file, unsigned short line);
00120
00121 struct timeval end();
00122
00123 inline bool in_call()
00124 {
00125 return (current_byte_count > 0);
00126 }
00127
00128 void record_LongId(const LongId &lid);
00129
00130 friend void Timing_Recorder_exit_cleanup_setup() throw();
00131 friend void Timing_Recorder_exit_cleanup() throw();
00132 };
00133 #endif
00134
00135 #else
00136
00137 #define TIMING_START_CALL(proc) ((void)0)
00138 #define TIMING_DUPE_STATUS(new_call) ((void)0)
00139 #define RECORD_TIME_POINT ((void)0)
00140 #define TIMING_END_CALL(delta) ((void)0)
00141 #define TIMING_IN_CALL 0
00142 #define TIMING_RECORD_LONGID(lid) ((void)0)
00143
00144 #endif