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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 | 506 |
507 // static | 507 // static |
508 bool TimeTicks::IsHighResolution() { | 508 bool TimeTicks::IsHighResolution() { |
509 if (g_now_function == &InitialNowFunction) | 509 if (g_now_function == &InitialNowFunction) |
510 InitializeNowFunctionPointer(); | 510 InitializeNowFunctionPointer(); |
511 return g_now_function == &QPCNow; | 511 return g_now_function == &QPCNow; |
512 } | 512 } |
513 | 513 |
514 // static | 514 // static |
| 515 TimeTicks::Clock TimeTicks::GetClock() { |
| 516 return IsHighResolution() ? |
| 517 Clock::WIN_QPC : Clock::WIN_ROLLOVER_PROTECTED_TIME_GET_TIME; |
| 518 } |
| 519 |
| 520 // static |
515 ThreadTicks ThreadTicks::Now() { | 521 ThreadTicks ThreadTicks::Now() { |
516 DCHECK(IsSupported()); | 522 DCHECK(IsSupported()); |
517 | 523 |
518 // Get the number of TSC ticks used by the current thread. | 524 // Get the number of TSC ticks used by the current thread. |
519 ULONG64 thread_cycle_time = 0; | 525 ULONG64 thread_cycle_time = 0; |
520 GetQueryThreadCycleTimeFunction()(::GetCurrentThread(), &thread_cycle_time); | 526 GetQueryThreadCycleTimeFunction()(::GetCurrentThread(), &thread_cycle_time); |
521 | 527 |
522 // Get the frequency of the TSC. | 528 // Get the frequency of the TSC. |
523 double tsc_ticks_per_second = TSCTicksPerSecond(); | 529 double tsc_ticks_per_second = TSCTicksPerSecond(); |
524 if (tsc_ticks_per_second == 0) | 530 if (tsc_ticks_per_second == 0) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { | 613 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { |
608 return TimeTicks() + QPCValueToTimeDelta(qpc_value); | 614 return TimeTicks() + QPCValueToTimeDelta(qpc_value); |
609 } | 615 } |
610 | 616 |
611 // TimeDelta ------------------------------------------------------------------ | 617 // TimeDelta ------------------------------------------------------------------ |
612 | 618 |
613 // static | 619 // static |
614 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { | 620 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { |
615 return QPCValueToTimeDelta(qpc_value); | 621 return QPCValueToTimeDelta(qpc_value); |
616 } | 622 } |
OLD | NEW |