OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import time |
| 6 from telemetry.core.util import TimeoutException |
| 7 from telemetry.page import page_measurement |
| 8 |
| 9 class NewRasterizeAndRecord(page_measurement.PageMeasurement): |
| 10 def __init__(self): |
| 11 super(NewRasterizeAndRecord, self).__init__('', True) |
| 12 |
| 13 def AddCommandLineOptions(self, parser): |
| 14 parser.add_option('--start-wait-time', dest='start_wait_time', |
| 15 default=2, |
| 16 help='Wait time before the benchmark is started ' + |
| 17 '(must be long enought to load all content)') |
| 18 parser.add_option('--rasterize_repeat', dest='rasterize_repeat', |
| 19 default=100, |
| 20 help='Repeat each raster this many times. Increase ' + |
| 21 'this value to reduce variance.') |
| 22 parser.add_option('--record_repeat', dest='record_repeat', |
| 23 default=100, |
| 24 help='Repeat each record this many times. Increase ' + |
| 25 'this value to reduce variance.') |
| 26 |
| 27 def CustomizeBrowserOptions(self, options): |
| 28 options.AppendExtraBrowserArgs([ |
| 29 '--enable-impl-side-painting', |
| 30 '--force-compositing-mode', |
| 31 '--enable-threaded-compositing', |
| 32 '--enable-gpu-benchmarking' |
| 33 ]) |
| 34 |
| 35 def MeasurePage(self, page, tab, results): |
| 36 try: |
| 37 tab.WaitForJavaScriptExpression("document.readyState == 'complete'", 10) |
| 38 except TimeoutException: |
| 39 pass |
| 40 time.sleep(float(self.options.start_wait_time)) |
| 41 |
| 42 record_repeat = self.options.record_repeat |
| 43 rasterize_repeat = self.options.rasterize_repeat |
| 44 # Enqueue benchmark |
| 45 tab.ExecuteJavaScript(""" |
| 46 window.benchmark_results = {}; |
| 47 window.benchmark_results.done = false; |
| 48 chrome.gpuBenchmarking.runMicroBenchmark( |
| 49 "rasterize_and_record_benchmark", |
| 50 function(value) { |
| 51 window.benchmark_results.done = true; |
| 52 window.benchmark_results.results = value; |
| 53 }, { |
| 54 "record_repeat_count": """ + str(record_repeat) + """, |
| 55 "rasterize_repeat_count": """ + str(rasterize_repeat) + """ |
| 56 }); |
| 57 """) |
| 58 |
| 59 tab.WaitForJavaScriptExpression('window.benchmark_results.done', 300) |
| 60 |
| 61 data = tab.EvaluateJavaScript('window.benchmark_results.results') |
| 62 |
| 63 pixels_recorded = data['pixels_recorded'] |
| 64 record_time = data['record_time_ms'] |
| 65 pixels_rasterized = data['pixels_rasterized'] |
| 66 rasterize_time = data['rasterize_time_ms'] |
| 67 |
| 68 results.Add('pixels_recorded', '', pixels_recorded) |
| 69 results.Add('record_time', 'ms', record_time) |
| 70 results.Add('pixels_rasterized', '', pixels_rasterized) |
| 71 results.Add('rasterize_time', 'ms', rasterize_time) |
| 72 |
OLD | NEW |