@@ -32,17 +32,9 @@ static uint64_t ToNanoSeconds(const FILETIME& aFileTime) {
32
32
return usec.QuadPart * 100 ;
33
33
}
34
34
35
- int GetCycleTimeFrequencyMHz () {
35
+ int GetCpuFrequencyMHz () {
36
36
static const int frequency = []() {
37
- // Having a constant TSC is required to convert cycle time to actual time.
38
- // In automation, having short CPU times reported as 0 is more of a problem
39
- // than having an imprecise value. The fallback method can't report CPU
40
- // times < 1/64s.
41
- if (!mozilla::has_constant_tsc () && !xpc::IsInAutomation ()) {
42
- return 0 ;
43
- }
44
-
45
- // Now get the nominal CPU frequency.
37
+ // Get the nominal CPU frequency.
46
38
HKEY key;
47
39
static const WCHAR keyName[] =
48
40
L" HARDWARE\\ DESCRIPTION\\ System\\ CentralProcessor\\ 0" ;
@@ -64,6 +56,22 @@ int GetCycleTimeFrequencyMHz() {
64
56
return frequency;
65
57
}
66
58
59
+ int GetCycleTimeFrequencyMHz () {
60
+ static const int frequency = []() {
61
+ // Having a constant TSC is required to convert cycle time to actual time.
62
+ // In automation, having short CPU times reported as 0 is more of a problem
63
+ // than having an imprecise value. The fallback method can't report CPU
64
+ // times < 1/64s.
65
+ if (!mozilla::has_constant_tsc () && !xpc::IsInAutomation ()) {
66
+ return 0 ;
67
+ }
68
+
69
+ return GetCpuFrequencyMHz ();
70
+ }();
71
+
72
+ return frequency;
73
+ }
74
+
67
75
nsresult GetCpuTimeSinceProcessStartInMs (uint64_t * aResult) {
68
76
int frequencyInMHz = GetCycleTimeFrequencyMHz ();
69
77
if (frequencyInMHz) {
0 commit comments