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

Unified Diff: tools/perf/metrics/cpu.py

Issue 362533003: Fix overflow for 32-bit jiffie counter on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment. 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/perf/metrics/cpu_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/metrics/cpu.py
diff --git a/tools/perf/metrics/cpu.py b/tools/perf/metrics/cpu.py
index 7666cb7fcf56e88ad704d92391d26501d5e7f483..3d54a9040efca5586db0fdc4c488976a79c824b9 100644
--- a/tools/perf/metrics/cpu.py
+++ b/tools/perf/metrics/cpu.py
@@ -65,7 +65,14 @@ def _SubtractCpuStats(cpu_stats, start_cpu_stats):
start_cpu_stats[process_type]['CpuProcessTime'])
total_time = (cpu_stats[process_type]['TotalTime'] -
start_cpu_stats[process_type]['TotalTime'])
- assert total_time > 0, 'Expected total_time > 0, was: %d' % total_time
+ # Fix overflow for 32-bit jiffie counter, 64-bit counter will not overflow.
+ # Linux kernel starts with a value close to an overflow, so correction is
+ # necessary.
+ if total_time < 0:
+ total_time += 2**32
+ # Assert that the arguments were given in the correct order.
+ assert total_time > 0 and total_time < 2**31, (
+ 'Expected total_time > 0, was: %d' % total_time)
cpu_usage[process_type] = float(cpu_process_time) / total_time
return cpu_usage
« no previous file with comments | « no previous file | tools/perf/metrics/cpu_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698