Added wxStopWatch::TimeInMicro() for better precision time measurement.

Also simplify/streamline wxStopWatch implementation and replace confusingly
named m_pause with more clear m_elapsedBeforePause.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69835 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-11-27 19:50:12 +00:00
parent 54647bb750
commit b0ec002323
5 changed files with 107 additions and 41 deletions

View File

@@ -55,13 +55,22 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StopWatchTestCase, "StopWatchTestCase" );
void StopWatchTestCase::Misc()
{
static const long tolerance = 100; // in ms
static const long tolerance = 10; // in ms
wxStopWatch sw;
long t;
wxLongLong usec;
sw.Pause(); // pause it immediately
// verify that almost no time elapsed
usec = sw.TimeInMicro();
WX_ASSERT_MESSAGE
(
("Elapsed time was %" wxLongLongFmtSpec "dus", usec),
usec < tolerance*1000
);
wxSleep(1);
t = sw.Time();