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

Unified Diff: tools/win/IdleWakeups/power_sampler.h

Issue 2356753004: IdleWakeups tool (Closed)
Patch Set: Removed TODO from stdafx.cpp and added myself to OWNERS file. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/win/IdleWakeups/idle_wakeups.cpp ('k') | tools/win/IdleWakeups/power_sampler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/win/IdleWakeups/power_sampler.h
diff --git a/tools/win/IdleWakeups/power_sampler.h b/tools/win/IdleWakeups/power_sampler.h
new file mode 100644
index 0000000000000000000000000000000000000000..5998f7bb481b189668b2451a7a11eec6e3c8742e
--- /dev/null
+++ b/tools/win/IdleWakeups/power_sampler.h
@@ -0,0 +1,49 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TOOLS_WIN_IDLEWAKEUPS_POWER_SAMPLER_H_
+#define TOOLS_WIN_IDLEWAKEUPS_POWER_SAMPLER_H_
+
+#include <map>
+#include <string>
+
+#include <windows.h>
+
+// https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x
+typedef int (*IntelEnergyLibInitialize_t)();
+typedef int (*GetNumMsrs_t)(int* nMsr);
+typedef int (*GetMsrName_t)(int iMsr, wchar_t* szName);
+typedef int (*GetMsrFunc_t)(int iMsr, int* pFuncID);
+typedef int (*GetPowerData_t)(int iNode,
+ int iMsr,
+ double* pResult,
+ int* nResult);
+typedef int (*ReadSample_t)();
+
+class PowerSampler {
+ public:
+ PowerSampler();
+ ~PowerSampler();
+
+ void SampleCPUPowerState();
+
+ double get_power(std::wstring key) { return power_[key]; }
+
+ private:
+ // Power consumed in mWh since the last sample.
+ std::map<std::wstring, double> power_;
+
+ HMODULE energy_lib_ = nullptr;
+ IntelEnergyLibInitialize_t IntelEnergyLibInitialize = nullptr;
+ GetNumMsrs_t GetNumMsrs = nullptr;
+ GetMsrName_t GetMsrName = nullptr;
+ GetMsrFunc_t GetMsrFunc = nullptr;
+ GetPowerData_t GetPowerData = nullptr;
+ ReadSample_t ReadSample = nullptr;
+
+ PowerSampler& operator=(const PowerSampler&) = delete;
+ PowerSampler(const PowerSampler&) = delete;
+};
+
+#endif // TOOLS_WIN_IDLEWAKEUPS_POWER_SAMPLER_H_
« no previous file with comments | « tools/win/IdleWakeups/idle_wakeups.cpp ('k') | tools/win/IdleWakeups/power_sampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698