-
Notifications
You must be signed in to change notification settings - Fork 14
/
timer.h
48 lines (39 loc) · 844 Bytes
/
timer.h
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
#pragma once
namespace QPC_Timer
{
typedef LONGLONG Tick;
extern Tick frequency;
extern Tick overhead;
extern double ticksToNanosecs;
void Initialize();
inline Tick Sample()
{
LARGE_INTEGER t;
QueryPerformanceCounter(&t);
return t.QuadPart;
}
}
#if INTEGER_MAP_TIMING_METHOD(RDTSC)
namespace RDTSC_Timer
{
typedef __int64 Tick;
extern Tick frequency;
extern Tick overhead;
extern double ticksToNanosecs;
void Initialize();
inline Tick Sample()
{
__asm
{
mov eax, 0
cpuid
}
return __rdtsc();
}
}
#endif // INTEGER_MAP_TIMING_METHOD(RDTSC)
#if INTEGER_MAP_TIMING_METHOD(QUERY_PERFORMANCE_COUNTER)
#define Timer QPC_Timer
#elif INTEGER_MAP_TIMING_METHOD(RDTSC)
#define Timer RDTSC_Timer
#endif