aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2001-11-15 01:54:12 +0000
committernyamatongwe <devnull@localhost>2001-11-15 01:54:12 +0000
commitbedc366948fe5e3b38d7d058cb53c829406e6ea2 (patch)
tree5b69743d5e1eec0f07667aee70f327373593bda4 /win32
parent9fc0dc5140d4299dbf0aed8aead1d89892aa2c00 (diff)
downloadscintilla-mirror-bedc366948fe5e3b38d7d058cb53c829406e6ea2.tar.gz
Changed to a more typesafe definition of ElapsedTime.
Diffstat (limited to 'win32')
-rw-r--r--win32/PlatWin.cxx39
1 files changed, 23 insertions, 16 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index d227aa7a1..7a1ef5f9c 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -877,38 +877,45 @@ static bool initialisedET = false;
static bool usePerformanceCounter = false;
static LARGE_INTEGER frequency;
-static double Now() {
- if (usePerformanceCounter) {
- LARGE_INTEGER timeVal;
- ::QueryPerformanceCounter(&timeVal);
- return *(reinterpret_cast<double *>(&timeVal));
- } else {
- return clock();
- }
-}
-
ElapsedTime::ElapsedTime() {
if (!initialisedET) {
usePerformanceCounter = ::QueryPerformanceFrequency(&frequency);
initialisedET = true;
}
- beginTime = Now();
+ if (usePerformanceCounter) {
+ LARGE_INTEGER timeVal;
+ ::QueryPerformanceCounter(&timeVal);
+ bigBit = timeVal.HighPart;
+ littleBit = timeVal.LowPart;
+ } else {
+ bigBit = clock();
+ }
}
double ElapsedTime::Duration(bool reset) {
- double endTime = Now();
double result;
+ long endBigBit;
+ long endLittleBit;
+
if (usePerformanceCounter) {
- LARGE_INTEGER lBegin = *(reinterpret_cast<LARGE_INTEGER *>(&beginTime));
- LARGE_INTEGER lEnd = *(reinterpret_cast<LARGE_INTEGER *>(&endTime));
+ LARGE_INTEGER lEnd;
+ ::QueryPerformanceCounter(&lEnd);
+ endBigBit = lEnd.HighPart;
+ endLittleBit = lEnd.LowPart;
+ LARGE_INTEGER lBegin;
+ lBegin.HighPart = bigBit;
+ lBegin.LowPart = littleBit;
double elapsed = lEnd.QuadPart - lBegin.QuadPart;
result = elapsed / static_cast<double>(frequency.QuadPart);
} else {
- double elapsed = endTime - beginTime;
+ endBigBit = clock();
+ endLittleBit = 0;
+ double elapsed = endBigBit - bigBit;
result = elapsed / CLOCKS_PER_SEC;
}
if (reset) {
- beginTime = endTime;
+ bigBit = endBigBit;
+ littleBit = endLittleBit;
}
return result;
}