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

Side by Side Diff: tools/perf/metrics/cpu_unittest.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 | « tools/perf/metrics/cpu.py ('k') | no next file » | 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 unittest 5 import unittest
6 6
7 from metrics import cpu 7 from metrics import cpu
8 8
9 # Testing private method. 9 # Testing private method.
10 # pylint: disable=protected-access 10 # pylint: disable=protected-access
(...skipping 17 matching lines...) Expand all
28 # A process type will be ignored if there's an empty dict for start or end. 28 # A process type will be ignored if there's an empty dict for start or end.
29 start['Renderer'] = {} 29 start['Renderer'] = {}
30 self.assertEqual({'Browser': 0.25}, cpu._SubtractCpuStats(end, start)) 30 self.assertEqual({'Browser': 0.25}, cpu._SubtractCpuStats(end, start))
31 31
32 # Results for multiple process types can be computed. 32 # Results for multiple process types can be computed.
33 start['Renderer'] = {'CpuProcessTime': 0, 'TotalTime': 0} 33 start['Renderer'] = {'CpuProcessTime': 0, 'TotalTime': 0}
34 self.assertEqual({'Browser': 0.25, 'Renderer': 0.1}, 34 self.assertEqual({'Browser': 0.25, 'Renderer': 0.1},
35 cpu._SubtractCpuStats(end, start)) 35 cpu._SubtractCpuStats(end, start))
36 36
37 # Test 32-bit overflow. 37 # Test 32-bit overflow.
38 start = {'Browser': {'CpuProcessTime': 0, 'TotalTime': 2 ** 32 - 20}} 38 start = {'Browser': {'CpuProcessTime': 0, 'TotalTime': 2 ** 32 / 100. - 20}}
39 end = {'Browser': {'CpuProcessTime': 5, 'TotalTime': 20}} 39 end = {'Browser': {'CpuProcessTime': 5, 'TotalTime': 20}}
40 self.assertEqual({'Browser': 0.125}, cpu._SubtractCpuStats(end, start)) 40 self.assertEqual({'Browser': 0.125}, cpu._SubtractCpuStats(end, start))
41 self.assertRaises(AssertionError, cpu._SubtractCpuStats, start, end) 41 self.assertRaises(AssertionError, cpu._SubtractCpuStats, start, end)
OLDNEW
« no previous file with comments | « tools/perf/metrics/cpu.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698