-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.cpp
More file actions
30 lines (25 loc) · 697 Bytes
/
Timer.cpp
File metadata and controls
30 lines (25 loc) · 697 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
#include "Timer.h"
namespace ST
{
//--------- Init of internal variables ---------//
Timer::Timer() : start(0)
{
LARGE_INTEGER freq;
::QueryPerformanceFrequency(&freq);
frequency = freq.QuadPart;
}
//--------- Init timer ---------//
void Timer::Reset()
{
LARGE_INTEGER tempStart;
::QueryPerformanceCounter(&tempStart);
start = tempStart.QuadPart;
}
//--------- Returns elapsed time in seconds ---------//
double Timer::ElapsedTime() const
{
LARGE_INTEGER currentTime;
::QueryPerformanceCounter(¤tTime);
return (double)(currentTime.QuadPart - start) / frequency;
}
}