Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b39494a

Browse files
committed
Add now() to Timer class and switch to steady clock
Problem: * Timer has no interface to return epoch time * high_resolution_clock is aliased to system_clock on ubuntu Solution * Add a now() interface to Timer class * Switch to steady clock
1 parent 68b977c commit b39494a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

include/RobotUtilities/TimerLinux.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66

77
namespace RUT {
88

9-
typedef std::chrono::high_resolution_clock Clock;
9+
typedef std::chrono::steady_clock Clock;
1010
typedef Clock::time_point TimePoint;
1111

1212
class Timer {
1313
public:
1414
Timer();
1515
~Timer();
1616

17-
// time measurement functions
17+
// return epoch time
18+
TimePoint now();
19+
20+
// duration measurement
1821
void tic();
1922
double toc_ms(); // return ms
2023

src/TimerLinux.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Timer::Timer() {
1313

1414
Timer::~Timer() {}
1515

16+
TimePoint Timer::now() { return Clock::now(); }
17+
1618
void Timer::tic() { _t1 = Clock::now(); }
1719

1820
double Timer::toc_ms() {

0 commit comments

Comments
 (0)