| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 logging | |
| 6 import sys | |
| 7 import time | 5 import time |
| 8 | 6 |
| 9 from metrics import rendering_stats | 7 from metrics import rendering_stats |
| 10 from telemetry.page import page_measurement | 8 from telemetry.page import page_measurement |
| 9 from telemetry.page import page_test |
| 11 import telemetry.core.timeline.bounds as timeline_bounds | 10 import telemetry.core.timeline.bounds as timeline_bounds |
| 12 from telemetry.core.timeline.model import MarkerMismatchError | 11 from telemetry.core.timeline.model import MarkerMismatchError |
| 13 from telemetry.core.timeline.model import MarkerOverlapError | 12 from telemetry.core.timeline.model import MarkerOverlapError |
| 14 | 13 |
| 15 TIMELINE_MARKER = 'RasterizeAndRecord' | 14 TIMELINE_MARKER = 'RasterizeAndRecord' |
| 16 | 15 |
| 17 | 16 |
| 18 class RasterizeAndRecord(page_measurement.PageMeasurement): | 17 class RasterizeAndRecord(page_measurement.PageMeasurement): |
| 19 def __init__(self): | 18 def __init__(self): |
| 20 super(RasterizeAndRecord, self).__init__('', True) | 19 super(RasterizeAndRecord, self).__init__('', True) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 52 |
| 54 def DidStartBrowser(self, browser): | 53 def DidStartBrowser(self, browser): |
| 55 # Check if the we actually have threaded forced compositing enabled. | 54 # Check if the we actually have threaded forced compositing enabled. |
| 56 system_info = browser.GetSystemInfo() | 55 system_info = browser.GetSystemInfo() |
| 57 if (system_info.gpu.feature_status | 56 if (system_info.gpu.feature_status |
| 58 and system_info.gpu.feature_status.get( | 57 and system_info.gpu.feature_status.get( |
| 59 'compositing', None) == 'enabled_force_threaded'): | 58 'compositing', None) == 'enabled_force_threaded'): |
| 60 self._compositing_features_enabled = True | 59 self._compositing_features_enabled = True |
| 61 | 60 |
| 62 def MeasurePage(self, page, tab, results): | 61 def MeasurePage(self, page, tab, results): |
| 63 # Exit if threaded forced compositing is not enabled. | 62 # Throw and exception if threaded forced compositing is not enabled. |
| 64 if (not self._compositing_features_enabled): | 63 if (not self._compositing_features_enabled): |
| 65 logging.warning('Warning: compositing feature status unknown or not '+ | 64 raise page_test.TestNotSupportedOnPlatformFailure( |
| 66 'forced and threaded. Skipping measurement.') | 65 'Compositing feature status unknown or not '+ |
| 67 sys.exit(0) | 66 'forced and threaded. Skipping measurement.') |
| 68 | 67 |
| 69 # Rasterize only what's visible. | 68 # Rasterize only what's visible. |
| 70 tab.ExecuteJavaScript( | 69 tab.ExecuteJavaScript( |
| 71 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();') | 70 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();') |
| 72 | 71 |
| 73 # Wait until the page has loaded and come to a somewhat steady state. | 72 # Wait until the page has loaded and come to a somewhat steady state. |
| 74 # Needs to be adjusted for every device (~2 seconds for workstation). | 73 # Needs to be adjusted for every device (~2 seconds for workstation). |
| 75 time.sleep(float(self.options.start_wait_time)) | 74 time.sleep(float(self.options.start_wait_time)) |
| 76 | 75 |
| 77 # Render one frame before we start gathering a trace. On some pages, the | 76 # Render one frame before we start gathering a trace. On some pages, the |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 stats = rendering_stats.RenderingStats(renderer_process, timeline_ranges) | 112 stats = rendering_stats.RenderingStats(renderer_process, timeline_ranges) |
| 114 | 113 |
| 115 results.Add('rasterize_time', 'ms', | 114 results.Add('rasterize_time', 'ms', |
| 116 max(stats.rasterize_time)) | 115 max(stats.rasterize_time)) |
| 117 results.Add('record_time', 'ms', | 116 results.Add('record_time', 'ms', |
| 118 max(stats.record_time)) | 117 max(stats.record_time)) |
| 119 results.Add('rasterized_pixels', 'pixels', | 118 results.Add('rasterized_pixels', 'pixels', |
| 120 max(stats.rasterized_pixel_count)) | 119 max(stats.rasterized_pixel_count)) |
| 121 results.Add('recorded_pixels', 'pixels', | 120 results.Add('recorded_pixels', 'pixels', |
| 122 max(stats.recorded_pixel_count)) | 121 max(stats.recorded_pixel_count)) |
| OLD | NEW |