18 #ifndef HPP_UTIL_TIMER_HH 19 # define HPP_UTIL_TIMER_HH 37 explicit Timer (
bool autoStart =
false);
44 double duration ()
const;
49 std::ostream& print (std::ostream&)
const;
55 # ifdef HPP_ENABLE_BENCHMARK 57 # define hppStartBenchmark(ID) \ 58 hppDout (benchmark, #ID << ": start"); \ 59 ::hpp::debug::Timer _##ID##_timer_ (true) 61 # define hppStopBenchmark(ID) \ 63 _##ID##_timer_.stop (); \ 64 hppDout (benchmark, #ID << ": stop"); \ 67 # define hppDisplayBenchmark(ID) \ 68 hppDout (benchmark, #ID << ": "<< _##ID##_timer_.duration ()); 70 # define hppBenchmark(data) \ 72 using namespace hpp; \ 73 using namespace ::hpp::debug; \ 74 std::stringstream __ss; \ 75 __ss << data << iendl; \ 76 logging.benchmark.write (__FILE__, __LINE__, __PRETTY_FUNCTION__, \ 81 # define hppStartBenchmark(ID) 82 # define hppStopBenchmark(ID) 83 # define hppDisplayBenchmark(ID) 84 # define hppBenchmark(data) 85 # endif // HPP_ENABLE_BENCHMARK 111 double mean ()
const;
112 double totalTime ()
const;
114 std::ostream& print (std::ostream& os)
const;
125 # ifdef HPP_ENABLE_BENCHMARK 131 # define HPP_DEFINE_TIMECOUNTER(name) \ 132 ::hpp::debug::TimeCounter _##name##_timecounter_ (#name) 133 # define HPP_SCOPE_TIMECOUNTER(name) \ 135 ::hpp::debug::TimeCounter::Scope _##name##_scopetimecounter_ \ 136 (_##name##_timecounter_) 137 # define HPP_START_TIMECOUNTER(name) \ 139 _##name##_timecounter_.start () 140 # define HPP_STOP_TIMECOUNTER(name) \ 142 _##name##_timecounter_.stop() 143 # define HPP_DISPLAY_LAST_TIMECOUNTER(name) \ 146 using namespace hpp; \ 147 using namespace ::hpp::debug; \ 148 std::stringstream __ss; \ 149 __ss << #name << " last: " \ 150 << _##name##_timecounter_.last() << iendl; \ 151 logging.benchmark.write (__FILE__, __LINE__, \ 152 __PRETTY_FUNCTION__, __ss); \ 154 # define HPP_DISPLAY_TIMECOUNTER(name) \ 157 using namespace hpp; \ 158 using namespace ::hpp::debug; \ 159 std::stringstream __ss; \ 160 __ss << _##name##_timecounter_ << iendl; \ 161 logging.benchmark.write (__FILE__, __LINE__, \ 162 __PRETTY_FUNCTION__, __ss); \ 164 # define HPP_RESET_TIMECOUNTER(name) \ 166 _##name##_timecounter_.reset(); 167 # define HPP_STREAM_TIMECOUNTER(os, name) \ 169 os << _##name##_timecounter_ 170 # else // HPP_ENABLE_BENCHMARK 172 # define HPP_DEFINE_TIMECOUNTER(name) \ 173 struct _##name##_EndWithSemiColon_{} 174 # define HPP_SCOPE_TIMECOUNTER(name) 175 # define HPP_START_TIMECOUNTER(name) 176 # define HPP_STOP_TIMECOUNTER(name) 177 # define HPP_DISPLAY_LAST_TIMECOUNTER(name) 178 # define HPP_DISPLAY_TIMECOUNTER(name) 179 # define HPP_RESET_TIMECOUNTER(name) 180 # define HPP_STREAM_TIMECOUNTER(os, name) \ 182 # endif // HPP_ENABLE_BENCHMARK 184 # define HPP_STOP_AND_DISPLAY_TIMECOUNTER(name) \ 185 HPP_STOP_TIMECOUNTER(name); \ 186 HPP_DISPLAY_TIMECOUNTER(name) 191 #endif // HPP_UTIL_TIMER_HH ~Scope()
Definition: timer.hh:93
std::chrono::high_resolution_clock clock_type
Definition: timer.hh:33
std::chrono::high_resolution_clock clock_type
Definition: timer.hh:98
clock_type::time_point time_point
Definition: timer.hh:34
Definition: assertion.hh:22
std::chrono::duration< double > duration_type
Definition: timer.hh:35
void start()
Definition: timer.cc:99
std::ostream & operator<<(std::ostream &os, const TimeCounter &tc)
Definition: timer.cc:158
Scope(TimeCounter &t)
Definition: timer.hh:92
#define HPP_UTIL_DLLAPI
Definition: config.hh:64
clock_type::time_point time_point
Definition: timer.hh:99
std::chrono::duration< double > duration_type
Definition: timer.hh:100
TimeCounter & tc
Definition: timer.hh:95
Computation of min, max and mean time from a set of measurements.
Definition: timer.hh:88