29#ifndef HPP_UTIL_TIMER_HH
30#define HPP_UTIL_TIMER_HH
51 double duration()
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)
118 double totalTime()
const;
120 std::ostream& print(std::ostream&
os)
const;
131#ifdef HPP_ENABLE_BENCHMARK
137#define HPP_DEFINE_TIMECOUNTER(name) \
138 ::hpp::debug::TimeCounter _##name##_timecounter_(#name)
140#define HPP_SCOPE_TIMECOUNTER(name) \
141 ::hpp::debug::TimeCounter::Scope _##name##_scopetimecounter_( \
142 _##name##_timecounter_)
144#define HPP_START_TIMECOUNTER(name) _##name##_timecounter_.start()
146#define HPP_STOP_TIMECOUNTER(name) _##name##_timecounter_.stop()
148#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); \
157#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); \
166#define HPP_RESET_TIMECOUNTER(name) _##name##_timecounter_.reset();
168#define HPP_STREAM_TIMECOUNTER(os, name) os << _##name##_timecounter_
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
182#define HPP_STOP_AND_DISPLAY_TIMECOUNTER(name) \
183 HPP_STOP_TIMECOUNTER(name); \
184 HPP_DISPLAY_TIMECOUNTER(name)
Computation of min, max and mean time from a set of measurements.
Definition timer.hh:95
std::chrono::system_clock clock_type
Definition timer.hh:104
std::chrono::duration< double > duration_type
Definition timer.hh:106
clock_type::time_point time_point
Definition timer.hh:105
void start()
Definition timer.cc:81
std::chrono::duration< double > duration_type
Definition timer.hh:42
std::chrono::steady_clock clock_type
Definition timer.hh:40
clock_type::time_point time_point
Definition timer.hh:41
#define HPP_UTIL_DLLAPI
Definition config.hh:88
std::ostream & operator<<(std::ostream &os, const TimeCounter &tc)
Definition timer.cc:116
Definition assertion.hh:45
Class to ease exception creation.
Definition exception-factory.hh:73
Scope(TimeCounter &t)
Definition timer.hh:98
~Scope()
Definition timer.hh:99
TimeCounter & tc
Definition timer.hh:101