12 typedef std::map<std::string, timing_t> timing_map;
15 std::vector<std::string> order;
20 timing_t get(
const std::string& name)
const {
21 timing_map::const_iterator i = timings.find(name);
22 return (i != timings.end()) ? i->second : 0;
38 void record(
const std::string& name);
48 void write(std::ostream& out = std::cout,
bool print_total =
false)
const;
51 void dump(std::ostream& out = std::cout,
bool print_total =
false) {
52 write(out, print_total);
void record(const std::string &name)
Records time since start or last call to record.
void dump(std::ostream &out=std::cout, bool print_total=false)
Writes AND clears.
Timer & operator=(const Timer &other)
timing_t operator[](const std::string &name) const
Returns the i-th timing recorded (starting with 0)
unsigned long long timing_t
Size for timings reported by get_time_ns.
void fast_forward()
Skips ahead and sets last time to now.
void write(std::ostream &out=std::cout, bool print_total=false) const
Prints all timings (nicely formatted, in sec) to a file.
std::ostream & operator<<(std::ostream &out, const Timer &timer)
Syntactic sugar; calls write on the timer and passes the ostream.
Timer & operator+=(const Timer &other)
Appends timings from another timer to those for this one.
timing_t start_time() const
Returns when the timer was initially constructed.
void clear()
Empties out all recorded timings so far AND sets last_time to now.