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

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

Issue 225513004: Fix power measurement with dumpsys when the format is unrecognized. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/android_dumpsys_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/android_dumpsys_power_monitor.py
diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py
index fae8a47ff1605ba584fcc2252d63cd23dcbbd4be..0e7cef57b2b51a6669c84ce983a011fb6f60b80c 100644
--- a/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py
+++ b/tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor.py
@@ -4,6 +4,7 @@
import telemetry.core.platform.power_monitor as power_monitor
+import logging
import csv
from collections import defaultdict
@@ -58,6 +59,11 @@ class DumpsysPowerMonitor(power_monitor.PowerMonitor):
Returns:
Dictionary in the format returned by StopMonitoringPower().
"""
+ # Raw power usage samples.
+ out_dict = {}
+ out_dict['identifier'] = 'dumpsys'
+ out_dict['power_samples_mw'] = []
+
# csv columns
DUMP_VERSION_INDEX = 0
COLUMN_TYPE_INDEX = 3
@@ -73,7 +79,10 @@ class DumpsysPowerMonitor(power_monitor.PowerMonitor):
continue
entries_by_type[entry[COLUMN_TYPE_INDEX]].append(entry)
# Find the uid of for the given package.
- assert package in entries_by_type, 'Expected package not found'
+ if not package in entries_by_type:
+ logging.warning('Unable to parse dumpsys output. Please upgrade the OS.')
+ out_dict['energy_consumption_mwh'] = 0
+ return out_dict
assert len(entries_by_type[package]) == 1, 'Multiple entries for package.'
uid = entries_by_type[package][0][PACKAGE_UID_INDEX]
consumptions_mah = [float(entry[PWI_POWER_COMSUMPTION_INDEX])
@@ -85,9 +94,5 @@ class DumpsysPowerMonitor(power_monitor.PowerMonitor):
# Converting at a nominal voltage of 4.0V, as those values are obtained by a
# heuristic, and 4.0V is the voltage we set when using a monsoon device.
consumption_mwh = consumption_mah * 4.0
- # Raw power usage samples.
- out_dict = {}
- out_dict['identifier'] = 'dumpsys'
- out_dict['power_samples_mw'] = []
out_dict['energy_consumption_mwh'] = consumption_mwh
return out_dict
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/power_monitor/android_dumpsys_power_monitor_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698