Dura2D
v0.1.0
An educational 2D game physics library
Loading...
Searching...
No Matches
d2Timer.h
Go to the documentation of this file.
1
#ifndef D2TIMER_H
2
#define D2TIMER_H
3
4
#include <chrono>
5
#include <iostream>
6
7
class
d2Timer
8
{
9
public
:
10
d2Timer
()
11
{
12
start
();
13
}
14
15
~d2Timer
()
16
{
17
stop
();
18
std::cout <<
"Duration: "
<<
getDuration
() <<
" ns"
<< std::endl;
19
}
20
21
void
start
()
22
{
23
m_start = std::chrono::high_resolution_clock::now();
24
}
25
26
void
stop
()
27
{
28
auto
end = std::chrono::high_resolution_clock::now();
29
m_duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - m_start);
30
}
31
32
[[nodiscard]]
33
long
long
getDuration
()
const
34
{
35
return
m_duration.count();
36
}
37
38
private
:
39
std::chrono::high_resolution_clock::time_point m_start { };
40
std::chrono::nanoseconds m_duration { 0 };
41
};
42
43
#endif
//D2TIMER_H
d2Timer
Definition
d2Timer.h:8
d2Timer::start
void start()
Definition
d2Timer.h:21
d2Timer::~d2Timer
~d2Timer()
Definition
d2Timer.h:15
d2Timer::getDuration
long long getDuration() const
Definition
d2Timer.h:33
d2Timer::stop
void stop()
Definition
d2Timer.h:26
d2Timer::d2Timer
d2Timer()
Definition
d2Timer.h:10
dura2d
d2Timer.h
Generated by
1.12.0