blob: dc15a727f0eeb764fab712497f95beec521e1593 (
plain) (
blame)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
//+------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1993.
//
// File: stopwtch.cxx
//
// Contents: StopWatch timer
//
// Classes: CStopWatch
//
// Functions:
//
// History: 30-June-93 t-martig Created
//
//--------------------------------------------------------------------------
extern "C"
{
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
};
#include <windows.h>
#include <stopwtch.hxx>
//+-------------------------------------------------------------------
//
// Member: CStopWatch::Resolution, public
//
// Synopsis: Inquires performance timer resolution
//
// Returns: Performance counter ticks / second
//
// History: 30-June-93 t-martig Created
//
//--------------------------------------------------------------------
CStopWatch::CStopWatch ()
{
QueryPerformanceFrequency (&liFreq);
}
//+-------------------------------------------------------------------
//
// Member: CStopWatch::Reset, public
//
// Synopsis: Starts measurement cycle
//
// History: 30-June-93 t-martig Created
//
//--------------------------------------------------------------------
void CStopWatch::Reset ()
{
QueryPerformanceCounter (&liStart); // BUGBUG - test for error !
}
//+-------------------------------------------------------------------
//
// Member: CStopWatch::Read, public
//
// Synopsis: Reads stop watch timer
//
// Returns: Time since call of CStopWatch::Reset (in microseconds)
//
// History: 30-June-93 t-martig Created
//
//--------------------------------------------------------------------
ULONG CStopWatch::Read ()
{
LARGE_INTEGER liNow, liDelta, liRemainder;
QueryPerformanceCounter (&liNow); // BUGBUG - test for error
liDelta = RtlLargeIntegerSubtract (liNow, liStart);
liDelta = RtlExtendedIntegerMultiply (liDelta, 1000000);
liDelta = RtlLargeIntegerDivide (liDelta, liFreq, &liRemainder);
return liDelta.LowPart;
}
//+-------------------------------------------------------------------
//
// Member: CStopWatch::Resolution, public
//
// Synopsis: Inquires performance timer resolution
//
// Returns: Performance counter ticks / second
//
// History: 30-June-93 t-martig Created
//
//--------------------------------------------------------------------
ULONG CStopWatch::Resolution ()
{
return liFreq.LowPart;
}
|