1 // Copyright 2024 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_POWER_MONITOR_CPU_FREQUENCY_UTILS_H_ 6 #define BASE_POWER_MONITOR_CPU_FREQUENCY_UTILS_H_ 7 8 #include "base/base_export.h" 9 10 namespace base { 11 12 // Returns the estimated CPU frequency by executing a tight loop of predictable 13 // assembly instructions. The estimated frequency should be proportional and 14 // about the same magnitude than the real CPU frequency. The measurement should 15 // be long enough to avoid Turbo Boost effect (~3ms) and be low enough to stay 16 // within the operating system scheduler quantum (~100ms). 17 // The return value is the estimated CPU frequency, in Hz. 18 BASE_EXPORT double EstimateCpuFrequency(); 19 20 // These functions map to fields in the win32 PROCESSOR_POWER_INFORMATION struct 21 // They are currently only implemented on Windows since that's the platform 22 // being investigated, but they could be replaced with something more 23 // generic/cross-platform as needed. 24 // Return the maximum frequency or the frequency limit of the fastest logical 25 // CPU. This means that on a big/little system, the little cores will never be 26 // captured by these functions. 27 BASE_EXPORT unsigned long GetCpuMaxMhz(); 28 BASE_EXPORT unsigned long GetCpuMhzLimit(); 29 30 } // namespace base 31 32 #endif // BASE_POWER_MONITOR_CPU_FREQUENCY_UTILS_H_ 33