11#ifndef TLX_MULTI_TIMER_HEADER
12#define TLX_MULTI_TIMER_HEADER
56 void start(
const char* timer);
68 double get(
const char* timer);
73 void print(
const char* info, std::ostream& os)
const;
75 void print(
const char* info)
const;
100 std::chrono::time_point<std::chrono::high_resolution_clock>
time_point_;
MultiTimer can be used to measure time usage of different phases in a program or algorithm.
void print(const char *info, std::ostream &os) const
print all timers as a TIMER line to os
void start(const char *timer)
start new timer phase, stop the currently running one.
const char * running_
currently running timer name
Entry & find_or_create(const char *name)
internal methods to find or create new timer entries
MultiTimer(MultiTimer &&)
move-constructor: default
std::vector< Entry > timers_
array of timers
MultiTimer & operator+=(const MultiTimer &b)
add all timers from another, internally holds a global mutex lock, because this is used to add thread...
MultiTimer(const MultiTimer &)
default copy-constructor
std::chrono::duration< double > total_duration_
total duration
std::uint32_t running_hash_
hash of running_
void stop()
stop the currently running timer.
const char * running() const
return name of currently running timer.
MultiTimer & add(const MultiTimer &b)
add all timers from another, internally holds a global mutex lock, because this is used to add thread...
MultiTimer & operator=(const MultiTimer &)
default assignment operator
double get(const char *timer)
return timer duration in seconds of timer.
std::chrono::time_point< std::chrono::high_resolution_clock > time_point_
start of currently running timer name
double total() const
return total duration of all timers.
RAII Scoped MultiTimer switcher: switches the timer of a MultiTimer on construction and back to old o...
~ScopedMultiTimerSwitch()
change back timer to previous timer.
MultiTimer & timer_
reference to MultiTimer
const char * previous_
previous timer, used to switch back to on destruction
ScopedMultiTimerSwitch(MultiTimer &timer, const char *new_timer)
construct and timer to switch to
Independent RAII Scoped MultiTimer: contains a MultiTimer which is started with the given timer,...
MultiTimer & base_
reference to base timer
~ScopedMultiTimer()
change back timer to previous timer.
ScopedMultiTimer(MultiTimer &base, const char *timer)
construct and change timer to tm
MultiTimer timer_
contained independent timer