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

Side by Side Diff: tools/perf/metrics/cpu.py

Issue 2560543002: [telemetry] Fix CPU metric jiffie overflow correction. (Closed)
Patch Set: Typo. Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/perf/metrics/cpu_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from telemetry.value import scalar 7 from telemetry.value import scalar
8 8
9 from metrics import Metric 9 from metrics import Metric
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 assert process_type in start_cpu_stats, 'Mismatching process types' 80 assert process_type in start_cpu_stats, 'Mismatching process types'
81 # Skip any process_types that are empty. 81 # Skip any process_types that are empty.
82 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]): 82 if (not cpu_stats[process_type]) or (not start_cpu_stats[process_type]):
83 continue 83 continue
84 cpu_process_time = (cpu_stats[process_type]['CpuProcessTime'] - 84 cpu_process_time = (cpu_stats[process_type]['CpuProcessTime'] -
85 start_cpu_stats[process_type]['CpuProcessTime']) 85 start_cpu_stats[process_type]['CpuProcessTime'])
86 total_time = (cpu_stats[process_type]['TotalTime'] - 86 total_time = (cpu_stats[process_type]['TotalTime'] -
87 start_cpu_stats[process_type]['TotalTime']) 87 start_cpu_stats[process_type]['TotalTime'])
88 # Fix overflow for 32-bit jiffie counter, 64-bit counter will not overflow. 88 # Fix overflow for 32-bit jiffie counter, 64-bit counter will not overflow.
89 # Linux kernel starts with a value close to an overflow, so correction is 89 # Linux kernel starts with a value close to an overflow, so correction is
90 # necessary. 90 # necessary. Assume jiffie counter is at 100 Hz.
91 if total_time < 0: 91 if total_time < 0:
92 total_time += 2 ** 32 92 total_time += 2 ** 32 / 100.
93 # Assert that the arguments were given in the correct order. 93 # Assert that the arguments were given in the correct order.
94 assert total_time > 0 and total_time < 2 ** 31, ( 94 assert total_time > 0 and total_time < 2 ** 31 / 100., (
95 'Expected total_time > 0, was: %d' % total_time) 95 'Expected total_time > 0, was: %d' % total_time)
96 cpu_usage[process_type] = float(cpu_process_time) / total_time 96 cpu_usage[process_type] = float(cpu_process_time) / total_time
97 return cpu_usage 97 return cpu_usage
OLDNEW
« 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