Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: base/time/time_win.cc

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/time/time_unittest.cc ('k') | base/time/time_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 20 matching lines...) Expand all
31 // will only increase the system-wide timer if we're not running on battery 31 // will only increase the system-wide timer if we're not running on battery
32 // power. 32 // power.
33 33
34 #include "base/time/time.h" 34 #include "base/time/time.h"
35 35
36 #pragma comment(lib, "winmm.lib") 36 #pragma comment(lib, "winmm.lib")
37 #include <windows.h> 37 #include <windows.h>
38 #include <mmsystem.h> 38 #include <mmsystem.h>
39 #include <stdint.h> 39 #include <stdint.h>
40 40
41 #include "base/basictypes.h"
42 #include "base/cpu.h" 41 #include "base/cpu.h"
43 #include "base/lazy_instance.h" 42 #include "base/lazy_instance.h"
44 #include "base/logging.h" 43 #include "base/logging.h"
45 #include "base/synchronization/lock.h" 44 #include "base/synchronization/lock.h"
46 45
47 using base::ThreadTicks; 46 using base::ThreadTicks;
48 using base::Time; 47 using base::Time;
49 using base::TimeDelta; 48 using base::TimeDelta;
50 using base::TimeTicks; 49 using base::TimeTicks;
51 50
52 namespace { 51 namespace {
53 52
54 // From MSDN, FILETIME "Contains a 64-bit value representing the number of 53 // From MSDN, FILETIME "Contains a 64-bit value representing the number of
55 // 100-nanosecond intervals since January 1, 1601 (UTC)." 54 // 100-nanosecond intervals since January 1, 1601 (UTC)."
56 int64 FileTimeToMicroseconds(const FILETIME& ft) { 55 int64_t FileTimeToMicroseconds(const FILETIME& ft) {
57 // Need to bit_cast to fix alignment, then divide by 10 to convert 56 // Need to bit_cast to fix alignment, then divide by 10 to convert
58 // 100-nanoseconds to microseconds. This only works on little-endian 57 // 100-nanoseconds to microseconds. This only works on little-endian
59 // machines. 58 // machines.
60 return bit_cast<int64, FILETIME>(ft) / 10; 59 return bit_cast<int64_t, FILETIME>(ft) / 10;
61 } 60 }
62 61
63 void MicrosecondsToFileTime(int64 us, FILETIME* ft) { 62 void MicrosecondsToFileTime(int64_t us, FILETIME* ft) {
64 DCHECK_GE(us, 0LL) << "Time is less than 0, negative values are not " 63 DCHECK_GE(us, 0LL) << "Time is less than 0, negative values are not "
65 "representable in FILETIME"; 64 "representable in FILETIME";
66 65
67 // Multiply by 10 to convert microseconds to 100-nanoseconds. Bit_cast will 66 // Multiply by 10 to convert microseconds to 100-nanoseconds. Bit_cast will
68 // handle alignment problems. This only works on little-endian machines. 67 // handle alignment problems. This only works on little-endian machines.
69 *ft = bit_cast<FILETIME, int64>(us * 10); 68 *ft = bit_cast<FILETIME, int64_t>(us * 10);
70 } 69 }
71 70
72 int64 CurrentWallclockMicroseconds() { 71 int64_t CurrentWallclockMicroseconds() {
73 FILETIME ft; 72 FILETIME ft;
74 ::GetSystemTimeAsFileTime(&ft); 73 ::GetSystemTimeAsFileTime(&ft);
75 return FileTimeToMicroseconds(ft); 74 return FileTimeToMicroseconds(ft);
76 } 75 }
77 76
78 // Time between resampling the un-granular clock for this API. 60 seconds. 77 // Time between resampling the un-granular clock for this API. 60 seconds.
79 const int kMaxMillisecondsToAvoidDrift = 60 * Time::kMillisecondsPerSecond; 78 const int kMaxMillisecondsToAvoidDrift = 60 * Time::kMillisecondsPerSecond;
80 79
81 int64 initial_time = 0; 80 int64_t initial_time = 0;
82 TimeTicks initial_ticks; 81 TimeTicks initial_ticks;
83 82
84 void InitializeClock() { 83 void InitializeClock() {
85 initial_ticks = TimeTicks::Now(); 84 initial_ticks = TimeTicks::Now();
86 initial_time = CurrentWallclockMicroseconds(); 85 initial_time = CurrentWallclockMicroseconds();
87 } 86 }
88 87
89 // The two values that ActivateHighResolutionTimer uses to set the systemwide 88 // The two values that ActivateHighResolutionTimer uses to set the systemwide
90 // timer interrupt frequency on Windows. It controls how precise timers are 89 // timer interrupt frequency on Windows. It controls how precise timers are
91 // but also has a big impact on battery life. 90 // but also has a big impact on battery life.
(...skipping 11 matching lines...) Expand all
103 // Can't statically link to it because it is not available on XP. 102 // Can't statically link to it because it is not available on XP.
104 using QueryThreadCycleTimePtr = decltype(::QueryThreadCycleTime)*; 103 using QueryThreadCycleTimePtr = decltype(::QueryThreadCycleTime)*;
105 QueryThreadCycleTimePtr GetQueryThreadCycleTimeFunction() { 104 QueryThreadCycleTimePtr GetQueryThreadCycleTimeFunction() {
106 static const QueryThreadCycleTimePtr query_thread_cycle_time_fn = 105 static const QueryThreadCycleTimePtr query_thread_cycle_time_fn =
107 reinterpret_cast<QueryThreadCycleTimePtr>(::GetProcAddress( 106 reinterpret_cast<QueryThreadCycleTimePtr>(::GetProcAddress(
108 ::GetModuleHandle(L"kernel32.dll"), "QueryThreadCycleTime")); 107 ::GetModuleHandle(L"kernel32.dll"), "QueryThreadCycleTime"));
109 return query_thread_cycle_time_fn; 108 return query_thread_cycle_time_fn;
110 } 109 }
111 110
112 // Returns the current value of the performance counter. 111 // Returns the current value of the performance counter.
113 uint64 QPCNowRaw() { 112 uint64_t QPCNowRaw() {
114 LARGE_INTEGER perf_counter_now = {}; 113 LARGE_INTEGER perf_counter_now = {};
115 // According to the MSDN documentation for QueryPerformanceCounter(), this 114 // According to the MSDN documentation for QueryPerformanceCounter(), this
116 // will never fail on systems that run XP or later. 115 // will never fail on systems that run XP or later.
117 // https://msdn.microsoft.com/library/windows/desktop/ms644904.aspx 116 // https://msdn.microsoft.com/library/windows/desktop/ms644904.aspx
118 ::QueryPerformanceCounter(&perf_counter_now); 117 ::QueryPerformanceCounter(&perf_counter_now);
119 return perf_counter_now.QuadPart; 118 return perf_counter_now.QuadPart;
120 } 119 }
121 120
122 } // namespace 121 } // namespace
123 122
124 // Time ----------------------------------------------------------------------- 123 // Time -----------------------------------------------------------------------
125 124
126 // The internal representation of Time uses FILETIME, whose epoch is 1601-01-01 125 // The internal representation of Time uses FILETIME, whose epoch is 1601-01-01
127 // 00:00:00 UTC. ((1970-1601)*365+89)*24*60*60*1000*1000, where 89 is the 126 // 00:00:00 UTC. ((1970-1601)*365+89)*24*60*60*1000*1000, where 89 is the
128 // number of leap year days between 1601 and 1970: (1970-1601)/4 excluding 127 // number of leap year days between 1601 and 1970: (1970-1601)/4 excluding
129 // 1700, 1800, and 1900. 128 // 1700, 1800, and 1900.
130 // static 129 // static
131 const int64 Time::kTimeTToMicrosecondsOffset = INT64_C(11644473600000000); 130 const int64_t Time::kTimeTToMicrosecondsOffset = INT64_C(11644473600000000);
132 131
133 // static 132 // static
134 Time Time::Now() { 133 Time Time::Now() {
135 if (initial_time == 0) 134 if (initial_time == 0)
136 InitializeClock(); 135 InitializeClock();
137 136
138 // We implement time using the high-resolution timers so that we can get 137 // We implement time using the high-resolution timers so that we can get
139 // timeouts which are smaller than 10-15ms. If we just used 138 // timeouts which are smaller than 10-15ms. If we just used
140 // CurrentWallclockMicroseconds(), we'd have the less-granular timer. 139 // CurrentWallclockMicroseconds(), we'd have the less-granular timer.
141 // 140 //
(...skipping 21 matching lines...) Expand all
163 162
164 // static 163 // static
165 Time Time::NowFromSystemTime() { 164 Time Time::NowFromSystemTime() {
166 // Force resync. 165 // Force resync.
167 InitializeClock(); 166 InitializeClock();
168 return Time(initial_time); 167 return Time(initial_time);
169 } 168 }
170 169
171 // static 170 // static
172 Time Time::FromFileTime(FILETIME ft) { 171 Time Time::FromFileTime(FILETIME ft) {
173 if (bit_cast<int64, FILETIME>(ft) == 0) 172 if (bit_cast<int64_t, FILETIME>(ft) == 0)
174 return Time(); 173 return Time();
175 if (ft.dwHighDateTime == std::numeric_limits<DWORD>::max() && 174 if (ft.dwHighDateTime == std::numeric_limits<DWORD>::max() &&
176 ft.dwLowDateTime == std::numeric_limits<DWORD>::max()) 175 ft.dwLowDateTime == std::numeric_limits<DWORD>::max())
177 return Max(); 176 return Max();
178 return Time(FileTimeToMicroseconds(ft)); 177 return Time(FileTimeToMicroseconds(ft));
179 } 178 }
180 179
181 FILETIME Time::ToFileTime() const { 180 FILETIME Time::ToFileTime() const {
182 if (is_null()) 181 if (is_null())
183 return bit_cast<FILETIME, int64>(0); 182 return bit_cast<FILETIME, int64_t>(0);
184 if (is_max()) { 183 if (is_max()) {
185 FILETIME result; 184 FILETIME result;
186 result.dwHighDateTime = std::numeric_limits<DWORD>::max(); 185 result.dwHighDateTime = std::numeric_limits<DWORD>::max();
187 result.dwLowDateTime = std::numeric_limits<DWORD>::max(); 186 result.dwLowDateTime = std::numeric_limits<DWORD>::max();
188 return result; 187 return result;
189 } 188 }
190 FILETIME utc_ft; 189 FILETIME utc_ft;
191 MicrosecondsToFileTime(us_, &utc_ft); 190 MicrosecondsToFileTime(us_, &utc_ft);
192 return utc_ft; 191 return utc_ft;
193 } 192 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // We define a wrapper to adapt between the __stdcall and __cdecl call of the 324 // We define a wrapper to adapt between the __stdcall and __cdecl call of the
326 // mock function, and to avoid a static constructor. Assigning an import to a 325 // mock function, and to avoid a static constructor. Assigning an import to a
327 // function pointer directly would require setup code to fetch from the IAT. 326 // function pointer directly would require setup code to fetch from the IAT.
328 DWORD timeGetTimeWrapper() { 327 DWORD timeGetTimeWrapper() {
329 return timeGetTime(); 328 return timeGetTime();
330 } 329 }
331 330
332 DWORD (*g_tick_function)(void) = &timeGetTimeWrapper; 331 DWORD (*g_tick_function)(void) = &timeGetTimeWrapper;
333 332
334 // Accumulation of time lost due to rollover (in milliseconds). 333 // Accumulation of time lost due to rollover (in milliseconds).
335 int64 g_rollover_ms = 0; 334 int64_t g_rollover_ms = 0;
336 335
337 // The last timeGetTime value we saw, to detect rollover. 336 // The last timeGetTime value we saw, to detect rollover.
338 DWORD g_last_seen_now = 0; 337 DWORD g_last_seen_now = 0;
339 338
340 // Lock protecting rollover_ms and last_seen_now. 339 // Lock protecting rollover_ms and last_seen_now.
341 // Note: this is a global object, and we usually avoid these. However, the time 340 // Note: this is a global object, and we usually avoid these. However, the time
342 // code is low-level, and we don't want to use Singletons here (it would be too 341 // code is low-level, and we don't want to use Singletons here (it would be too
343 // easy to use a Singleton without even knowing it, and that may lead to many 342 // easy to use a Singleton without even knowing it, and that may lead to many
344 // gotchas). Its impact on startup time should be negligible due to low-level 343 // gotchas). Its impact on startup time should be negligible due to low-level
345 // nature of time code. 344 // nature of time code.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // this timer; and also other Windows applications can alter it, affecting this 395 // this timer; and also other Windows applications can alter it, affecting this
397 // one. 396 // one.
398 397
399 using NowFunction = TimeDelta (*)(void); 398 using NowFunction = TimeDelta (*)(void);
400 399
401 TimeDelta InitialNowFunction(); 400 TimeDelta InitialNowFunction();
402 401
403 // See "threading notes" in InitializeNowFunctionPointer() for details on how 402 // See "threading notes" in InitializeNowFunctionPointer() for details on how
404 // concurrent reads/writes to these globals has been made safe. 403 // concurrent reads/writes to these globals has been made safe.
405 NowFunction g_now_function = &InitialNowFunction; 404 NowFunction g_now_function = &InitialNowFunction;
406 int64 g_qpc_ticks_per_second = 0; 405 int64_t g_qpc_ticks_per_second = 0;
407 406
408 // As of January 2015, use of <atomic> is forbidden in Chromium code. This is 407 // As of January 2015, use of <atomic> is forbidden in Chromium code. This is
409 // what std::atomic_thread_fence does on Windows on all Intel architectures when 408 // what std::atomic_thread_fence does on Windows on all Intel architectures when
410 // the memory_order argument is anything but std::memory_order_seq_cst: 409 // the memory_order argument is anything but std::memory_order_seq_cst:
411 #define ATOMIC_THREAD_FENCE(memory_order) _ReadWriteBarrier(); 410 #define ATOMIC_THREAD_FENCE(memory_order) _ReadWriteBarrier();
412 411
413 TimeDelta QPCValueToTimeDelta(LONGLONG qpc_value) { 412 TimeDelta QPCValueToTimeDelta(LONGLONG qpc_value) {
414 // Ensure that the assignment to |g_qpc_ticks_per_second|, made in 413 // Ensure that the assignment to |g_qpc_ticks_per_second|, made in
415 // InitializeNowFunctionPointer(), has happened by this point. 414 // InitializeNowFunctionPointer(), has happened by this point.
416 ATOMIC_THREAD_FENCE(memory_order_acquire); 415 ATOMIC_THREAD_FENCE(memory_order_acquire);
417 416
418 DCHECK_GT(g_qpc_ticks_per_second, 0); 417 DCHECK_GT(g_qpc_ticks_per_second, 0);
419 418
420 // If the QPC Value is below the overflow threshold, we proceed with 419 // If the QPC Value is below the overflow threshold, we proceed with
421 // simple multiply and divide. 420 // simple multiply and divide.
422 if (qpc_value < Time::kQPCOverflowThreshold) { 421 if (qpc_value < Time::kQPCOverflowThreshold) {
423 return TimeDelta::FromMicroseconds( 422 return TimeDelta::FromMicroseconds(
424 qpc_value * Time::kMicrosecondsPerSecond / g_qpc_ticks_per_second); 423 qpc_value * Time::kMicrosecondsPerSecond / g_qpc_ticks_per_second);
425 } 424 }
426 // Otherwise, calculate microseconds in a round about manner to avoid 425 // Otherwise, calculate microseconds in a round about manner to avoid
427 // overflow and precision issues. 426 // overflow and precision issues.
428 int64 whole_seconds = qpc_value / g_qpc_ticks_per_second; 427 int64_t whole_seconds = qpc_value / g_qpc_ticks_per_second;
429 int64 leftover_ticks = qpc_value - (whole_seconds * g_qpc_ticks_per_second); 428 int64_t leftover_ticks = qpc_value - (whole_seconds * g_qpc_ticks_per_second);
430 return TimeDelta::FromMicroseconds( 429 return TimeDelta::FromMicroseconds(
431 (whole_seconds * Time::kMicrosecondsPerSecond) + 430 (whole_seconds * Time::kMicrosecondsPerSecond) +
432 ((leftover_ticks * Time::kMicrosecondsPerSecond) / 431 ((leftover_ticks * Time::kMicrosecondsPerSecond) /
433 g_qpc_ticks_per_second)); 432 g_qpc_ticks_per_second));
434 } 433 }
435 434
436 TimeDelta QPCNow() { 435 TimeDelta QPCNow() {
437 return QPCValueToTimeDelta(QPCNowRaw()); 436 return QPCValueToTimeDelta(QPCNowRaw());
438 } 437 }
439 438
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 ULONG64 thread_cycle_time = 0; 518 ULONG64 thread_cycle_time = 0;
520 GetQueryThreadCycleTimeFunction()(::GetCurrentThread(), &thread_cycle_time); 519 GetQueryThreadCycleTimeFunction()(::GetCurrentThread(), &thread_cycle_time);
521 520
522 // Get the frequency of the TSC. 521 // Get the frequency of the TSC.
523 double tsc_ticks_per_second = TSCTicksPerSecond(); 522 double tsc_ticks_per_second = TSCTicksPerSecond();
524 if (tsc_ticks_per_second == 0) 523 if (tsc_ticks_per_second == 0)
525 return ThreadTicks(); 524 return ThreadTicks();
526 525
527 // Return the CPU time of the current thread. 526 // Return the CPU time of the current thread.
528 double thread_time_seconds = thread_cycle_time / tsc_ticks_per_second; 527 double thread_time_seconds = thread_cycle_time / tsc_ticks_per_second;
529 return ThreadTicks(static_cast<int64>( 528 return ThreadTicks(
530 thread_time_seconds * Time::kMicrosecondsPerSecond)); 529 static_cast<int64_t>(thread_time_seconds * Time::kMicrosecondsPerSecond));
531 } 530 }
532 531
533 // static 532 // static
534 bool ThreadTicks::IsSupportedWin() { 533 bool ThreadTicks::IsSupportedWin() {
535 static bool is_supported = GetQueryThreadCycleTimeFunction() && 534 static bool is_supported = GetQueryThreadCycleTimeFunction() &&
536 base::CPU().has_non_stop_time_stamp_counter() && 535 base::CPU().has_non_stop_time_stamp_counter() &&
537 !IsBuggyAthlon(base::CPU()); 536 !IsBuggyAthlon(base::CPU());
538 return is_supported; 537 return is_supported;
539 } 538 }
540 539
(...skipping 16 matching lines...) Expand all
557 if (tsc_ticks_per_second != 0) 556 if (tsc_ticks_per_second != 0)
558 return tsc_ticks_per_second; 557 return tsc_ticks_per_second;
559 558
560 // Increase the thread priority to reduces the chances of having a context 559 // Increase the thread priority to reduces the chances of having a context
561 // switch during a reading of the TSC and the performance counter. 560 // switch during a reading of the TSC and the performance counter.
562 int previous_priority = ::GetThreadPriority(::GetCurrentThread()); 561 int previous_priority = ::GetThreadPriority(::GetCurrentThread());
563 ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 562 ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
564 563
565 // The first time that this function is called, make an initial reading of the 564 // The first time that this function is called, make an initial reading of the
566 // TSC and the performance counter. 565 // TSC and the performance counter.
567 static const uint64 tsc_initial = __rdtsc(); 566 static const uint64_t tsc_initial = __rdtsc();
568 static const uint64 perf_counter_initial = QPCNowRaw(); 567 static const uint64_t perf_counter_initial = QPCNowRaw();
569 568
570 // Make a another reading of the TSC and the performance counter every time 569 // Make a another reading of the TSC and the performance counter every time
571 // that this function is called. 570 // that this function is called.
572 uint64 tsc_now = __rdtsc(); 571 uint64_t tsc_now = __rdtsc();
573 uint64 perf_counter_now = QPCNowRaw(); 572 uint64_t perf_counter_now = QPCNowRaw();
574 573
575 // Reset the thread priority. 574 // Reset the thread priority.
576 ::SetThreadPriority(::GetCurrentThread(), previous_priority); 575 ::SetThreadPriority(::GetCurrentThread(), previous_priority);
577 576
578 // Make sure that at least 50 ms elapsed between the 2 readings. The first 577 // Make sure that at least 50 ms elapsed between the 2 readings. The first
579 // time that this function is called, we don't expect this to be the case. 578 // time that this function is called, we don't expect this to be the case.
580 // Note: The longer the elapsed time between the 2 readings is, the more 579 // Note: The longer the elapsed time between the 2 readings is, the more
581 // accurate the computed TSC frequency will be. The 50 ms value was 580 // accurate the computed TSC frequency will be. The 50 ms value was
582 // chosen because local benchmarks show that it allows us to get a 581 // chosen because local benchmarks show that it allows us to get a
583 // stddev of less than 1 tick/us between multiple runs. 582 // stddev of less than 1 tick/us between multiple runs.
584 // Note: According to the MSDN documentation for QueryPerformanceFrequency(), 583 // Note: According to the MSDN documentation for QueryPerformanceFrequency(),
585 // this will never fail on systems that run XP or later. 584 // this will never fail on systems that run XP or later.
586 // https://msdn.microsoft.com/library/windows/desktop/ms644905.aspx 585 // https://msdn.microsoft.com/library/windows/desktop/ms644905.aspx
587 LARGE_INTEGER perf_counter_frequency = {}; 586 LARGE_INTEGER perf_counter_frequency = {};
588 ::QueryPerformanceFrequency(&perf_counter_frequency); 587 ::QueryPerformanceFrequency(&perf_counter_frequency);
589 DCHECK_GE(perf_counter_now, perf_counter_initial); 588 DCHECK_GE(perf_counter_now, perf_counter_initial);
590 uint64 perf_counter_ticks = perf_counter_now - perf_counter_initial; 589 uint64_t perf_counter_ticks = perf_counter_now - perf_counter_initial;
591 double elapsed_time_seconds = 590 double elapsed_time_seconds =
592 perf_counter_ticks / static_cast<double>(perf_counter_frequency.QuadPart); 591 perf_counter_ticks / static_cast<double>(perf_counter_frequency.QuadPart);
593 592
594 const double kMinimumEvaluationPeriodSeconds = 0.05; 593 const double kMinimumEvaluationPeriodSeconds = 0.05;
595 if (elapsed_time_seconds < kMinimumEvaluationPeriodSeconds) 594 if (elapsed_time_seconds < kMinimumEvaluationPeriodSeconds)
596 return 0; 595 return 0;
597 596
598 // Compute the frequency of the TSC. 597 // Compute the frequency of the TSC.
599 DCHECK_GE(tsc_now, tsc_initial); 598 DCHECK_GE(tsc_now, tsc_initial);
600 uint64 tsc_ticks = tsc_now - tsc_initial; 599 uint64_t tsc_ticks = tsc_now - tsc_initial;
601 tsc_ticks_per_second = tsc_ticks / elapsed_time_seconds; 600 tsc_ticks_per_second = tsc_ticks / elapsed_time_seconds;
602 601
603 return tsc_ticks_per_second; 602 return tsc_ticks_per_second;
604 } 603 }
605 604
606 // static 605 // static
607 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) { 606 TimeTicks TimeTicks::FromQPCValue(LONGLONG qpc_value) {
608 return TimeTicks() + QPCValueToTimeDelta(qpc_value); 607 return TimeTicks() + QPCValueToTimeDelta(qpc_value);
609 } 608 }
610 609
611 // TimeDelta ------------------------------------------------------------------ 610 // TimeDelta ------------------------------------------------------------------
612 611
613 // static 612 // static
614 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) { 613 TimeDelta TimeDelta::FromQPCValue(LONGLONG qpc_value) {
615 return QPCValueToTimeDelta(qpc_value); 614 return QPCValueToTimeDelta(qpc_value);
616 } 615 }
OLDNEW
« no previous file with comments | « base/time/time_unittest.cc ('k') | base/time/time_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698