| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 from metrics import power | 5 from metrics import power |
| 6 | 6 |
| 7 from telemetry.core.platform import tracing_category_filter | 7 from telemetry.core.platform import tracing_category_filter |
| 8 from telemetry.core.platform import tracing_options | 8 from telemetry.core.platform import tracing_options |
| 9 from telemetry.page import page_test | 9 from telemetry.page import page_test |
| 10 from telemetry.timeline import model | 10 from telemetry.timeline import model |
| 11 from telemetry.value import scalar | 11 from telemetry.value import scalar |
| 12 | 12 |
| 13 | 13 |
| 14 class ImageDecoding(page_test.PageTest): | 14 class ImageDecoding(page_test.PageTest): |
| 15 def __init__(self): | 15 def __init__(self): |
| 16 super(ImageDecoding, self).__init__() | 16 super(ImageDecoding, self).__init__() |
| 17 self._power_metric = None | 17 self._power_metric = None |
| 18 | 18 |
| 19 def CustomizeBrowserOptions(self, options): | 19 def CustomizeBrowserOptions(self, options): |
| 20 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 20 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 21 power.PowerMetric.CustomizeBrowserOptions(options) | 21 power.PowerMetric.CustomizeBrowserOptions(options) |
| 22 | 22 |
| 23 def WillStartBrowser(self, browser): | 23 def WillStartBrowser(self, platform): |
| 24 self._power_metric = power.PowerMetric(browser) | 24 self._power_metric = power.PowerMetric(platform) |
| 25 | 25 |
| 26 def WillNavigateToPage(self, page, tab): | 26 def WillNavigateToPage(self, page, tab): |
| 27 tab.ExecuteJavaScript(""" | 27 tab.ExecuteJavaScript(""" |
| 28 if (window.chrome && | 28 if (window.chrome && |
| 29 chrome.gpuBenchmarking && | 29 chrome.gpuBenchmarking && |
| 30 chrome.gpuBenchmarking.clearImageCache) { | 30 chrome.gpuBenchmarking.clearImageCache) { |
| 31 chrome.gpuBenchmarking.clearImageCache(); | 31 chrome.gpuBenchmarking.clearImageCache(); |
| 32 } | 32 } |
| 33 """) | 33 """) |
| 34 self._power_metric.Start(page, tab) | 34 self._power_metric.Start(page, tab) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 'formats: gif, png, jpg, and webp. The image files are ' | 95 'formats: gif, png, jpg, and webp. The image files are ' |
| 96 'located at chrome/test/data/image_decoding.')) | 96 'located at chrome/test/data/image_decoding.')) |
| 97 results.AddValue(scalar.ScalarValue( | 97 results.AddValue(scalar.ScalarValue( |
| 98 results.current_page, 'ImageLoading_avg', 'ms', | 98 results.current_page, 'ImageLoading_avg', 'ms', |
| 99 tab.EvaluateJavaScript('averageLoadingTimeMs()'))) | 99 tab.EvaluateJavaScript('averageLoadingTimeMs()'))) |
| 100 | 100 |
| 101 def CleanUpAfterPage(self, page, tab): | 101 def CleanUpAfterPage(self, page, tab): |
| 102 tracing_controller = tab.browser.platform.tracing_controller | 102 tracing_controller = tab.browser.platform.tracing_controller |
| 103 if tracing_controller.is_tracing_running: | 103 if tracing_controller.is_tracing_running: |
| 104 tracing_controller.Stop() | 104 tracing_controller.Stop() |
| OLD | NEW |