17 using ClockT = std::chrono::high_resolution_clock;
18 using TimePointT = std::chrono::high_resolution_clock::time_point;
19 using DurationT = std::chrono::high_resolution_clock::duration;
20 using SecondsT = std::chrono::duration<double>;
26 elapsed = DurationT::zero();
29 void Start() { start = ClockT::now(); }
30 void Stop() { elapsed += ClockT::now() - start; }
31 double ElapsedSeconds()
const {
return SecondsT(elapsed).count(); }
32 void PrintElapsed(std::string label) {
34 snprintf(buffer,
sizeof(buffer),
"%s:\t %fs", label.c_str(),
35 SecondsT(elapsed).count());
36 LOG(CONSOLE) << buffer;
56 using StatMap = std::map<std::string, std::pair<size_t, size_t>>;
58 std::string label_ =
"";
59 std::map<std::string, Statistics> statistics_map_;
62 void PrintStatistics(StatMap
const& statistics)
const;
65 Monitor() { self_timer_.Start(); }
80 void Init(std::string label) { this->label_ = label; }
81 void Start(
const std::string &name);
82 void Stop(
const std::string &name);