Chromium Code Reviews| Index: src/platform-win32.cc |
| diff --git a/src/platform-win32.cc b/src/platform-win32.cc |
| index 49463be8e00fbf8ab022e71ba8af5fccaf0f2f09..7fa87f838b97b8001bcf4deeccaab9ffad3a0133 100644 |
| --- a/src/platform-win32.cc |
| +++ b/src/platform-win32.cc |
| @@ -591,8 +591,16 @@ double OS::TimeCurrentMillis() { |
| return t.ToJSTime(); |
| } |
| -// Returns the tickcounter based on timeGetTime. |
| + |
| +static LARGE_INTEGER frequency = 0; |
| + |
| + |
| +// Returns the tickcounter based on QueryPerformanceCounter or timeGetTime. |
| int64_t OS::Ticks() { |
| + static LARGE_INTEGER tick; |
| + if (frequency != 0 && QueryPerformanceCounter(&tick)) { |
| + return static_cast<int64_t>(tick.QuadPart * 1000000.0 / frequency->QuadPart); |
|
Jakob Kummerow
2012/09/04 11:31:36
long line
|
| + } |
| return timeGetTime() * 1000; // Convert to microseconds. |
| } |
| @@ -2087,12 +2095,15 @@ void OS::SetUp() { |
| // call this setup code within the same millisecond. |
| uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
| srand(static_cast<unsigned int>(seed)); |
| + // Get the number of ticks per second that is used in OS::Ticks() |
| + QueryPerformanceFrequency(&frequency); |
| limit_mutex = CreateMutex(); |
| SamplerThread::SetUp(); |
| } |
| void OS::TearDown() { |
| + frequency = 0; |
| SamplerThread::TearDown(); |
| delete limit_mutex; |
| } |