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

Side by Side Diff: tools/telemetry/telemetry/web_perf/metrics/fast_metric_unittest.py

Issue 403093002: Merge all logic in PageMeasurementResults to PageTestResults. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 import StringIO 6 import StringIO
7 import unittest 7 import unittest
8 8
9 from telemetry.web_perf.metrics import fast_metric 9 from telemetry.web_perf.metrics import fast_metric
10 from telemetry.timeline import model as model_module 10 from telemetry.timeline import model as model_module
(...skipping 24 matching lines...) Expand all
35 **kwargs)) 35 **kwargs))
36 36
37 def MeasureFakePage(self, metric): 37 def MeasureFakePage(self, metric):
38 self._renderer_thread.async_slices.extend(self._async_slices) 38 self._renderer_thread.async_slices.extend(self._async_slices)
39 self._model.FinalizeImport() 39 self._model.FinalizeImport()
40 interaction_records = [ 40 interaction_records = [
41 tir_module.TimelineInteractionRecord.FromAsyncEvent(s) 41 tir_module.TimelineInteractionRecord.FromAsyncEvent(s)
42 for s in self._async_slices] 42 for s in self._async_slices]
43 results = page_measurement_results.PageMeasurementResults() 43 results = page_measurement_results.PageMeasurementResults()
44 fake_page = None 44 fake_page = None
45 results.WillMeasurePage(fake_page) 45 results.StartTest(fake_page)
46 metric.AddResults(self._model, self._renderer_thread, interaction_records, 46 metric.AddResults(self._model, self._renderer_thread, interaction_records,
47 results) 47 results)
48 results.StopTest(fake_page)
48 return results 49 return results
49 50
50 51
51 class FastMetricTests(unittest.TestCase): 52 class FastMetricTests(unittest.TestCase):
52 53
53 def setUp(self): 54 def setUp(self):
54 self.log_output = StringIO.StringIO() 55 self.log_output = StringIO.StringIO()
55 self.stream_handler = logging.StreamHandler(self.log_output) 56 self.stream_handler = logging.StreamHandler(self.log_output)
56 logging.getLogger().addHandler(self.stream_handler) 57 logging.getLogger().addHandler(self.stream_handler)
57 58
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 metric = fast_metric.FastMetric() 133 metric = fast_metric.FastMetric()
133 results = renderer_thread_helper.MeasureFakePage(metric) 134 results = renderer_thread_helper.MeasureFakePage(metric)
134 135
135 expected_values = [ 136 expected_values = [
136 ('fast-cpu_time', 'ms', 44), # thread overlap 137 ('fast-cpu_time', 'ms', 44), # thread overlap
137 ('fast-duration', 'ms', 54), # 27 + 27; total interaction wall duration 138 ('fast-duration', 'ms', 54), # 27 + 27; total interaction wall duration
138 ('fast-idle_time', 'ms', 18), # 27 - ((2 + 45) - 45); interaction wall 139 ('fast-idle_time', 'ms', 18), # 27 - ((2 + 45) - 45); interaction wall
139 # time outside of renderer wall time. 140 # time outside of renderer wall time.
140 ] 141 ]
141 self.assertEqual(expected_values, self.ActualValues(results)) 142 self.assertEqual(expected_values, self.ActualValues(results))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698