Chromium Code Reviews| Index: tools/perf/metrics/cpu.py |
| diff --git a/tools/perf/metrics/cpu.py b/tools/perf/metrics/cpu.py |
| index 7666cb7fcf56e88ad704d92391d26501d5e7f483..07229d822234500387a5f63cca521f942ff7e9eb 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. |
| + # Android devices start with a value close to an overflow, so correction is |
|
Sami
2014/06/30 15:52:26
Looks like this isn't really Android-specific but
Victor Starodub
2014/06/30 16:15:02
Thanks. Fixed the comment
|
| + # 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 |