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

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

Issue 239083010: Telemetry: adds CPU frequency stats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unit-info Created 6 years, 8 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
Index: tools/perf/metrics/cpu_unittest.py
diff --git a/tools/perf/metrics/cpu_unittest.py b/tools/perf/metrics/cpu_unittest.py
index 30d488dac8bc420399e00f32ea8a6fff6b8277d0..6f083794baf3fee515b66b04b66c6ef032081d75 100644
--- a/tools/perf/metrics/cpu_unittest.py
+++ b/tools/perf/metrics/cpu_unittest.py
@@ -31,3 +31,47 @@ class CpuMetricTest(unittest.TestCase):
self.assertEqual({'Browser': 0.25, 'Renderer': 0.1},
cpu._SubtractCpuStats(end, start))
+ # The result for global frequency stats is used.
+ start = {
+ 'Browser': {'CpuProcessTime': 0, 'TotalTime': 0},
+ 'Global': {'GlobalCpuFrequencyStats': {1000000: 9, 2000000: 19}}
+ }
+ end = {
+ 'Browser': {'CpuProcessTime': 5, 'TotalTime': 20},
+ 'Global': {'GlobalCpuFrequencyStats': {1000000: 20, 2000000: 31}}
+ }
+
+ expected = {
+ 'Browser': 0.25,
+ 'Global': {'GlobalCpuFrequencyStats': {1000000: 11, 2000000: 12}}
+ }
+
+ self.assertEqual(expected, cpu._SubtractCpuStats(end, start))
+
+ def testAddResults(self):
+ results = {
+ 'Browser': 0.25,
+ 'Global': {'GlobalCpuFrequencyStats': {1000000: 11, 2000000: 12}}
+ }
+ class MockResults(object):
+ def __init__(self):
+ self.trace_name = None
+ self.units = None
+ self.value = None
+ self.chart_name = None
+ self.data_type = None
+
+ def Add(self, trace_name, units, value, chart_name=None,
+ data_type='default'):
+ self.trace_name = trace_name
+ self.units = units
+ self.value = value
+ self.chart_name = chart_name
+ self.data_type = data_type
+
+ mock_results = MockResults()
+ cpu_metric = cpu.CpuMetric(None)
+ cpu_metric._results = results
+ cpu_metric.AddResults(None, mock_results)
+ self.assertEquals(1521.74, mock_results.value)
+

Powered by Google App Engine
This is Rietveld 408576698