forked from Pike1z/SETSM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.hpp
51 lines (42 loc) · 1.29 KB
/
log.hpp
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
49
#ifndef LOG_H
#define LOG_H
#include<chrono>
class StopWatch
{
public:
void start() {
if(is_running)
stop();
start_time = std::chrono::high_resolution_clock::now();
is_running = true;
}
void stop() {
auto stop_time = std::chrono::high_resolution_clock::now();
duration = stop_time - start_time;
is_running = false;
}
std::chrono::high_resolution_clock::duration get_elapsed_time() {
return duration;
}
long get_elapsed_seconds() {
return std::chrono::duration_cast<std::chrono::seconds>(duration).count();
}
long get_elapsed_milliseconds() {
return std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
}
long get_elapsed_microseconds() {
return std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
}
private:
std::chrono::high_resolution_clock::time_point start_time;
std::chrono::high_resolution_clock::duration duration;
bool is_running;
};
int init_logging();
void LOG(const char *fmt, ...);
#endif
struct SINGLE_FILE;
SINGLE_FILE *single_fopen(const char *path, const char *mode);
int fclose(SINGLE_FILE *stream);
int fprintf(SINGLE_FILE *stream, const char *format, ...);
int single_printf(const char *fmt, ...);