25#ifndef CROCODDYL_CORE_UTILS_STOPWATCH_H_
26#define CROCODDYL_CORE_UTILS_STOPWATCH_H_
36#pragma GCC visibility push(default)
39#define START_PROFILER(name) \
40 getProfiler().profiler_status() ? getProfiler().start(name) : void()
41#define STOP_PROFILER(name) \
42 getProfiler().profiler_status() ? getProfiler().stop(name) : void()
44#define STOP_WATCH_MAX_NAME_LENGTH 60
45#define STOP_WATCH_TIME_WIDTH 10
165 : w(_w), n(_n), p(_p) {}
166 inline void start() {
200 Watcher
watcher(
const std::string &perf_name);
203 void start(
const std::string &perf_name);
206 void stop(
const std::string &perf_name);
209 void pause(
const std::string &perf_name);
212 void reset(
const std::string &perf_name);
218 void report(
const std::string &perf_name,
int precision = 2,
219 std::ostream &output = std::cout);
222 void report_all(
int precision = 2, std::ostream &output = std::cout);
260 min_time(std::numeric_limits<long double>::max()),
261 max_time(std::numeric_limits<long double>::min()),
282 std::map<std::string, PerformanceData>
292#pragma GCC visibility pop
A class representing a stopwatch.
bool active
Flag to hold the clock's status.
long double get_total_time(const std::string &perf_name)
Returns total execution time of a certain performance.
void reset_all()
Resets all the performance records.
bool profiler_status()
Return if the profiler is enable or disable.
long double take_time()
Take time, depends on mode.
long double get_time_so_far(const std::string &perf_name)
Return the time since the start of the last measurement of a given performance.
void stop(const std::string &perf_name)
Stops the stopwatch related to a certain piece of code.
void turn_on()
Turn on clock, restore clock operativity after a turn_off().
long double get_last_time(const std::string &perf_name)
Return last measurement of a certain performance.
std::map< std::string, PerformanceData > * records_of
Dynamic collection of performance data.
void start(const std::string &perf_name)
Start the stopwatch related to a certain piece of code.
void reset(const std::string &perf_name)
Reset a certain performance record.
Watcher watcher(const std::string &perf_name)
create a Start the stopwatch related to a certain piece of code
void disable_profiler()
Disable the profiler.
bool profiler_active
Indicates if the profiler is enabled.
void report_all(int precision=2, std::ostream &output=std::cout)
Dump the data of all the performance records.
long double get_max_time(const std::string &perf_name)
Returns maximum execution time of a certain performance.
long double get_average_time(const std::string &perf_name)
Returns average execution time of a certain performance.
void set_mode(StopwatchMode mode)
Initialize stopwatch to use a certain time taking mode.
long double get_min_time(const std::string &perf_name)
Returns minimum execution time of a certain performance.
void turn_off()
Turn off clock, all the Stopwatch::* methods return without doing anything after this method is calle...
bool performance_exists(std::string perf_name)
Tells if a performance with a certain ID exists.
void pause(const std::string &perf_name)
Stops the stopwatch related to a certain piece of code.
void enable_profiler()
Enable the profiler.
StopwatchMode mode
Time taking mode.
void report(const std::string &perf_name, int precision=2, std::ostream &output=std::cout)
Dump the data of a certain performance record.