OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 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 TOOLS_WIN_IDLEWAKEUPS_POWER_STATUS_MONITOR_H_ |
| 6 #define TOOLS_WIN_IDLEWAKEUPS_POWER_STATUS_MONITOR_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 11 #include <windows.h> |
| 12 |
| 13 // https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadge
t-api-on-mac-os-x |
| 14 typedef int (*IntelEnergyLibInitialize_t)(); |
| 15 typedef int (*GetNumMsrs_t)(int* nMsr); |
| 16 typedef int (*GetMsrName_t)(int iMsr, wchar_t* szName); |
| 17 typedef int (*GetMsrFunc_t)(int iMsr, int* pFuncID); |
| 18 typedef int (*GetPowerData_t)(int iNode, |
| 19 int iMsr, |
| 20 double* pResult, |
| 21 int* nResult); |
| 22 typedef int (*ReadSample_t)(); |
| 23 |
| 24 class PowerSampler { |
| 25 public: |
| 26 PowerSampler(); |
| 27 ~PowerSampler(); |
| 28 |
| 29 void SampleCPUPowerState(); |
| 30 |
| 31 double get_power(std::wstring key) { return power_[key]; } |
| 32 |
| 33 private: |
| 34 // Power consumed in mWh since the last sample. |
| 35 std::map<std::wstring, double> power_; |
| 36 |
| 37 HMODULE energy_lib_ = nullptr; |
| 38 IntelEnergyLibInitialize_t IntelEnergyLibInitialize = nullptr; |
| 39 GetNumMsrs_t GetNumMsrs = nullptr; |
| 40 GetMsrName_t GetMsrName = nullptr; |
| 41 GetMsrFunc_t GetMsrFunc = nullptr; |
| 42 GetPowerData_t GetPowerData = nullptr; |
| 43 ReadSample_t ReadSample = nullptr; |
| 44 |
| 45 PowerSampler& operator=(const PowerSampler&) = delete; |
| 46 PowerSampler(const PowerSampler&) = delete; |
| 47 }; |
| 48 |
| 49 #endif // TOOLS_WIN_IDLEWAKEUPS_POWER_STATUS_MONITOR_H_ |
OLD | NEW |