29 #ifndef HPP_UTIL_TIMER_HH 30 #define HPP_UTIL_TIMER_HH 44 explicit Timer(
bool autoStart =
false);
49 const time_point& start();
50 const time_point& stop();
51 double duration()
const;
53 const time_point& getStart()
const;
54 const time_point& getStop()
const;
56 std::ostream& print(std::ostream&)
const;
63 #ifdef HPP_ENABLE_BENCHMARK 65 #define hppStartBenchmark(ID) \ 66 hppDout(benchmark, #ID << ": start"); \ 67 ::hpp::debug::Timer _##ID##_timer_(true) 69 #define hppStopBenchmark(ID) \ 71 _##ID##_timer_.stop(); \ 72 hppDout(benchmark, #ID << ": stop"); \ 75 #define hppDisplayBenchmark(ID) \ 76 hppDout(benchmark, #ID << ": " << _##ID##_timer_.duration()); 78 #define hppBenchmark(data) \ 80 using namespace hpp; \ 81 using namespace ::hpp::debug; \ 82 std::stringstream __ss; \ 83 __ss << data << iendl; \ 84 logging.benchmark.write(__FILE__, __LINE__, __PRETTY_FUNCTION__, __ss); \ 88 #define hppStartBenchmark(ID) 89 #define hppStopBenchmark(ID) 90 #define hppDisplayBenchmark(ID) 91 #define hppBenchmark(data) 92 #endif // HPP_ENABLE_BENCHMARK 118 double totalTime()
const;
120 std::ostream& print(std::ostream& os)
const;
125 duration_type t_, last_, min_, max_;
131 #ifdef HPP_ENABLE_BENCHMARK 137 #define HPP_DEFINE_TIMECOUNTER(name) \ 138 ::hpp::debug::TimeCounter _##name##_timecounter_(#name) 139 #define HPP_SCOPE_TIMECOUNTER(name) \ 141 ::hpp::debug::TimeCounter::Scope _##name##_scopetimecounter_( \ 142 _##name##_timecounter_) 143 #define HPP_START_TIMECOUNTER(name) _##name##_timecounter_.start() 145 #define HPP_STOP_TIMECOUNTER(name) _##name##_timecounter_.stop() 147 #define HPP_DISPLAY_LAST_TIMECOUNTER(name) \ 150 using namespace hpp; \ 151 using namespace ::hpp::debug; \ 152 std::stringstream __ss; \ 153 __ss << #name << " last: " << _##name##_timecounter_.last() << iendl; \ 154 logging.benchmark.write(__FILE__, __LINE__, __PRETTY_FUNCTION__, __ss); \ 156 #define HPP_DISPLAY_TIMECOUNTER(name) \ 159 using namespace hpp; \ 160 using namespace ::hpp::debug; \ 161 std::stringstream __ss; \ 162 __ss << _##name##_timecounter_ << iendl; \ 163 logging.benchmark.write(__FILE__, __LINE__, __PRETTY_FUNCTION__, __ss); \ 165 #define HPP_RESET_TIMECOUNTER(name) _##name##_timecounter_.reset(); 167 #define HPP_STREAM_TIMECOUNTER(os, name) os << _##name##_timecounter_ 169 #else // HPP_ENABLE_BENCHMARK 171 #define HPP_DEFINE_TIMECOUNTER(name) \ 172 struct _##name##_EndWithSemiColon_ {} 173 #define HPP_SCOPE_TIMECOUNTER(name) 174 #define HPP_START_TIMECOUNTER(name) 175 #define HPP_STOP_TIMECOUNTER(name) 176 #define HPP_DISPLAY_LAST_TIMECOUNTER(name) 177 #define HPP_DISPLAY_TIMECOUNTER(name) 178 #define HPP_RESET_TIMECOUNTER(name) 179 #define HPP_STREAM_TIMECOUNTER(os, name) os 180 #endif // HPP_ENABLE_BENCHMARK 182 #define HPP_STOP_AND_DISPLAY_TIMECOUNTER(name) \ 183 HPP_STOP_TIMECOUNTER(name); \ 184 HPP_DISPLAY_TIMECOUNTER(name) 189 #endif // HPP_UTIL_TIMER_HH ~Scope()
Definition: timer.hh:99
clock_type::time_point time_point
Definition: timer.hh:41
Definition: assertion.hh:45
std::chrono::duration< double > duration_type
Definition: timer.hh:42
void start()
Definition: timer.cc:81
std::chrono::steady_clock clock_type
Definition: timer.hh:40
std::ostream & operator<<(std::ostream &os, const TimeCounter &tc)
Definition: timer.cc:116
Scope(TimeCounter &t)
Definition: timer.hh:98
#define HPP_UTIL_DLLAPI
Definition: config.hh:88
clock_type::time_point time_point
Definition: timer.hh:105
std::chrono::duration< double > duration_type
Definition: timer.hh:106
std::chrono::system_clock clock_type
Definition: timer.hh:104
TimeCounter & tc
Definition: timer.hh:101
Computation of min, max and mean time from a set of measurements.
Definition: timer.hh:95