-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTimer.cpp
37 lines (30 loc) · 786 Bytes
/
Timer.cpp
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
#include "pch.h"
#include "Timer.h"
void Timer::start()
{
m_StartTime = std::chrono::system_clock::now();
m_bRunning = true;
}
void Timer::stop()
{
// m_EndTime = std::chrono::system_clock::now();
m_bRunning = false;
}
double Timer::elapsedMilliseconds()
{
std::chrono::time_point<std::chrono::system_clock> endTime;
if (m_bRunning)
{
endTime = std::chrono::system_clock::now();
}
else
{
return 0;
// endTime = m_EndTime;
}
return std::chrono::duration_cast<std::chrono::milliseconds>(endTime - m_StartTime).count();
}
double Timer::elapsedSeconds()
{
return elapsedMilliseconds() / 1000.0;
}