24 #ifndef CROCODDYL_CORE_UTILS_STOPWATCH_H_ 25 #define CROCODDYL_CORE_UTILS_STOPWATCH_H_ 34 #pragma GCC visibility push(default) 37 #define START_PROFILER(name) getProfiler().profiler_status() ? getProfiler().start(name) : void() 38 #define STOP_PROFILER(name) getProfiler().profiler_status() ? getProfiler().stop(name) : void() 40 #define STOP_WATCH_MAX_NAME_LENGTH 60 41 #define STOP_WATCH_TIME_WIDTH 10 174 void start(
const std::string &perf_name);
177 void stop(
const std::string &perf_name);
180 void pause(
const std::string &perf_name);
183 void reset(
const std::string &perf_name);
189 void report(
const std::string &perf_name,
int precision = 2, std::ostream &output = std::cout);
192 void report_all(
int precision = 2, std::ostream &output = std::cout);
250 #pragma GCC visibility pop void start(const std::string &perf_name)
Start the stopwatch related to a certain piece of code.
void reset_all()
Resets all the performance records.
long double take_time()
Take time, depends on mode.
void reset(const std::string &perf_name)
Reset a certain performance record.
void turn_on()
Turn on clock, restore clock operativity after a turn_off().
void disable_profiler()
Disable the profiler.
void report_all(int precision=2, std::ostream &output=std::cout)
Dump the data of all the performance records.
Stopwatch(StopwatchMode _mode=NONE)
Constructor.
long double get_min_time(const std::string &perf_name)
Returns minimum execution time of a certain performance.
long double get_total_time(const std::string &perf_name)
Returns total execution time of a certain performance.
bool profiler_active
Indicates if the profiler is enabled.
long double get_average_time(const std::string &perf_name)
Returns average execution time of a certain performance.
bool performance_exists(std::string perf_name)
Tells if a performance with a certain ID exists.
void enable_profiler()
Enable the profiler.
bool profiler_status()
Return if the profiler is enable or disable.
StopwatchMode mode
Time taking mode.
void turn_off()
Turn off clock, all the Stopwatch::* methods return without doing anything after this method is calle...
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 set_mode(StopwatchMode mode)
Initialize stopwatch to use a certain time taking mode.
void stop(const std::string &perf_name)
Stops the stopwatch related to a certain piece of code.
void report(const std::string &perf_name, int precision=2, std::ostream &output=std::cout)
Dump the data of a certain performance record.
bool active
Flag to hold the clock's status.
std::map< std::string, PerformanceData > * records_of
Dynamic collection of performance data.
void pause(const std::string &perf_name)
Stops the stopwatch related to a certain piece of code.
long double get_max_time(const std::string &perf_name)
Returns maximum execution time of a certain performance.
long double get_last_time(const std::string &perf_name)
Return last measurement of a certain performance.
A class representing a stopwatch.