Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
49 lines (40 loc) · 1.14 KB

File metadata and controls

49 lines (40 loc) · 1.14 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#include "TimeHelpers.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
namespace UnitTest {
Timer::Timer()
: m_threadHandle(::GetCurrentThread())
, m_startTime(0)
{
#if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR
typedef unsigned long DWORD_PTR;
#endif
DWORD_PTR systemMask;
::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask);
::SetThreadAffinityMask(m_threadHandle, 1);
::QueryPerformanceFrequency(reinterpret_cast< LARGE_INTEGER* >(&m_frequency));
::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
}
void Timer::Start()
{
m_startTime = GetTime();
}
double Timer::GetTimeInMs() const
{
__int64 const elapsedTime = GetTime() - m_startTime;
double const seconds = double(elapsedTime) / double(m_frequency);
return seconds * 1000.0;
}
__int64 Timer::GetTime() const
{
LARGE_INTEGER curTime;
::SetThreadAffinityMask(m_threadHandle, 1);
::QueryPerformanceCounter(&curTime);
::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
return curTime.QuadPart;
}
void TimeHelpers::SleepMs(int ms)
{
::Sleep(ms);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.