forked from yyk99/icc_junk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.h
41 lines (32 loc) · 834 Bytes
/
timer.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
//
//
//
#ifndef ICC_JUNK_TIMER_H
#define ICC_JUNK_TIMER_H
#include <chrono>
class Timer {
using the_clock = std::chrono::steady_clock;
static std::chrono::time_point<the_clock> now () {
return the_clock::now();
}
std::chrono::time_point<the_clock> _start; // = chrono::high_resolution_clock::now();
std::chrono::time_point<the_clock> _stop; // = chrono::high_resolution_clock::now();
public:
void start() {
_start = now();
}
void stop() {
_stop = now();
}
/// returns elapsed time in seconds
double elapsed() const {
return (double)std::chrono::duration_cast<std::chrono::milliseconds>(_stop - _start).count() / 1000.;
}
};
// Local Variables:
// mode: c++
// c-basic-offset: 4
// tab-width: 4
// indent-tabs-mode: nil
// End:
#endif