-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer.h
More file actions
38 lines (27 loc) · 803 Bytes
/
timer.h
File metadata and controls
38 lines (27 loc) · 803 Bytes
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
#ifndef TIMER_H
#define TIMER_H
#include <chrono>
#include <string>
class Timer {
static const std::chrono::duration<double> buffer;
std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
std::chrono::time_point<std::chrono::high_resolution_clock> m_end;
bool running = false;
public:
static int year();
static int month();
static int day();
static int weekday();
static int hour();
static int minute();
static int second();
static int millisecond();
static std::string iso_time();
void start();
void stop();
void reset();
bool isRunning();
double elapsed();
static void sleep(double duration, std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now());
};
#endif