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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 } | 497 } |
498 | 498 |
499 // static | 499 // static |
500 bool TimeTicks::IsHighResolution() { | 500 bool TimeTicks::IsHighResolution() { |
501 if (g_now_function == &InitialNowFunction) | 501 if (g_now_function == &InitialNowFunction) |
502 InitializeNowFunctionPointer(); | 502 InitializeNowFunctionPointer(); |
503 return g_now_function == &QPCNow; | 503 return g_now_function == &QPCNow; |
504 } | 504 } |
505 | 505 |
506 // static | 506 // static |
| 507 bool TimeTicks::IsConsistentAcrossProcesses() { |
| 508 // According to Windows documentation [1] QPC is consistent post-Windows |
| 509 // Vista. So if we are using QPC then we are consistent which is the same as |
| 510 // being high resolution. |
| 511 // |
| 512 // [1] https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.
85).aspx |
| 513 // |
| 514 // "In general, the performance counter results are consistent across all |
| 515 // processors in multi-core and multi-processor systems, even when measured on |
| 516 // different threads or processes. Here are some exceptions to this rule: |
| 517 // - Pre-Windows Vista operating systems that run on certain processors might |
| 518 // violate this consistency because of one of these reasons: |
| 519 // 1. The hardware processors have a non-invariant TSC and the BIOS |
| 520 // doesn't indicate this condition correctly. |
| 521 // 2. The TSC synchronization algorithm that was used wasn't suitable for |
| 522 // systems with large numbers of processors." |
| 523 return IsHighResolution(); |
| 524 } |
| 525 |
| 526 // static |
507 TimeTicks::Clock TimeTicks::GetClock() { | 527 TimeTicks::Clock TimeTicks::GetClock() { |
508 return IsHighResolution() ? | 528 return IsHighResolution() ? |
509 Clock::WIN_QPC : Clock::WIN_ROLLOVER_PROTECTED_TIME_GET_TIME; | 529 Clock::WIN_QPC : Clock::WIN_ROLLOVER_PROTECTED_TIME_GET_TIME; |
510 } | 530 } |
511 | 531 |
512 // static | 532 // static |
513 ThreadTicks ThreadTicks::Now() { | 533 ThreadTicks ThreadTicks::Now() { |
514 return ThreadTicks::GetForThread(PlatformThread::CurrentHandle()); | 534 return ThreadTicks::GetForThread(PlatformThread::CurrentHandle()); |
515 } | 535 } |
516 | 536 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { | 630 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { |
611 return TimeTicks() + QPCValueToTimeDelta(qpc_value); | 631 return TimeTicks() + QPCValueToTimeDelta(qpc_value); |
612 } | 632 } |
613 | 633 |
614 // TimeDelta ------------------------------------------------------------------ | 634 // TimeDelta ------------------------------------------------------------------ |
615 | 635 |
616 // static | 636 // static |
617 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 637 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
618 return QPCValueToTimeDelta(qpc_value); | 638 return QPCValueToTimeDelta(qpc_value); |
619 } | 639 } |
OLD | NEW |