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