| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import sys | 5 import sys |
| 6 import time | 6 import time |
| 7 | 7 |
| 8 from telemetry.core.util import TimeoutException | 8 from telemetry.core.util import TimeoutException |
| 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 | 12 |
| 13 class RasterizeAndRecordMicro(page_test.PageTest): | 13 class RasterizeAndRecordMicro(page_test.PageTest): |
| 14 def __init__(self): | 14 def __init__(self, start_wait_time=2, rasterize_repeat=100, record_repeat=100, |
| 15 timeout=120, report_detailed_results=False): |
| 15 super(RasterizeAndRecordMicro, self).__init__('') | 16 super(RasterizeAndRecordMicro, self).__init__('') |
| 16 self._chrome_branch_number = None | 17 self._chrome_branch_number = None |
| 17 | 18 self._start_wait_time = start_wait_time |
| 18 @classmethod | 19 self._rasterize_repeat = rasterize_repeat |
| 19 def AddCommandLineArgs(cls, parser): | 20 self._record_repeat = record_repeat |
| 20 parser.add_option('--start-wait-time', type='float', | 21 self._timeout = timeout |
| 21 default=2, | 22 self._report_detailed_results = report_detailed_results |
| 22 help='Wait time before the benchmark is started ' | |
| 23 '(must be long enought to load all content)') | |
| 24 parser.add_option('--rasterize-repeat', type='int', | |
| 25 default=100, | |
| 26 help='Repeat each raster this many times. Increase ' | |
| 27 'this value to reduce variance.') | |
| 28 parser.add_option('--record-repeat', type='int', | |
| 29 default=100, | |
| 30 help='Repeat each record this many times. Increase ' | |
| 31 'this value to reduce variance.') | |
| 32 parser.add_option('--timeout', type='int', | |
| 33 default=120, | |
| 34 help='The length of time to wait for the micro ' | |
| 35 'benchmark to finish, expressed in seconds.') | |
| 36 parser.add_option('--report-detailed-results', | |
| 37 action='store_true', | |
| 38 help='Whether to report additional detailed results.') | |
| 39 | 23 |
| 40 def CustomizeBrowserOptions(self, options): | 24 def CustomizeBrowserOptions(self, options): |
| 41 options.AppendExtraBrowserArgs([ | 25 options.AppendExtraBrowserArgs([ |
| 42 '--enable-impl-side-painting', | 26 '--enable-impl-side-painting', |
| 43 '--enable-threaded-compositing', | 27 '--enable-threaded-compositing', |
| 44 '--enable-gpu-benchmarking' | 28 '--enable-gpu-benchmarking' |
| 45 ]) | 29 ]) |
| 46 | 30 |
| 47 def DidStartBrowser(self, browser): | 31 def DidStartBrowser(self, browser): |
| 48 # TODO(vmpstr): Remove this temporary workaround when reference build has | 32 # TODO(vmpstr): Remove this temporary workaround when reference build has |
| 49 # been updated to branch 1713 or later. | 33 # been updated to branch 1713 or later. |
| 50 backend = browser._browser_backend # pylint: disable=W0212 | 34 backend = browser._browser_backend # pylint: disable=W0212 |
| 51 self._chrome_branch_number = getattr(backend, 'chrome_branch_number', None) | 35 self._chrome_branch_number = getattr(backend, 'chrome_branch_number', None) |
| 52 if (not self._chrome_branch_number or | 36 if (not self._chrome_branch_number or |
| 53 (sys.platform != 'android' and self._chrome_branch_number < 1713)): | 37 (sys.platform != 'android' and self._chrome_branch_number < 1713)): |
| 54 raise page_test.TestNotSupportedOnPlatformFailure( | 38 raise page_test.TestNotSupportedOnPlatformFailure( |
| 55 'rasterize_and_record_micro requires Chrome branch 1713 ' | 39 'rasterize_and_record_micro requires Chrome branch 1713 ' |
| 56 'or later. Skipping measurement.') | 40 'or later. Skipping measurement.') |
| 57 | 41 |
| 58 def ValidateAndMeasurePage(self, page, tab, results): | 42 def ValidateAndMeasurePage(self, page, tab, results): |
| 59 try: | 43 try: |
| 60 tab.WaitForDocumentReadyStateToBeComplete() | 44 tab.WaitForDocumentReadyStateToBeComplete() |
| 61 except TimeoutException: | 45 except TimeoutException: |
| 62 pass | 46 pass |
| 63 time.sleep(self.options.start_wait_time) | 47 time.sleep(self._start_wait_time) |
| 64 | 48 |
| 65 record_repeat = self.options.record_repeat | |
| 66 rasterize_repeat = self.options.rasterize_repeat | |
| 67 # Enqueue benchmark | 49 # Enqueue benchmark |
| 68 tab.ExecuteJavaScript(""" | 50 tab.ExecuteJavaScript(""" |
| 69 window.benchmark_results = {}; | 51 window.benchmark_results = {}; |
| 70 window.benchmark_results.done = false; | 52 window.benchmark_results.done = false; |
| 71 window.benchmark_results.id = | 53 window.benchmark_results.id = |
| 72 chrome.gpuBenchmarking.runMicroBenchmark( | 54 chrome.gpuBenchmarking.runMicroBenchmark( |
| 73 "rasterize_and_record_benchmark", | 55 "rasterize_and_record_benchmark", |
| 74 function(value) { | 56 function(value) { |
| 75 window.benchmark_results.done = true; | 57 window.benchmark_results.done = true; |
| 76 window.benchmark_results.results = value; | 58 window.benchmark_results.results = value; |
| 77 }, { | 59 }, { |
| 78 "record_repeat_count": """ + str(record_repeat) + """, | 60 "record_repeat_count": %i, |
| 79 "rasterize_repeat_count": """ + str(rasterize_repeat) + """ | 61 "rasterize_repeat_count": %i |
| 80 }); | 62 }); |
| 81 """) | 63 """ % (self._record_repeat, self._rasterize_repeat)) |
| 82 | 64 |
| 83 benchmark_id = tab.EvaluateJavaScript('window.benchmark_results.id') | 65 benchmark_id = tab.EvaluateJavaScript('window.benchmark_results.id') |
| 84 if (not benchmark_id): | 66 if (not benchmark_id): |
| 85 raise page_test.MeasurementFailure( | 67 raise page_test.MeasurementFailure( |
| 86 'Failed to schedule rasterize_and_record_micro') | 68 'Failed to schedule rasterize_and_record_micro') |
| 87 | 69 |
| 88 tab.WaitForJavaScriptExpression( | 70 tab.WaitForJavaScriptExpression( |
| 89 'window.benchmark_results.done', self.options.timeout) | 71 'window.benchmark_results.done', self._timeout) |
| 90 | 72 |
| 91 data = tab.EvaluateJavaScript('window.benchmark_results.results') | 73 data = tab.EvaluateJavaScript('window.benchmark_results.results') |
| 92 | 74 |
| 93 pixels_recorded = data['pixels_recorded'] | 75 pixels_recorded = data['pixels_recorded'] |
| 94 record_time = data['record_time_ms'] | 76 record_time = data['record_time_ms'] |
| 95 pixels_rasterized = data['pixels_rasterized'] | 77 pixels_rasterized = data['pixels_rasterized'] |
| 96 rasterize_time = data['rasterize_time_ms'] | 78 rasterize_time = data['rasterize_time_ms'] |
| 97 | 79 |
| 98 results.AddValue(scalar.ScalarValue( | 80 results.AddValue(scalar.ScalarValue( |
| 99 results.current_page, 'pixels_recorded', 'pixels', pixels_recorded)) | 81 results.current_page, 'pixels_recorded', 'pixels', pixels_recorded)) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 110 sys.platform == 'android'): | 92 sys.platform == 'android'): |
| 111 record_time_sk_null_canvas = data['record_time_sk_null_canvas_ms'] | 93 record_time_sk_null_canvas = data['record_time_sk_null_canvas_ms'] |
| 112 record_time_painting_disabled = data['record_time_painting_disabled_ms'] | 94 record_time_painting_disabled = data['record_time_painting_disabled_ms'] |
| 113 results.AddValue(scalar.ScalarValue( | 95 results.AddValue(scalar.ScalarValue( |
| 114 results.current_page, 'record_time_sk_null_canvas', 'ms', | 96 results.current_page, 'record_time_sk_null_canvas', 'ms', |
| 115 record_time_sk_null_canvas)) | 97 record_time_sk_null_canvas)) |
| 116 results.AddValue(scalar.ScalarValue( | 98 results.AddValue(scalar.ScalarValue( |
| 117 results.current_page, 'record_time_painting_disabled', 'ms', | 99 results.current_page, 'record_time_painting_disabled', 'ms', |
| 118 record_time_painting_disabled)) | 100 record_time_painting_disabled)) |
| 119 | 101 |
| 120 if self.options.report_detailed_results: | 102 if self._report_detailed_results: |
| 121 pixels_rasterized_with_non_solid_color = \ | 103 pixels_rasterized_with_non_solid_color = \ |
| 122 data['pixels_rasterized_with_non_solid_color'] | 104 data['pixels_rasterized_with_non_solid_color'] |
| 123 pixels_rasterized_as_opaque = \ | 105 pixels_rasterized_as_opaque = \ |
| 124 data['pixels_rasterized_as_opaque'] | 106 data['pixels_rasterized_as_opaque'] |
| 125 total_layers = data['total_layers'] | 107 total_layers = data['total_layers'] |
| 126 total_picture_layers = data['total_picture_layers'] | 108 total_picture_layers = data['total_picture_layers'] |
| 127 total_picture_layers_with_no_content = \ | 109 total_picture_layers_with_no_content = \ |
| 128 data['total_picture_layers_with_no_content'] | 110 data['total_picture_layers_with_no_content'] |
| 129 total_picture_layers_off_screen = \ | 111 total_picture_layers_off_screen = \ |
| 130 data['total_picture_layers_off_screen'] | 112 data['total_picture_layers_off_screen'] |
| 131 | 113 |
| 132 results.AddValue(scalar.ScalarValue( | 114 results.AddValue(scalar.ScalarValue( |
| 133 results.current_page, 'pixels_rasterized_with_non_solid_color', | 115 results.current_page, 'pixels_rasterized_with_non_solid_color', |
| 134 'pixels', pixels_rasterized_with_non_solid_color)) | 116 'pixels', pixels_rasterized_with_non_solid_color)) |
| 135 results.AddValue(scalar.ScalarValue( | 117 results.AddValue(scalar.ScalarValue( |
| 136 results.current_page, 'pixels_rasterized_as_opaque', 'pixels', | 118 results.current_page, 'pixels_rasterized_as_opaque', 'pixels', |
| 137 pixels_rasterized_as_opaque)) | 119 pixels_rasterized_as_opaque)) |
| 138 results.AddValue(scalar.ScalarValue( | 120 results.AddValue(scalar.ScalarValue( |
| 139 results.current_page, 'total_layers', 'count', total_layers)) | 121 results.current_page, 'total_layers', 'count', total_layers)) |
| 140 results.AddValue(scalar.ScalarValue( | 122 results.AddValue(scalar.ScalarValue( |
| 141 results.current_page, 'total_picture_layers', 'count', | 123 results.current_page, 'total_picture_layers', 'count', |
| 142 total_picture_layers)) | 124 total_picture_layers)) |
| 143 results.AddValue(scalar.ScalarValue( | 125 results.AddValue(scalar.ScalarValue( |
| 144 results.current_page, 'total_picture_layers_with_no_content', 'count', | 126 results.current_page, 'total_picture_layers_with_no_content', 'count', |
| 145 total_picture_layers_with_no_content)) | 127 total_picture_layers_with_no_content)) |
| 146 results.AddValue(scalar.ScalarValue( | 128 results.AddValue(scalar.ScalarValue( |
| 147 results.current_page, 'total_picture_layers_off_screen', 'count', | 129 results.current_page, 'total_picture_layers_off_screen', 'count', |
| 148 total_picture_layers_off_screen)) | 130 total_picture_layers_off_screen)) |
| OLD | NEW |