00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00033
00034 #ifndef GROOVX_RUTZ_PROF_H_UTC20050630214711_DEFINED
00035 #define GROOVX_RUTZ_PROF_H_UTC20050630214711_DEFINED
00036
00037 #include "rutz/time.h"
00038
00039 #include <iosfwd>
00040
00041 namespace rutz
00042 {
00043 class prof;
00044 }
00045
00047
00089 class rutz::prof
00090 {
00091 public:
00092 prof(const char* s, const char* fname, int lineno) throw();
00093 ~prof() throw();
00094
00096 enum timing_mode
00097 {
00098 WALLCLOCK,
00099 RUSAGE
00100 };
00101
00103 static timing_mode get_timing_mode() throw()
00104 { return s_timing_mode; }
00105
00107 static void set_timing_mode(timing_mode mode) throw()
00108 { s_timing_mode = mode; }
00109
00111 static rutz::time get_now_time(timing_mode mode) throw()
00112 {
00113 switch (mode)
00114 {
00115 case rutz::prof::RUSAGE:
00116 return (rutz::time::user_rusage() + rutz::time::sys_rusage());
00117
00118 case rutz::prof::WALLCLOCK:
00119 default:
00120 return rutz::time::wall_clock_now();
00121 }
00122 }
00123
00125 void reset() throw();
00126
00128 unsigned int count() const throw();
00129
00130 void add_time(const rutz::time& t) throw();
00131
00132 void add_child_time(const rutz::time& t) throw();
00133
00134 const char* context_name() const throw();
00135
00136 const char* src_file_name() const throw();
00137
00138 int src_line_no() const throw();
00139
00141 double total_time() const throw();
00142
00144 double self_time() const throw();
00145
00147 double avg_self_time() const throw();
00148
00150 void print_prof_data(FILE* f) const throw();
00151
00153 void print_prof_data(std::ostream& os) const throw();
00154
00156 static void print_at_exit(bool yes_or_no) throw();
00157
00159 static void prof_summary_file_name(const char* fname);
00160
00162 static void reset_all_prof_data() throw();
00163
00165 static void print_all_prof_data(FILE* f) throw();
00166
00168 static void print_all_prof_data(std::ostream& os) throw();
00169
00170 private:
00171 prof(const prof&) throw();
00172 prof& operator=(const prof&) throw();
00173
00174 const char* const m_context_name;
00175 const char* const m_src_file_name;
00176 int const m_src_line_no;
00177 unsigned int m_call_count;
00178 rutz::time m_total_time;
00179 rutz::time m_children_time;
00180
00181 static timing_mode s_timing_mode;
00182 };
00183
00184 static const char __attribute__((used)) vcid_groovx_rutz_prof_h_utc20050630214711[] = "$Id: prof.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00185 #endif // !GROOVX_RUTZ_PROF_H_UTC20050630214711DEFINED