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

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

Issue 598093003: Workaround telemetry CPU problem on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Sammi's commment Created 6 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 | « no previous file | tools/telemetry/telemetry/core/platform/power_monitor/sysfs_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/sysfs_power_monitor.py
diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor.py
index 59d1aef3f58a3a7ea2db494160e8ed2af7ba3e95..d1dff5594a2a1568ac0b7181750b295168fd4cdd 100644
--- a/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor.py
+++ b/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor.py
@@ -104,7 +104,10 @@ class SysfsPowerMonitor(power_monitor.PowerMonitor):
for cpu in self._cpus:
cpu_freq_path = os.path.join(
CPU_PATH, cpu, 'cpufreq/stats/time_in_state')
- stats[cpu] = self._platform.RunCommand('cat %s' % cpu_freq_path)
+ try:
+ stats[cpu] = self._platform.GetFileContents(cpu_freq_path)
+ except Exception:
+ stats[cpu] = None
return stats
@staticmethod
@@ -120,6 +123,9 @@ class SysfsPowerMonitor(power_monitor.PowerMonitor):
sample_stats = {}
for cpu in sample:
frequencies = {}
+ if sample[cpu] is None:
+ sample_stats[cpu] = None
+ continue
for line in sample[cpu].splitlines():
pair = line.split()
freq = int(pair[0]) * 10 ** 3
@@ -152,6 +158,9 @@ class SysfsPowerMonitor(power_monitor.PowerMonitor):
for cpu in initial:
current_cpu = {}
total = 0
+ if initial[cpu] is None or final[cpu] is None:
+ cpu_stats[cpu] = collections.defaultdict(int)
+ continue
for state in initial[cpu]:
current_cpu[state] = final[cpu][state] - initial[cpu][state]
total += current_cpu[state]
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698