| 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 from telemetry.core import util | 7 from telemetry.core import util |
| 8 from telemetry.core import exceptions | 8 from telemetry.core import exceptions |
| 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 def __init__(self): | 16 def __init__(self): |
| 18 super(BlinkStyle, self).__init__() | 17 super(BlinkStyle, self).__init__() |
| 19 self._controller = None | 18 self._controller = None |
| 20 | 19 |
| 21 def WillNavigateToPage(self, page, tab): | 20 def WillNavigateToPage(self, page, tab): |
| 22 self._controller = timeline_controller.TimelineController() | 21 self._controller = timeline_controller.TimelineController() |
| 23 self._controller.trace_categories = 'blink_style,blink.console' | 22 self._controller.trace_categories = 'blink_style,blink.console' |
| 24 self._controller.SetUp(page, tab) | 23 self._controller.SetUp(page, tab) |
| 25 self._controller.Start(tab) | 24 self._controller.Start(tab) |
| 26 | 25 |
| 27 def CleanUpAfterPage(self, page, tab): | 26 def CleanUpAfterPage(self, page, tab): |
| 28 if self._controller: | 27 if self._controller: |
| 29 self._controller.CleanUp(tab) | 28 self._controller.CleanUp(tab) |
| 30 | 29 |
| 31 def ValidateAndMeasurePage(self, page, tab, results): | 30 def ValidateAndMeasurePage(self, page, tab, results): |
| 32 runner = action_runner.ActionRunner(tab) | 31 tab.ExecuteJavaScript('console.time("wait-for-quiescence");') |
| 33 with runner.CreateInteraction('wait-for-quiescence'): | 32 try: |
| 34 tab.ExecuteJavaScript('console.time("");') | 33 util.WaitFor(tab.HasReachedQuiescence, 15) |
| 35 try: | 34 except exceptions.TimeoutException: |
| 36 util.WaitFor(tab.HasReachedQuiescence, 15) | 35 # Some sites never reach quiesence. As this benchmark normalizes/ |
| 37 except exceptions.TimeoutException: | 36 # categories results, it shouldn't be necessary to reach the same |
| 38 # Some sites never reach quiesence. As this benchmark normalizes/ | 37 # state on every run. |
| 39 # categories results, it shouldn't be necessary to reach the same | 38 pass |
| 40 # state on every run. | 39 tab.ExecuteJavaScript('console.timeEnd("wait-for-quiescence");') |
| 41 pass | |
| 42 | 40 |
| 43 tab.ExecuteJavaScript( | 41 tab.ExecuteJavaScript( |
| 44 'console.time("style-update");' | 42 'console.time("style-update");' |
| 45 # Occasionally documents will break the APIs we need. | 43 # Occasionally documents will break the APIs we need. |
| 46 'try {' | 44 'try {' |
| 47 # Invalidate style for the whole document. | 45 # Invalidate style for the whole document. |
| 48 ' document && (document.documentElement.lang += "z");' | 46 ' document && (document.documentElement.lang += "z");' |
| 49 # Force a style update (but not layout). | 47 # Force a style update (but not layout). |
| 50 ' getComputedStyle(document.documentElement).color;' | 48 ' getComputedStyle(document.documentElement).color;' |
| 51 '} catch (e) {}' | 49 '} catch (e) {}' |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 tokens = sum(event.tokens for event in events) | 121 tokens = sum(event.tokens for event in events) |
| 124 length = sum(event.length for event in events) | 122 length = sum(event.length for event in events) |
| 125 | 123 |
| 126 results.AddValue( | 124 results.AddValue( |
| 127 scalar.ScalarValue(page, ('parse_css_%s' % category), | 125 scalar.ScalarValue(page, ('parse_css_%s' % category), |
| 128 'tokens/s', 1000 / (parse_duration / tokens))) | 126 'tokens/s', 1000 / (parse_duration / tokens))) |
| 129 | 127 |
| 130 results.AddValue( | 128 results.AddValue( |
| 131 scalar.ScalarValue(page, ('tokenize_css_%s' % category), | 129 scalar.ScalarValue(page, ('tokenize_css_%s' % category), |
| 132 'char/s', 1000 / (tokenize_duration / length))) | 130 'char/s', 1000 / (tokenize_duration / length))) |
| OLD | NEW |