OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from collections import defaultdict | 5 from collections import defaultdict |
6 from itertools import starmap | 6 from itertools import starmap |
7 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
8 from telemetry.core import util | 8 from telemetry.core import util |
9 from telemetry.page import action_runner | |
10 from telemetry.page import page_test | 9 from telemetry.page import page_test |
11 from telemetry.value import scalar | 10 from telemetry.value import scalar |
12 | 11 |
13 from measurements import timeline_controller | 12 from measurements import timeline_controller |
14 | 13 |
15 | 14 |
16 class BlinkStyle(page_test.PageTest): | 15 class BlinkStyle(page_test.PageTest): |
17 | 16 |
18 def __init__(self): | 17 def __init__(self): |
19 super(BlinkStyle, self).__init__() | 18 super(BlinkStyle, self).__init__() |
20 self._controller = None | 19 self._controller = None |
21 | 20 |
22 def WillNavigateToPage(self, page, tab): | 21 def WillNavigateToPage(self, page, tab): |
23 self._controller = timeline_controller.TimelineController() | 22 self._controller = timeline_controller.TimelineController() |
24 self._controller.trace_categories = 'blink_style,blink.console' | 23 self._controller.trace_categories = 'blink_style,blink.console' |
25 self._controller.SetUp(page, tab) | 24 self._controller.SetUp(page, tab) |
26 self._controller.Start(tab) | 25 self._controller.Start(tab) |
27 | 26 |
28 def DidRunPage(self, platform): | 27 def DidRunPage(self, platform): |
29 if self._controller: | 28 if self._controller: |
30 self._controller.CleanUp(platform) | 29 self._controller.CleanUp(platform) |
31 | 30 |
32 def ValidateAndMeasurePage(self, page, tab, results): | 31 def ValidateAndMeasurePage(self, page, tab, results): |
33 runner = action_runner.ActionRunner(tab) | 32 with tab.action_runner.CreateInteraction('wait-for-quiescence'): |
34 with runner.CreateInteraction('wait-for-quiescence'): | |
35 tab.ExecuteJavaScript('console.time("");') | 33 tab.ExecuteJavaScript('console.time("");') |
36 try: | 34 try: |
37 util.WaitFor(tab.HasReachedQuiescence, 15) | 35 util.WaitFor(tab.HasReachedQuiescence, 15) |
38 except exceptions.TimeoutException: | 36 except exceptions.TimeoutException: |
39 # Some sites never reach quiesence. As this benchmark normalizes/ | 37 # Some sites never reach quiesence. As this benchmark normalizes/ |
40 # categories results, it shouldn't be necessary to reach the same | 38 # categories results, it shouldn't be necessary to reach the same |
41 # state on every run. | 39 # state on every run. |
42 pass | 40 pass |
43 | 41 |
44 tab.ExecuteJavaScript(''' | 42 tab.ExecuteJavaScript(''' |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 tokens = sum(event.tokens for event in events) | 135 tokens = sum(event.tokens for event in events) |
138 length = sum(event.length for event in events) | 136 length = sum(event.length for event in events) |
139 | 137 |
140 results.AddValue( | 138 results.AddValue( |
141 scalar.ScalarValue(page, ('parse_css_%s' % category), | 139 scalar.ScalarValue(page, ('parse_css_%s' % category), |
142 'tokens/s', 1000 / (parse_duration / tokens))) | 140 'tokens/s', 1000 / (parse_duration / tokens))) |
143 | 141 |
144 results.AddValue( | 142 results.AddValue( |
145 scalar.ScalarValue(page, ('tokenize_css_%s' % category), | 143 scalar.ScalarValue(page, ('tokenize_css_%s' % category), |
146 'char/s', 1000 / (tokenize_duration / length))) | 144 'char/s', 1000 / (tokenize_duration / length))) |
OLD | NEW |