-
Notifications
You must be signed in to change notification settings - Fork 9
/
Lapse.h
48 lines (29 loc) · 658 Bytes
/
Lapse.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <chrono>
#include "./CLog.h"
class Lapse final {
public:
~Lapse() noexcept;
Lapse(const char* p, std::size_t s);
private:
static double Now() noexcept;
private:
double mLapse;
const char* mp;
std::size_t ms;
};
Lapse::~Lapse() noexcept
{
clog(mp, ms, Now() - mLapse);
}
Lapse::Lapse(const char* p, std::size_t s)
:mLapse(Now())
,mp(p)
,ms(s)
{
}
double Lapse::Now() noexcept
{
using namespace std::chrono;
return static_cast<double>(duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count()) / 1000000000;
}