projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix wxEncodingConverter::Convert(wchar_t) documentation.
[wxWidgets.git]
/
src
/
common
/
stopwatch.cpp
diff --git
a/src/common/stopwatch.cpp
b/src/common/stopwatch.cpp
index b0e6ddde4085cdb0fec25f6363485044e9735baf..f36696dff0b9ce5053dfa785446d1109c0db4903 100644
(file)
--- a/
src/common/stopwatch.cpp
+++ b/
src/common/stopwatch.cpp
@@
-37,6
+37,7
@@
#include "wx/msw/wrapwin.h"
#endif
#include "wx/log.h"
#include "wx/msw/wrapwin.h"
#endif
#include "wx/log.h"
+ #include "wx/thread.h"
#endif //WX_PRECOMP
// ============================================================================
#endif //WX_PRECOMP
// ============================================================================
@@
-64,7
+65,7
@@
struct PerfCounter
return freq.QuadPart != 0;
}
return freq.QuadPart != 0;
}
- wxC
riticalSection cs
;
+ wxC
RIT_SECT_DECLARE_MEMBER(cs)
;
LARGE_INTEGER freq;
bool init;
} gs_perfCounter;
LARGE_INTEGER freq;
bool init;
} gs_perfCounter;
@@
-82,7
+83,7
@@
void wxStopWatch::DoStart()
#ifdef __WXMSW__
if ( !gs_perfCounter.init )
{
#ifdef __WXMSW__
if ( !gs_perfCounter.init )
{
- wxC
riticalSectionLocker lock(
gs_perfCounter.cs);
+ wxC
RIT_SECT_LOCKER(lock,
gs_perfCounter.cs);
::QueryPerformanceFrequency(&gs_perfCounter.freq);
// Just a sanity check: it's not supposed to happen but verify that
::QueryPerformanceFrequency(&gs_perfCounter.freq);
// Just a sanity check: it's not supposed to happen but verify that
@@
-112,12
+113,23
@@
wxLongLong wxStopWatch::GetClockFreq() const
return gs_perfCounter.freq.QuadPart;
#endif // __WXMSW__
return gs_perfCounter.freq.QuadPart;
#endif // __WXMSW__
+#ifdef HAVE_GETTIMEOFDAY
+ // With gettimeofday() we can have nominally microsecond precision and
+ // while this is not the case in practice, it's still better than
+ // millisecond.
+ return MICROSECONDS_PER_SECOND;
+#else // !HAVE_GETTIMEOFDAY
// Currently milliseconds are used everywhere else.
return MILLISECONDS_PER_SECOND;
// Currently milliseconds are used everywhere else.
return MILLISECONDS_PER_SECOND;
+#endif // HAVE_GETTIMEOFDAY/!HAVE_GETTIMEOFDAY
}
void wxStopWatch::Start(long t0)
{
}
void wxStopWatch::Start(long t0)
{
+ // Calling Start() makes the stop watch run however many times it was
+ // paused before.
+ m_pauseCount = 0;
+
DoStart();
m_t0 -= (wxLongLong(t0)*GetClockFreq())/MILLISECONDS_PER_SECOND;
DoStart();
m_t0 -= (wxLongLong(t0)*GetClockFreq())/MILLISECONDS_PER_SECOND;
@@
-134,7
+146,11
@@
wxLongLong wxStopWatch::GetCurrentClockValue() const
}
#endif // __WXMSW__
}
#endif // __WXMSW__
+#ifdef HAVE_GETTIMEOFDAY
+ return wxGetUTCTimeUSec();
+#else // !HAVE_GETTIMEOFDAY
return wxGetUTCTimeMillis();
return wxGetUTCTimeMillis();
+#endif // HAVE_GETTIMEOFDAY/!HAVE_GETTIMEOFDAY
}
wxLongLong wxStopWatch::TimeInMicro() const
}
wxLongLong wxStopWatch::TimeInMicro() const