-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntimeMonitor.cpp
More file actions
58 lines (55 loc) · 1.71 KB
/
RuntimeMonitor.cpp
File metadata and controls
58 lines (55 loc) · 1.71 KB
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
50
51
52
53
54
55
56
57
//
// RuntimeMonitor.cpp
// minicpp
//
// Created by zitoun on 12/17/19.
// Copyright © 2019 Waldy. All rights reserved.
//
#include "RuntimeMonitor.hpp"
namespace RuntimeMonitor {
HRClock cputime()
{
return std::chrono::high_resolution_clock::now();
}
std::chrono::time_point<std::chrono::system_clock> wctime()
{
return std::chrono::system_clock::now();
}
HRClock now()
{
return std::chrono::high_resolution_clock::now();
}
double elapsedSince(HRClock then)
{
auto now = std::chrono::high_resolution_clock::now();
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(now - then);
return diff.count();
}
long milli(HRClock s,HRClock e)
{
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(e - s);
return diff.count();
}
double elapsedSeconds(HRClock start, HRClock end)
{
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
return static_cast<double>(diff.count()) / 1000.0;
}
double elapsedSeconds(HRClock start)
{
auto now = std::chrono::high_resolution_clock::now();
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
return static_cast<double>(diff.count()) / 1000.0;
}
double elapsedMilliseconds(HRClock start, HRClock end)
{
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
return static_cast<double>(diff.count());
}
unsigned long elapsedSinceMicro(HRClock then)
{
auto now = std::chrono::high_resolution_clock::now();
auto diff = std::chrono::duration_cast<std::chrono::microseconds>(now - then);
return diff.count();
}
}