blob: 9b60fa199e74922f0c8effef8e029f088ef89c2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <chrono>
class Stopwatch
{
public:
void start()
{
m_start = std::chrono::steady_clock::now();
}
double elapsed_s() const
{
return std::chrono::duration<double>(std::chrono::steady_clock::now() - m_start).count();
}
double elapsed_ms() const
{
return std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - m_start).count();
}
double elapsed_us() const
{
return std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - m_start).count();
}
private:
std::chrono::steady_clock::time_point m_start;
};
|