blob: 6fa1f8ea89a8671a9514fe8c027d1755dfb723cc (
plain)
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
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#include "standardpch.h"
#include "logging.h"
#include "simpletimer.h"
SimpleTimer::SimpleTimer()
{
start.QuadPart = 0;
stop.QuadPart = 0;
BOOL retVal = ::QueryPerformanceFrequency(&proc_freq);
if (retVal == FALSE)
{
LogDebug("SimpleTimer::SimpleTimer unable to QPF. error was 0x%08x", ::GetLastError());
::__debugbreak();
}
}
SimpleTimer::~SimpleTimer()
{
}
void SimpleTimer::Start()
{
BOOL retVal = ::QueryPerformanceCounter(&start);
if (retVal == FALSE)
{
LogDebug("SimpleTimer::Start unable to QPC. error was 0x%08x", ::GetLastError());
::__debugbreak();
}
}
void SimpleTimer::Stop()
{
BOOL retVal = ::QueryPerformanceCounter(&stop);
if (retVal == FALSE)
{
LogDebug("SimpleTimer::Stop unable to QPC. error was 0x%08x", ::GetLastError());
::__debugbreak();
}
}
double SimpleTimer::GetMilliseconds()
{
return GetSeconds() * 1000.0;
}
double SimpleTimer::GetSeconds()
{
return ((stop.QuadPart - start.QuadPart) / (double)proc_freq.QuadPart);
}
|