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

Unified Diff: tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor.py

Issue 337753002: [Telemetry] Use total power measurement calculated by `powermetrics` (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More precise math Created 6 years, 6 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 | « no previous file | tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor.py
diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor.py
index c2f141b543174c95750a19fe25b7cbd8ffaf4b5c..74006d16b743aeafd9620597a53b54b61587eed3 100644
--- a/tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor.py
+++ b/tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor.py
@@ -125,7 +125,6 @@ class PowerMetricsPowerMonitor(power_monitor.PowerMonitor):
"Was expecting a number: %s (%s)" % (type(out_data), out_data))
return float(out_data)
- power_samples = []
sample_durations = []
total_energy_consumption_mwh = 0
# powermetrics outputs multiple plists separated by null terminators.
@@ -176,7 +175,7 @@ class PowerMetricsPowerMonitor(power_monitor.PowerMonitor):
plist = PowerMetricsPowerMonitor._ParsePlistString(raw_plists[0])
if not plist:
logging.error("Error parsing plist.")
- return
+ return {}
# Duration of this sample.
sample_duration_ms = int(plist['elapsed_ns']) / 10**6
@@ -184,15 +183,11 @@ class PowerMetricsPowerMonitor(power_monitor.PowerMonitor):
if 'processor' not in plist:
logging.error("'processor' field not found in plist.")
- return
+ return {}
processor = plist['processor']
- energy_consumption_mw = int(processor.get('package_watts', 0)) * 10**3
-
- total_energy_consumption_mwh += (energy_consumption_mw *
- (sample_duration_ms / 3600000.))
-
- power_samples.append(energy_consumption_mw)
+ total_energy_consumption_mwh = (
+ (float(processor.get('package_joules', 0)) / 3600.) * 10**3 )
for m in metrics:
m.samples.append(DataWithMetricKeyPath(m, plist))
@@ -200,10 +195,7 @@ class PowerMetricsPowerMonitor(power_monitor.PowerMonitor):
# -------- Collect and Process Data --------
out_dict = {}
out_dict['identifier'] = 'powermetrics'
- # Raw power usage samples.
- if power_samples:
- out_dict['power_samples_mw'] = power_samples
- out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh
+ out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh
def StoreMetricAverage(metric, sample_durations, out):
"""Calculate average value of samples in a metric and store in output
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/power_monitor/powermetrics_power_monitor_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698