From 2555c77a816d66498204d68c80d2c1c5eb47bc6e Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 15 Feb 2005 19:50:27 +0000 Subject: [PATCH] Committed currently disabled code that implements the wxStopWatch based on QueryPerformanceCounter() I'll do more testing if I can, but here is the code for other to look at. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/stopwatch.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/common/stopwatch.cpp b/src/common/stopwatch.cpp index cb1c69a17a..901693c3e0 100644 --- a/src/common/stopwatch.cpp +++ b/src/common/stopwatch.cpp @@ -110,14 +110,48 @@ void wxStopWatch::Start(long t) { +#ifdef 0 +__WXMSW__ + LARGE_INTEGER frequency_li; + ::QueryPerformanceFrequency( &frequency_li ); + m_frequency = frequency_li.QuadPart; + if (m_frequency == 0) + { + m_t0 = wxGetLocalTimeMillis() - t; + } + else + { + LARGE_INTEGER counter_li; + ::QueryPerformanceCounter( &counter_li ); + wxLongLong counter = counter_li.QuadPart; + m_t0 = (counter * 10000 / m_frequency) - t*10; + } +#else m_t0 = wxGetLocalTimeMillis() - t; +#endif m_pause = 0; m_pauseCount = 0; } long wxStopWatch::GetElapsedTime() const { +#ifdef 0 +__WXMSW__ + if (m_frequency == 0) + { + return (wxGetLocalTimeMillis() - m_t0).GetLo(); + } + else + { + LARGE_INTEGER counter_li; + ::QueryPerformanceCounter( &counter_li ); + wxLongLong counter = counter_li.QuadPart; + wxLongLong res = (counter * 10000 / m_frequency) - m_t0; + return res.GetLo() / 10; + } +#else return (wxGetLocalTimeMillis() - m_t0).GetLo(); +#endif } long wxStopWatch::Time() const -- 2.45.2