Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1
26#ifndef TESSERACT_COMMON_TIMER_H
27#define TESSERACT_COMMON_TIMER_H
28
31#include <chrono>
33
34namespace tesseract_common
35{
37class Timer
38{
39 using Clock = std::chrono::high_resolution_clock;
40
41public:
43 void start()
44 {
45 start_time_ = Clock::now();
46 running_ = true;
47 }
48
50 void stop()
51 {
52 end_time_ = Clock::now();
53 running_ = false;
54 }
55
61 double elapsedMilliseconds() const
62 {
63 if (running_)
64 return std::chrono::duration<double, std::milli>(Clock::now() - start_time_).count();
65
66 return std::chrono::duration<double, std::milli>(end_time_ - start_time_).count();
67 }
68
74 double elapsedSeconds() const { return (elapsedMilliseconds() / 1000.0); }
75
76private:
77 std::chrono::time_point<Clock> start_time_;
78 std::chrono::time_point<Clock> end_time_;
79 bool running_{ false };
80};
81} // namespace tesseract_common
82#endif // TESSERACT_COMMON_TIMER_H
A simple timer class leveraging chrono high resolution clock.
Definition: timer.h:38
void stop()
Stop the timer.
Definition: timer.h:50
std::chrono::time_point< Clock > end_time_
Definition: timer.h:78
std::chrono::high_resolution_clock Clock
Definition: timer.h:39
double elapsedMilliseconds() const
Get the elapsed time in milliseconds.
Definition: timer.h:61
void start()
Start the timer.
Definition: timer.h:43
std::chrono::time_point< Clock > start_time_
Definition: timer.h:77
double elapsedSeconds() const
Get the elapsed time in seconds.
Definition: timer.h:74
bool running_
Definition: timer.h:79
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: allowed_collision_matrix.h:16