TTK
Loading...
Searching...
No Matches
Timer.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4
5namespace ttk {
6
7 class Timer {
8 using ClockType = std::chrono::steady_clock;
9 using TimeType = std::chrono::time_point<ClockType>;
10 using DiffType = std::chrono::duration<double>;
11
12 public:
13 Timer() = default;
14
15 inline double getElapsedTime() {
16 const auto end = this->getTimeStamp();
17 const DiffType diff = end - start_;
18 return diff.count();
19 }
20
21 inline void reStart() {
22 start_ = this->getTimeStamp();
23 }
24
25 protected:
26 inline TimeType getTimeStamp() {
27 return ClockType::now();
28 }
29
30 TimeType start_{this->getTimeStamp()};
31 };
32
33} // namespace ttk
TimeType getTimeStamp()
Definition: Timer.h:26
TimeType start_
Definition: Timer.h:30
void reStart()
Definition: Timer.h:21
Timer()=default
double getElapsedTime()
Definition: Timer.h:15
The Topology ToolKit.