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