Modify rasterize_and_record for DisplayItemList recording.
[chromium-blink-merge.git] / tools / perf / measurements / rasterize_and_record_micro.py
blobf278ff66b55c6e75240fc487efe8fde45c1bd0b9
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.
5 import sys
6 import time
8 from telemetry.core.util import TimeoutException
9 from telemetry.page import page_test
10 from telemetry.value import scalar
13 class RasterizeAndRecordMicro(page_test.PageTest):
14 def __init__(self, start_wait_time=2, rasterize_repeat=100, record_repeat=100,
15 timeout=120, report_detailed_results=False):
16 super(RasterizeAndRecordMicro, self).__init__('')
17 self._chrome_branch_number = None
18 self._start_wait_time = start_wait_time
19 self._rasterize_repeat = rasterize_repeat
20 self._record_repeat = record_repeat
21 self._timeout = timeout
22 self._report_detailed_results = report_detailed_results
24 def CustomizeBrowserOptions(self, options):
25 options.AppendExtraBrowserArgs([
26 '--enable-impl-side-painting',
27 '--enable-threaded-compositing',
28 '--enable-gpu-benchmarking'
31 def ValidateAndMeasurePage(self, page, tab, results):
32 try:
33 tab.WaitForDocumentReadyStateToBeComplete()
34 except TimeoutException:
35 pass
36 time.sleep(self._start_wait_time)
38 # Enqueue benchmark
39 tab.ExecuteJavaScript("""
40 window.benchmark_results = {};
41 window.benchmark_results.done = false;
42 window.benchmark_results.id =
43 chrome.gpuBenchmarking.runMicroBenchmark(
44 "rasterize_and_record_benchmark",
45 function(value) {
46 window.benchmark_results.done = true;
47 window.benchmark_results.results = value;
48 }, {
49 "record_repeat_count": %i,
50 "rasterize_repeat_count": %i
51 });
52 """ % (self._record_repeat, self._rasterize_repeat))
54 benchmark_id = tab.EvaluateJavaScript('window.benchmark_results.id')
55 if (not benchmark_id):
56 raise page_test.MeasurementFailure(
57 'Failed to schedule rasterize_and_record_micro')
59 tab.WaitForJavaScriptExpression(
60 'window.benchmark_results.done', self._timeout)
62 data = tab.EvaluateJavaScript('window.benchmark_results.results')
64 pixels_recorded = data['pixels_recorded']
65 record_time = data['record_time_ms']
66 pixels_rasterized = data['pixels_rasterized']
67 rasterize_time = data['rasterize_time_ms']
68 # TODO(schenney): Remove this workaround when reference builds get past
69 # the change that adds this comment.
70 if ('picture_memory_usage' in data):
71 picture_memory_usage = data['picture_memory_usage']
72 else:
73 picture_memory_usage = 0
75 results.AddValue(scalar.ScalarValue(
76 results.current_page, 'pixels_recorded', 'pixels', pixels_recorded))
77 results.AddValue(scalar.ScalarValue(
78 results.current_page, 'pixels_rasterized', 'pixels', pixels_rasterized))
79 results.AddValue(scalar.ScalarValue(
80 results.current_page, 'rasterize_time', 'ms', rasterize_time))
81 results.AddValue(scalar.ScalarValue(
82 results.current_page, 'viewport_picture_size', 'bytes',
83 picture_memory_usage))
84 results.AddValue(scalar.ScalarValue(
85 results.current_page, 'record_time', 'ms', record_time))
87 record_time_sk_null_canvas = data['record_time_sk_null_canvas_ms']
88 record_time_painting_disabled = data['record_time_painting_disabled_ms']
89 # TODO(schenney): Remove this workaround when reference builds get past
90 # the change that adds this comment.
91 if ('record_time_caching_disabled_ms' in data):
92 record_time_caching_disabled = data['record_time_caching_disabled_ms']
93 else:
94 record_time_caching_disabled = 0
95 results.AddValue(scalar.ScalarValue(
96 results.current_page, 'record_time_sk_null_canvas', 'ms',
97 record_time_sk_null_canvas))
98 results.AddValue(scalar.ScalarValue(
99 results.current_page, 'record_time_painting_disabled', 'ms',
100 record_time_painting_disabled))
101 results.AddValue(scalar.ScalarValue(
102 results.current_page, 'record_time_caching_disabled', 'ms',
103 record_time_caching_disabled))
105 if self._report_detailed_results:
106 pixels_rasterized_with_non_solid_color = \
107 data['pixels_rasterized_with_non_solid_color']
108 pixels_rasterized_as_opaque = \
109 data['pixels_rasterized_as_opaque']
110 total_layers = data['total_layers']
111 total_picture_layers = data['total_picture_layers']
112 total_picture_layers_with_no_content = \
113 data['total_picture_layers_with_no_content']
114 total_picture_layers_off_screen = \
115 data['total_picture_layers_off_screen']
116 # TODO(schenney): Remove this workaround when reference builds get past
117 # the change that adds this comment.
118 if ('total_pictures_in_pile_size' in data):
119 total_pictures_in_pile_size = data['total_pictures_in_pile_size']
120 else:
121 total_pictures_in_pile_size = 0
123 results.AddValue(scalar.ScalarValue(
124 results.current_page, 'total_size_of_pictures_in_piles', 'bytes',
125 total_pictures_in_pile_size))
126 results.AddValue(scalar.ScalarValue(
127 results.current_page, 'pixels_rasterized_with_non_solid_color',
128 'pixels', pixels_rasterized_with_non_solid_color))
129 results.AddValue(scalar.ScalarValue(
130 results.current_page, 'pixels_rasterized_as_opaque', 'pixels',
131 pixels_rasterized_as_opaque))
132 results.AddValue(scalar.ScalarValue(
133 results.current_page, 'total_layers', 'count', total_layers))
134 results.AddValue(scalar.ScalarValue(
135 results.current_page, 'total_picture_layers', 'count',
136 total_picture_layers))
137 results.AddValue(scalar.ScalarValue(
138 results.current_page, 'total_picture_layers_with_no_content', 'count',
139 total_picture_layers_with_no_content))
140 results.AddValue(scalar.ScalarValue(
141 results.current_page, 'total_picture_layers_off_screen', 'count',
142 total_picture_layers_off_screen))