| 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 time | 5 import time |
| 6 | 6 |
| 7 from measurements import smoothness | 7 from measurements import smoothness |
| 8 from telemetry.page import page_test | 8 from telemetry.page import page_test |
| 9 from telemetry.value import scalar | 9 from telemetry.value import scalar |
| 10 | 10 |
| 11 | 11 |
| 12 class RecordPerArea(page_test.PageTest): | 12 class RecordPerArea(page_test.PageTest): |
| 13 def __init__(self, start_wait_time=2): | 13 def __init__(self): |
| 14 super(RecordPerArea, self).__init__('', True) | 14 super(RecordPerArea, self).__init__('', True) |
| 15 self._start_wait_time = start_wait_time | 15 |
| 16 def AddCommandLineArgs(self, parser): |
| 17 parser.add_option('--start-wait-time', type='float', |
| 18 default=2, |
| 19 help='Wait time before the benchmark is started ' |
| 20 '(must be long enought to load all content)') |
| 16 | 21 |
| 17 def CustomizeBrowserOptions(self, options): | 22 def CustomizeBrowserOptions(self, options): |
| 18 smoothness.Smoothness.CustomizeBrowserOptions(options) | 23 smoothness.Smoothness.CustomizeBrowserOptions(options) |
| 19 options.AppendExtraBrowserArgs([ | 24 options.AppendExtraBrowserArgs([ |
| 20 '--enable-impl-side-painting', | 25 '--enable-impl-side-painting', |
| 21 '--enable-threaded-compositing', | 26 '--enable-threaded-compositing', |
| 22 '--enable-gpu-benchmarking' | 27 '--enable-gpu-benchmarking' |
| 23 ]) | 28 ]) |
| 24 | 29 |
| 25 def ValidateAndMeasurePage(self, page, tab, results): | 30 def ValidateAndMeasurePage(self, page, tab, results): |
| 26 # Wait until the page has loaded and come to a somewhat steady state. | 31 # Wait until the page has loaded and come to a somewhat steady state. |
| 27 # Needs to be adjusted for every device (~2 seconds for workstation). | 32 # Needs to be adjusted for every device (~2 seconds for workstation). |
| 28 time.sleep(self._start_wait_time) | 33 time.sleep(self.options.start_wait_time) |
| 29 | 34 |
| 30 # Enqueue benchmark | 35 # Enqueue benchmark |
| 31 tab.ExecuteJavaScript(""" | 36 tab.ExecuteJavaScript(""" |
| 32 window.benchmark_results = {}; | 37 window.benchmark_results = {}; |
| 33 window.benchmark_results.done = false; | 38 window.benchmark_results.done = false; |
| 34 chrome.gpuBenchmarking.runMicroBenchmark( | 39 chrome.gpuBenchmarking.runMicroBenchmark( |
| 35 "picture_record_benchmark", | 40 "picture_record_benchmark", |
| 36 function(value) { | 41 function(value) { |
| 37 window.benchmark_results.done = true; | 42 window.benchmark_results.done = true; |
| 38 window.benchmark_results.results = value; | 43 window.benchmark_results.results = value; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 all_data = tab.EvaluateJavaScript('window.benchmark_results.results') | 55 all_data = tab.EvaluateJavaScript('window.benchmark_results.results') |
| 51 for data in all_data: | 56 for data in all_data: |
| 52 width = data['width'] | 57 width = data['width'] |
| 53 height = data['height'] | 58 height = data['height'] |
| 54 area = width * height | 59 area = width * height |
| 55 time_ms = data['time_ms'] | 60 time_ms = data['time_ms'] |
| 56 | 61 |
| 57 results.AddValue(scalar.ScalarValue( | 62 results.AddValue(scalar.ScalarValue( |
| 58 results.current_page, 'area_%07d_%dx%d' % (area, width, height), | 63 results.current_page, 'area_%07d_%dx%d' % (area, width, height), |
| 59 'ms', time_ms)) | 64 'ms', time_ms)) |
| OLD | NEW |