Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: tools/perf/measurements/image_decoding.py

Issue 480713004: Fix the image decode telemetry perf unittest on impl side painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: imagedecode: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 17 matching lines...) Expand all
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)
35 35
36 options = tracing_options.TracingOptions() 36 options = tracing_options.TracingOptions()
37 options.enable_chrome_trace = True 37 options.enable_chrome_trace = True
38 # FIXME: bare 'devtools' is for compatibility with older reference versions 38 # FIXME: Remove the timeline category when impl-side painting is on
39 # only and may eventually be removed. 39 # everywhere.
40 category_filter = tracing_category_filter.TracingCategoryFilter( 40 category_filter = tracing_category_filter.TracingCategoryFilter(
41 'disabled-by-default-devtools.timeline*') 41 'disabled-by-default-devtools.timeline')
42 42
43 # FIXME: Remove webkit.console when blink.console lands in chromium and 43 # FIXME: Remove webkit.console when blink.console lands in chromium and
44 # the ref builds are updated. crbug.com/386847 44 # the ref builds are updated. crbug.com/386847
45 # FIXME: Remove the devtools.timeline category when impl-side painting is
46 # on everywhere.
45 categories = [ 47 categories = [
46 'devtools', 48 'blink',
49 'devtools.timeline',
47 'webkit.console', 50 'webkit.console',
48 'blink.console' 51 'blink.console'
49 ] 52 ]
50 for c in categories: 53 for c in categories:
51 category_filter.AddIncludedCategory(c) 54 category_filter.AddIncludedCategory(c)
52 tab.browser.platform.tracing_controller.Start(options, category_filter) 55 tab.browser.platform.tracing_controller.Start(options, category_filter)
53 56
54 def StopBrowserAfterPage(self, browser, page): 57 def StopBrowserAfterPage(self, browser, page):
55 return not browser.tabs[0].ExecuteJavaScript(""" 58 return not browser.tabs[0].ExecuteJavaScript("""
56 window.chrome && 59 window.chrome &&
57 chrome.gpuBenchmarking && 60 chrome.gpuBenchmarking &&
58 chrome.gpuBenchmarking.clearImageCache; 61 chrome.gpuBenchmarking.clearImageCache;
59 """) 62 """)
60 63
61 def ValidateAndMeasurePage(self, page, tab, results): 64 def ValidateAndMeasurePage(self, page, tab, results):
62 timeline_data = tab.browser.platform.tracing_controller.Stop() 65 timeline_data = tab.browser.platform.tracing_controller.Stop()
63 timeline_model = model.TimelineModel(timeline_data) 66 timeline_model = model.TimelineModel(timeline_data)
64 self._power_metric.Stop(page, tab) 67 self._power_metric.Stop(page, tab)
65 self._power_metric.AddResults(tab, results) 68 self._power_metric.AddResults(tab, results)
66 69
67 def _IsDone(): 70 def _IsDone():
68 return tab.EvaluateJavaScript('isDone') 71 return tab.EvaluateJavaScript('isDone')
69 72
70 decode_image_events = timeline_model.GetAllEventsOfName('Decode Image') 73 decode_image_events = timeline_model.GetAllEventsOfName(
74 'ImageFrameGenerator::decode')
75 # FIXME: Remove this when impl-side painting is on everywhere.
76 if not decode_image_events:
77 decode_image_events = timeline_model.GetAllEventsOfName('Decode Image')
71 78
72 # If it is a real image page, then store only the last-minIterations 79 # If it is a real image page, then store only the last-minIterations
73 # decode tasks. 80 # decode tasks.
74 if (hasattr(page, 81 if (hasattr(page,
75 'image_decoding_measurement_limit_results_to_min_iterations') and 82 'image_decoding_measurement_limit_results_to_min_iterations') and
76 page.image_decoding_measurement_limit_results_to_min_iterations): 83 page.image_decoding_measurement_limit_results_to_min_iterations):
77 assert _IsDone() 84 assert _IsDone()
78 min_iterations = tab.EvaluateJavaScript('minIterations') 85 min_iterations = tab.EvaluateJavaScript('minIterations')
79 decode_image_events = decode_image_events[-min_iterations:] 86 decode_image_events = decode_image_events[-min_iterations:]
80 87
81 durations = [d.duration for d in decode_image_events] 88 durations = [d.duration for d in decode_image_events]
82 assert durations, 'Failed to find "Decode Image" trace events.' 89 assert durations, 'Failed to find image decode trace events.'
83 90
84 image_decoding_avg = sum(durations) / len(durations) 91 image_decoding_avg = sum(durations) / len(durations)
85 results.AddValue(scalar.ScalarValue( 92 results.AddValue(scalar.ScalarValue(
86 results.current_page, 'ImageDecoding_avg', 'ms', image_decoding_avg, 93 results.current_page, 'ImageDecoding_avg', 'ms', image_decoding_avg,
87 description='Average decode time for images in 4 different ' 94 description='Average decode time for images in 4 different '
88 'formats: gif, png, jpg, and webp. The image files are ' 95 'formats: gif, png, jpg, and webp. The image files are '
89 'located at chrome/test/data/image_decoding.')) 96 'located at chrome/test/data/image_decoding.'))
90 results.AddValue(scalar.ScalarValue( 97 results.AddValue(scalar.ScalarValue(
91 results.current_page, 'ImageLoading_avg', 'ms', 98 results.current_page, 'ImageLoading_avg', 'ms',
92 tab.EvaluateJavaScript('averageLoadingTimeMs()'))) 99 tab.EvaluateJavaScript('averageLoadingTimeMs()')))
93 100
94 def CleanUpAfterPage(self, page, tab): 101 def CleanUpAfterPage(self, page, tab):
95 tracing_controller = tab.browser.platform.tracing_controller 102 tracing_controller = tab.browser.platform.tracing_controller
96 if tracing_controller.is_tracing_running: 103 if tracing_controller.is_tracing_running:
97 tracing_controller.Stop() 104 tracing_controller.Stop()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698