16 timings(other.timings),
24 timings = other.timings;
52 timing_map::iterator i = timings.find(name);
53 if (i == timings.end()) {
54 order.push_back(name);
56 timings[name] += elapsed;
63 for (
size_t i=0; i < other.order.size(); i++) {
64 const string& other_name = other.order[i];
65 if (timings.find(other_name) == timings.end()) {
66 order.push_back(other_name);
68 timings[other_name] += other[other_name];
76 const string total(
"Total");
77 size_t max_len = total.length();
79 for (
size_t i=0; i < order.size(); i++) {
80 max_len = max(max_len, order[i].length());
83 const size_t width = max_len + 2;
84 for (
size_t i=0; i < order.size(); i++) {
86 name << order[i] <<
":";
87 out << left << setw(width) << name.str() << (
get(order[i]) / 1e9) << endl;
90 if (print_total) out << left << setw(width) << total << ((now - start) / 1e9) << endl;
void record(const std::string &name)
Records time since start or last call to record.
Timer & operator=(const Timer &other)
unsigned long long timing_t
Size for timings reported by get_time_ns.
timing_t get_time_ns()
This is defined differently depending on compile-time timing options and on the platform we're using...
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.
Timer & operator+=(const Timer &other)
Appends timings from another timer to those for this one.
void clear()
Empties out all recorded timings so far AND sets last_time to now.