Biorbd Release_1.13.0
Loading...
Searching...
No Matches
Benchmark.h
1#ifndef BIORBD_UTILS_BENCHMARK_H
2#define BIORBD_UTILS_BENCHMARK_H
3
4#include "biorbdConfig.h"
5
6#include <map>
7#include <memory>
8
9namespace BIORBD_NAMESPACE {
10namespace utils {
11class String;
12class Timer;
13
20class BIORBD_API Benchmark {
21 public:
25 Benchmark();
26
33 void startTimer(const String& name, bool force = false);
34
39 void pauseTimer(const String& name);
40
45 void resumeTimer(const String& name);
46
52 double getLap(const String& name);
53
59 double stopTimer(const String& name);
60
65 static void wasteTime(double timeInSec);
66
71 void addTimer(const String& name);
72
78 int getTimerIdx(const String& name);
79
80 protected:
81 std::map<String, Timer> m_timers;
82 std::map<String, int> m_counts;
83};
84
85} // namespace utils
86} // namespace BIORBD_NAMESPACE
87
88#endif // BIORBD_UTILS_BENCHMARK_H
void resumeTimer(const String &name)
Resume a timer of a specified name.
Definition Benchmark.cpp:33
Benchmark()
Construct a benchmark analysis.
Definition Benchmark.cpp:9
static void wasteTime(double timeInSec)
To waste time (similar to a sleep function).
Definition Benchmark.cpp:45
std::map< String, Timer > m_timers
Timers.
Definition Benchmark.h:81
std::map< String, int > m_counts
Counts.
Definition Benchmark.h:82
double stopTimer(const String &name)
Stop the timer of a specified name and get lap time.
Definition Benchmark.cpp:25
void addTimer(const String &name)
Add a new timer to the timer set.
Definition Benchmark.cpp:37
double getLap(const String &name)
Get lap time of a specified timer.
Definition Benchmark.cpp:21
int getTimerIdx(const String &name)
Get the index of the specified timer.
Definition Benchmark.cpp:41
void pauseTimer(const String &name)
Pause a timer of a specified name.
Definition Benchmark.cpp:29
void startTimer(const String &name, bool force=false)
Start the timer of a specified name.
Definition Benchmark.cpp:13
Wrapper around the std::string class with augmented functionality.
Definition String.h:18
Wrapper around timer function in C++.
Definition Timer.h:15