29#ifndef HPP_UTIL_TIMER_HH 30#define HPP_UTIL_TIMER_HH 33#include <hpp/util/config.hh> 44 explicit Timer(
bool autoStart =
false);
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) 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
double stop()
Definition timer.cc:83
std::chrono::system_clock clock_type
Definition timer.hh:104
std::ostream & print(std::ostream &os) const
Definition timer.cc:111
std::chrono::duration< double > duration_type
Definition timer.hh:106
void reset()
Definition timer.cc:94
TimeCounter(const std::string &name)
Definition timer.cc:74
clock_type::time_point time_point
Definition timer.hh:105
double mean() const
Definition timer.cc:105
double min() const
Definition timer.cc:101
double totalTime() const
Definition timer.cc:109
double last()
Definition timer.cc:92
void start()
Definition timer.cc:81
double max() const
Definition timer.cc:103
std::chrono::duration< double > duration_type
Definition timer.hh:42
Timer & operator=(const Timer &)
Definition timer.cc:43
Timer(bool autoStart=false)
Definition timer.cc:37
double duration() const
Definition timer.cc:60
std::chrono::steady_clock clock_type
Definition timer.hh:40
std::ostream & print(std::ostream &) const
Definition timer.cc:62
const time_point & start()
Definition timer.cc:52
clock_type::time_point time_point
Definition timer.hh:41
const time_point & getStop() const
Definition timer.cc:58
const time_point & getStart() const
Definition timer.cc:56
const time_point & stop()
Definition timer.cc:54
std::ostream & operator<<(std::ostream &os, const TimeCounter &tc)
Definition timer.cc:116
Definition assertion.hh:45
Scope(TimeCounter &t)
Definition timer.hh:98
~Scope()
Definition timer.hh:99
TimeCounter & tc
Definition timer.hh:101