Bug 777032. Add support for high resolution profiling on win32. r=ehsan.

The default sleep time on windows is 15.6ms. This is insufficient for our
profiling needs. Use timeBeingPeriod to adjust this when necessary.

--HG--
extra : rebase_source : 0fae6fc052a3eaa94e60e92e68998bf2e6328516
This commit is contained in:
Jeff Muizelaar 2012-07-26 12:02:48 -04:00
parent 01ce4b48b1
commit 2542cf3e29

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <windows.h>
#include <mmsystem.h>
#include "platform.h"
#include <process.h>
@ -63,11 +64,22 @@ class SamplerThread : public Thread {
// Implement Thread::Run().
virtual void Run() {
// By default we'll not adjust the timer resolution which tends to be around
// 16ms. However, if the requested interval is sufficiently low we'll try to
// adjust the resolution to match.
if (interval_ < 10)
::timeBeginPeriod(interval_);
while (sampler_->IsActive()) {
if (!sampler_->IsPaused())
SampleContext(sampler_);
OS::Sleep(interval_);
}
// disable any timer resolution changes we've made
if (interval_ < 10)
::timeEndPeriod(interval_);
}
void SampleContext(Sampler* sampler) {