12 #include <unordered_map> 19 using Clock = std::chrono::high_resolution_clock;
20 using Time = Clock::time_point;
21 using Duration = Clock::duration;
35 static void summary(std::ostream& out);
42 static std::shared_ptr<Manager>
singleton();
48 Manager() : _created(Clock::now()) {}
50 void register_(
Ledger* ledger);
51 void unregister(
Ledger* ledger);
52 Ledger* newLedger(
const std::string& name);
56 std::unordered_map<std::string, Ledger*> _all_ledgers;
57 std::list<Ledger> _our_ledgers;
68 _manager->register_(
this);
70 ~
Ledger() { _manager->unregister(
this); }
78 const std::string& name()
const {
return _name; }
80 void summary(std::ostream& out)
const;
93 assert(_time_started == Time());
94 _time_started = Clock::now();
106 assert(_time_started != Time());
107 _time_used += (Clock::now() - _time_started);
108 _time_started = Time();
114 _time_used += (Clock::now() - _time_started);
115 _time_started = Time();
122 Duration _time_used = Duration(0);
123 uint64_t _num_completed = 0;
128 std::shared_ptr<detail::Manager> _manager;
144 void finish() { _ledger->finish(); }
static void summary(std::ostream &out)
Definition: timing.cc:68
static std::shared_ptr< Manager > singleton()
Definition: timing.cc:41