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 util | 7 from telemetry.core import util |
8 from telemetry.page import legacy_page_test | 8 from telemetry.page import legacy_page_test |
9 from telemetry.value import scalar | 9 from telemetry.value import scalar |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 self._controller.trace_categories = 'blink_style,blink.console' | 23 self._controller.trace_categories = 'blink_style,blink.console' |
24 self._controller.SetUp(page, tab) | 24 self._controller.SetUp(page, tab) |
25 self._controller.Start(tab) | 25 self._controller.Start(tab) |
26 | 26 |
27 def DidRunPage(self, platform): | 27 def DidRunPage(self, platform): |
28 if self._controller: | 28 if self._controller: |
29 self._controller.CleanUp(platform) | 29 self._controller.CleanUp(platform) |
30 | 30 |
31 def ValidateAndMeasurePage(self, page, tab, results): | 31 def ValidateAndMeasurePage(self, page, tab, results): |
32 with tab.action_runner.CreateInteraction('wait-for-quiescence'): | 32 with tab.action_runner.CreateInteraction('wait-for-quiescence'): |
33 tab.ExecuteJavaScript2('console.time("");') | 33 tab.ExecuteJavaScript('console.time("");') |
34 try: | 34 try: |
35 util.WaitFor(tab.HasReachedQuiescence, 15) | 35 util.WaitFor(tab.HasReachedQuiescence, 15) |
36 except py_utils.TimeoutException: | 36 except py_utils.TimeoutException: |
37 # Some sites never reach quiesence. As this benchmark normalizes/ | 37 # Some sites never reach quiesence. As this benchmark normalizes/ |
38 # categories results, it shouldn't be necessary to reach the same | 38 # categories results, it shouldn't be necessary to reach the same |
39 # state on every run. | 39 # state on every run. |
40 pass | 40 pass |
41 | 41 |
42 tab.ExecuteJavaScript2(''' | 42 tab.ExecuteJavaScript(''' |
43 for (var i = 0; i < 11; i++) { | 43 for (var i = 0; i < 11; i++) { |
44 var cold = i % 2 == 0; | 44 var cold = i % 2 == 0; |
45 var name = "update_style"; | 45 var name = "update_style"; |
46 if (cold) name += "_cold"; | 46 if (cold) name += "_cold"; |
47 console.time(name); | 47 console.time(name); |
48 // Occasionally documents will break the APIs we need | 48 // Occasionally documents will break the APIs we need |
49 try { | 49 try { |
50 // On cold runs, force a new StyleResolver | 50 // On cold runs, force a new StyleResolver |
51 if (cold) { | 51 if (cold) { |
52 var style = document.createElement("style"); | 52 var style = document.createElement("style"); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 tokens = sum(event.tokens for event in events) | 135 tokens = sum(event.tokens for event in events) |
136 length = sum(event.length for event in events) | 136 length = sum(event.length for event in events) |
137 | 137 |
138 results.AddValue( | 138 results.AddValue( |
139 scalar.ScalarValue(page, ('parse_css_%s' % category), | 139 scalar.ScalarValue(page, ('parse_css_%s' % category), |
140 'tokens/s', 1000 / (parse_duration / tokens))) | 140 'tokens/s', 1000 / (parse_duration / tokens))) |
141 | 141 |
142 results.AddValue( | 142 results.AddValue( |
143 scalar.ScalarValue(page, ('tokenize_css_%s' % category), | 143 scalar.ScalarValue(page, ('tokenize_css_%s' % category), |
144 'char/s', 1000 / (tokenize_duration / length))) | 144 'char/s', 1000 / (tokenize_duration / length))) |
OLD | NEW |