| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Windows Timer Primer | 6 // Windows Timer Primer |
| 7 // | 7 // |
| 8 // A good article: http://www.ddj.com/windows/184416651 | 8 // A good article: http://www.ddj.com/windows/184416651 |
| 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 | 9 // A good mozilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=363258 |
| 10 // | 10 // |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 QueryPerformanceCounter(&now); | 421 QueryPerformanceCounter(&now); |
| 422 return QPCValueToTimeDelta(now.QuadPart); | 422 return QPCValueToTimeDelta(now.QuadPart); |
| 423 } | 423 } |
| 424 | 424 |
| 425 bool IsBuggyAthlon(const base::CPU& cpu) { | 425 bool IsBuggyAthlon(const base::CPU& cpu) { |
| 426 // On Athlon X2 CPUs (e.g. model 15) QueryPerformanceCounter is unreliable. | 426 // On Athlon X2 CPUs (e.g. model 15) QueryPerformanceCounter is unreliable. |
| 427 return cpu.vendor_name() == "AuthenticAMD" && cpu.family() == 15; | 427 return cpu.vendor_name() == "AuthenticAMD" && cpu.family() == 15; |
| 428 } | 428 } |
| 429 | 429 |
| 430 void InitializeNowFunctionPointers() { | 430 void InitializeNowFunctionPointers() { |
| 431 LARGE_INTEGER ticks_per_sec = {0}; | 431 LARGE_INTEGER ticks_per_sec = {}; |
| 432 if (!QueryPerformanceFrequency(&ticks_per_sec)) | 432 if (!QueryPerformanceFrequency(&ticks_per_sec)) |
| 433 ticks_per_sec.QuadPart = 0; | 433 ticks_per_sec.QuadPart = 0; |
| 434 | 434 |
| 435 // If Windows cannot provide a QPC implementation, both TimeTicks::Now() and | 435 // If Windows cannot provide a QPC implementation, both TimeTicks::Now() and |
| 436 // TraceTicks::Now() must use the low-resolution clock. | 436 // TraceTicks::Now() must use the low-resolution clock. |
| 437 // | 437 // |
| 438 // If the QPC implementation is expensive and/or unreliable, TimeTicks::Now() | 438 // If the QPC implementation is expensive and/or unreliable, TimeTicks::Now() |
| 439 // will use the low-resolution clock, but TraceTicks::Now() will use the QPC | 439 // will use the low-resolution clock, but TraceTicks::Now() will use the QPC |
| 440 // (in the hope that it is still useful for tracing purposes). A CPU lacking a | 440 // (in the hope that it is still useful for tracing purposes). A CPU lacking a |
| 441 // non-stop time counter will cause Windows to provide an alternate QPC | 441 // non-stop time counter will cause Windows to provide an alternate QPC |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { | 521 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { |
| 522 return TimeTicks() + QPCValueToTimeDelta(qpc_value); | 522 return TimeTicks() + QPCValueToTimeDelta(qpc_value); |
| 523 } | 523 } |
| 524 | 524 |
| 525 // TimeDelta ------------------------------------------------------------------ | 525 // TimeDelta ------------------------------------------------------------------ |
| 526 | 526 |
| 527 // static | 527 // static |
| 528 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 528 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
| 529 return QPCValueToTimeDelta(qpc_value); | 529 return QPCValueToTimeDelta(qpc_value); |
| 530 } | 530 } |
| OLD | NEW |