]> git.saurik.com Git - wxWidgets.git/commitdiff
Committed currently disabled code that implements
authorRobert Roebling <robert@roebling.de>
Tue, 15 Feb 2005 19:50:27 +0000 (19:50 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 15 Feb 2005 19:50:27 +0000 (19:50 +0000)
   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

index cb1c69a17a78a09d67a102caa36492866ed394ee..901693c3e029ce61d1dd6b8a22d436f171e10c6c 100644 (file)
 
 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