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

Unified Diff: base/test/energy_monitor_mac.h

Issue 1393233002: Mac Energy Test Harness/Framework Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Snapshot of scripts for http://crbug.com/391646 Created 5 years, 2 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 | « base/test/BUILD.gn ('k') | base/test/energy_monitor_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/energy_monitor_mac.h
diff --git a/base/test/energy_monitor_mac.h b/base/test/energy_monitor_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..eaed60de80badfbedf6259b73968f0f9f083744d
--- /dev/null
+++ b/base/test/energy_monitor_mac.h
@@ -0,0 +1,63 @@
+// Copyright 2015 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 BASE_TEST_ENERGY_MONITOR_MAC_H_
+#define BASE_TEST_ENERGY_MONITOR_MAC_H_
+
+#include <stdint.h>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/time/time.h"
+
+namespace base {
+
+class FilePath;
+
+namespace test {
+
+// Class that executes a base::RunLoop on the current thread, sampling power
+// draw from Intel Machine-Specific Registers at regular intervals.
+class EnergyMonitorMac {
+ public:
+ enum EnergyType { PROCESSOR, IA, NUM_ENERGY_TYPES };
+
+ EnergyMonitorMac();
+ ~EnergyMonitorMac();
+
+ // Executes a run loop on the current thread. Starts taking samples after
+ // |warmup_delay|, and quits the runloop after taking num_samples.
+ void Run(const base::TimeDelta& warmup_delay, size_t num_samples);
+
+ // Set the sampling frequency. By default, each sample is taken after a 50
+ // millisecond delay by posting an event to the RunLoop.
+ void SetSampleDelay(const base::TimeDelta& sample_delay);
+
+ double GetAverageWatts(EnergyType type) const;
+ double GetStdDevWatts(EnergyType type) const;
+
+ void WriteTimeSeries(const base::FilePath& file);
+
+ private:
+ void ReadNextSample();
+ void TakeSample();
+
+ base::TimeDelta sample_delay_;
+ size_t target_sample_count_ = ~0;
+ base::Closure quit_closure_;
+
+ struct {
+ int msr_index = -1;
+ std::vector<double> watts;
+ } samples_[NUM_ENERGY_TYPES];
+
+ std::vector<uint64_t> rdtsc_values_;
+
+ DISALLOW_COPY_AND_ASSIGN(EnergyMonitorMac);
+};
+
+} // namespace test
+} // namespace base
+
+#endif // BASE_TEST_ENERGY_MONITOR_MAC_H_
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/energy_monitor_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698