diff options
author | nyamatongwe <unknown> | 2001-11-15 00:50:13 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-11-15 00:50:13 +0000 |
commit | 1f1556998546e7cfe3b38fab00a70a948c35bcc0 (patch) | |
tree | 8f88795c5f750290092a67a5b8a7760632e1db2c /win32/PlatWin.cxx | |
parent | aa63b1842ce03c992bd695c4dd7d3d940bf47f64 (diff) | |
download | scintilla-mirror-1f1556998546e7cfe3b38fab00a70a948c35bcc0.tar.gz |
Added ElapsedTime.
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r-- | win32/PlatWin.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 666c962cf..d227aa7a1 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -10,6 +10,7 @@ #include <ctype.h> #include <stdarg.h> #include <stdio.h> +#include <time.h> #define _WIN32_WINNT 0x0400 #include <windows.h> @@ -872,6 +873,46 @@ void Menu::Show(Point pt, Window &w) { Destroy(); } +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(); +} + +double ElapsedTime::Duration(bool reset) { + double endTime = Now(); + double result; + if (usePerformanceCounter) { + LARGE_INTEGER lBegin = *(reinterpret_cast<LARGE_INTEGER *>(&beginTime)); + LARGE_INTEGER lEnd = *(reinterpret_cast<LARGE_INTEGER *>(&endTime)); + double elapsed = lEnd.QuadPart - lBegin.QuadPart; + result = elapsed / static_cast<double>(frequency.QuadPart); + } else { + double elapsed = endTime - beginTime; + result = elapsed / CLOCKS_PER_SEC; + } + if (reset) { + beginTime = endTime; + } + return result; +} + ColourDesired Platform::Chrome() { return ::GetSysColor(COLOR_3DFACE); } |