| 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 itertools import starmap | 5 from itertools import starmap |
| 6 from collections import defaultdict | 6 from collections import defaultdict |
| 7 | |
| 8 from telemetry.core import util | 7 from telemetry.core import util |
| 8 from telemetry.core import exceptions |
| 9 from telemetry.page import page_test | 9 from telemetry.page import page_test |
| 10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
| 11 | 11 |
| 12 from measurements import timeline_controller | 12 from measurements import timeline_controller |
| 13 | 13 |
| 14 | 14 |
| 15 class BlinkStyle(page_test.PageTest): | 15 class BlinkStyle(page_test.PageTest): |
| 16 def __init__(self): | 16 def __init__(self): |
| 17 super(BlinkStyle, self).__init__() | 17 super(BlinkStyle, self).__init__() |
| 18 self._controller = None | 18 self._controller = None |
| 19 | 19 |
| 20 def WillNavigateToPage(self, page, tab): | 20 def WillNavigateToPage(self, page, tab): |
| 21 self._controller = timeline_controller.TimelineController() | 21 self._controller = timeline_controller.TimelineController() |
| 22 self._controller.trace_categories = 'blink,benchmark,blink.console' | 22 self._controller.trace_categories = 'blink_style,blink.console' |
| 23 self._controller.SetUp(page, tab) | 23 self._controller.SetUp(page, tab) |
| 24 self._controller.Start(tab) | 24 self._controller.Start(tab) |
| 25 | 25 |
| 26 def CleanUpAfterPage(self, page, tab): | 26 def CleanUpAfterPage(self, page, tab): |
| 27 if self._controller: | 27 if self._controller: |
| 28 self._controller.CleanUp(tab) | 28 self._controller.CleanUp(tab) |
| 29 | 29 |
| 30 def ValidateAndMeasurePage(self, page, tab, results): | 30 def ValidateAndMeasurePage(self, page, tab, results): |
| 31 tab.WaitForDocumentReadyStateToBeComplete() | 31 tab.ExecuteJavaScript('console.time("wait-for-quiescence");') |
| 32 if not util.WaitFor(tab.HasReachedQuiescence, 30): | 32 try: |
| 33 raise page_test.MeasurementFailure('Failed to reach quiesence.') | 33 util.WaitFor(tab.HasReachedQuiescence, 15) |
| 34 except exceptions.TimeoutException: |
| 35 pass |
| 36 tab.ExecuteJavaScript('console.timeEnd("wait-for-quiescence");') |
| 34 | 37 |
| 35 tab.ExecuteJavaScript( | 38 tab.ExecuteJavaScript( |
| 36 'console.time("style-update");' | 39 'console.time("style-update");' |
| 37 # Occasionally documents will break the APIs we need. | 40 # Occasionally documents will break the APIs we need. |
| 38 'try {' | 41 'try {' |
| 39 # Invalidate style for the whole document. | 42 # Invalidate style for the whole document. |
| 40 ' document && (document.documentElement.lang += "z");' | 43 ' document && (document.documentElement.lang += "z");' |
| 41 # Force a style update (but not layout). | 44 # Force a style update (but not layout). |
| 42 ' getComputedStyle(document.documentElement).color;' | 45 ' getComputedStyle(document.documentElement).color;' |
| 43 '} catch (e) {}' | 46 '} catch (e) {}' |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 tokens = sum(event.tokens for event in events) | 115 tokens = sum(event.tokens for event in events) |
| 113 length = sum(event.length for event in events) | 116 length = sum(event.length for event in events) |
| 114 | 117 |
| 115 results.AddValue( | 118 results.AddValue( |
| 116 scalar.ScalarValue(page, ('parse_css_%s' % category), | 119 scalar.ScalarValue(page, ('parse_css_%s' % category), |
| 117 'tokens/s', 1000 / (parse_duration / tokens))) | 120 'tokens/s', 1000 / (parse_duration / tokens))) |
| 118 | 121 |
| 119 results.AddValue( | 122 results.AddValue( |
| 120 scalar.ScalarValue(page, ('tokenize_css_%s' % category), | 123 scalar.ScalarValue(page, ('tokenize_css_%s' % category), |
| 121 'char/s', 1000 / (tokenize_duration / length))) | 124 'char/s', 1000 / (tokenize_duration / length))) |
| OLD | NEW |