forked from NTDLS/NSWFL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNSWFL_HighPrecisionTimer.h
43 lines (36 loc) · 1.93 KB
/
NSWFL_HighPrecisionTimer.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
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright © NetworkDLS 2023, All rights reserved
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _NSWFL_HIGHPRECISIONTIMER_H_
#define _NSWFL_HIGHPRECISIONTIMER_H_
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace NSWFL {
namespace DateTime {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class HighPrecisionTimer
{
protected:
LARGE_INTEGER _liStart;
LARGE_INTEGER _liStop;
LARGE_INTEGER _liFrequency;
bool _bIsHighPrecision;
public:
HighPrecisionTimer(void);
bool IsHighPrecision(void); //Returns true if the timer is highly precise.
void Start(void); //Starts the timer.
void Stop(void); //Stops the timer.
double Calculate(void); //Calculates the difference between timer Start() and Stop() events in milliseconds.
double Delta(void); //Returns the difference between timer Start() and now in milliseconds.
__int64 Frequency(void); // Timer frequency (for the current CPU executing the current thread).
__int64 TickCount(void); // Gets the tickcount for manual duration calculations.
double Calculate(__int64 i64StartTime, __int64 i64StopTime); //Calculates the difference between given times (tickcounts) in milliseconds.
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} //namespace::DateTime
} //namespace::NSWFL
#endif