forked from somma/_MyLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStopWatch.h
More file actions
43 lines (39 loc) · 1.24 KB
/
StopWatch.h
File metadata and controls
43 lines (39 loc) · 1.24 KB
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
/**----------------------------------------------------------------------------
* StopWatch.h
*-----------------------------------------------------------------------------
*
*-----------------------------------------------------------------------------
* All rights reserved by somma (fixbrain@gmail.com, unsorted@msn.com)
*-----------------------------------------------------------------------------
* 26:12:2011 17:53 created
* - OpenMP º´·Ä ÇÁ·Î±×·¡¹Ö by Á¤¿µÈÆ (CStopWatch class)
**---------------------------------------------------------------------------*/
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class StopWatch
{
private:
LARGE_INTEGER mFreq, mStart, mEnd;
float mTimeforDuration;
public :
StopWatch() : mTimeforDuration(0)
{
mFreq.LowPart = mFreq.HighPart = 0;
mStart = mFreq;
mEnd = mFreq;
QueryPerformanceFrequency(&mFreq);
}
~StopWatch()
{
}
public:
void Start(){ QueryPerformanceCounter(&mStart); }
void Stop()
{
QueryPerformanceCounter(&mEnd);
mTimeforDuration=(mEnd.QuadPart - mStart.QuadPart)/(float)mFreq.QuadPart;
}
float GetDurationSecond() { return mTimeforDuration; }
float GetDurationMilliSecond() { return mTimeforDuration * 1000.f; }
};