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.
7 from telemetry
.core
import exceptions
8 from telemetry
.page
import page_test
9 from telemetry
.value
import scalar
12 class RasterizeAndRecordMicro(page_test
.PageTest
):
13 def __init__(self
, start_wait_time
=2, rasterize_repeat
=100, record_repeat
=100,
14 timeout
=120, report_detailed_results
=False):
15 super(RasterizeAndRecordMicro
, self
).__init
__()
16 self
._chrome
_branch
_number
= None
17 self
._start
_wait
_time
= start_wait_time
18 self
._rasterize
_repeat
= rasterize_repeat
19 self
._record
_repeat
= record_repeat
20 self
._timeout
= timeout
21 self
._report
_detailed
_results
= report_detailed_results
23 def CustomizeBrowserOptions(self
, options
):
24 options
.AppendExtraBrowserArgs([
25 '--enable-impl-side-painting',
26 '--enable-threaded-compositing',
27 '--enable-gpu-benchmarking'
30 def ValidateAndMeasurePage(self
, page
, tab
, results
):
32 tab
.WaitForDocumentReadyStateToBeComplete()
33 except exceptions
.TimeoutException
:
35 time
.sleep(self
._start
_wait
_time
)
38 tab
.ExecuteJavaScript("""
39 window.benchmark_results = {};
40 window.benchmark_results.done = false;
41 window.benchmark_results.id =
42 chrome.gpuBenchmarking.runMicroBenchmark(
43 "rasterize_and_record_benchmark",
45 window.benchmark_results.done = true;
46 window.benchmark_results.results = value;
48 "record_repeat_count": %i,
49 "rasterize_repeat_count": %i
51 """ % (self
._record
_repeat
, self
._rasterize
_repeat
))
53 benchmark_id
= tab
.EvaluateJavaScript('window.benchmark_results.id')
55 raise page_test
.MeasurementFailure(
56 'Failed to schedule rasterize_and_record_micro')
58 tab
.WaitForJavaScriptExpression(
59 'window.benchmark_results.done', self
._timeout
)
61 data
= tab
.EvaluateJavaScript('window.benchmark_results.results')
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 # TODO(schenney): Remove this workaround when reference builds get past
68 # the change that adds this comment.
69 if 'picture_memory_usage' in data
:
70 picture_memory_usage
= data
['picture_memory_usage']
72 picture_memory_usage
= 0
74 results
.AddValue(scalar
.ScalarValue(
75 results
.current_page
, 'pixels_recorded', 'pixels', pixels_recorded
))
76 results
.AddValue(scalar
.ScalarValue(
77 results
.current_page
, 'pixels_rasterized', 'pixels', pixels_rasterized
))
78 results
.AddValue(scalar
.ScalarValue(
79 results
.current_page
, 'rasterize_time', 'ms', rasterize_time
))
80 results
.AddValue(scalar
.ScalarValue(
81 results
.current_page
, 'viewport_picture_size', 'bytes',
82 picture_memory_usage
))
83 results
.AddValue(scalar
.ScalarValue(
84 results
.current_page
, 'record_time', 'ms', record_time
))
86 record_time_sk_null_canvas
= data
['record_time_sk_null_canvas_ms']
87 record_time_painting_disabled
= data
['record_time_painting_disabled_ms']
88 # TODO(schenney): Remove this workaround when reference builds get past
89 # the change that adds this comment.
90 record_time_caching_disabled
= \
91 data
.get('record_time_caching_disabled_ms', 0)
92 # TODO(schenney): Remove this workaround when reference builds get past
93 # the change that adds this comment.
94 record_time_construction_disabled
= \
95 data
.get('record_time_construction_disabled_ms', 0)
96 results
.AddValue(scalar
.ScalarValue(
97 results
.current_page
, 'record_time_sk_null_canvas', 'ms',
98 record_time_sk_null_canvas
))
99 results
.AddValue(scalar
.ScalarValue(
100 results
.current_page
, 'record_time_painting_disabled', 'ms',
101 record_time_painting_disabled
))
102 results
.AddValue(scalar
.ScalarValue(
103 results
.current_page
, 'record_time_caching_disabled', 'ms',
104 record_time_caching_disabled
))
105 results
.AddValue(scalar
.ScalarValue(
106 results
.current_page
, 'record_time_construction_disabled', 'ms',
107 record_time_construction_disabled
))
109 if self
._report
_detailed
_results
:
110 pixels_rasterized_with_non_solid_color
= \
111 data
['pixels_rasterized_with_non_solid_color']
112 pixels_rasterized_as_opaque
= \
113 data
['pixels_rasterized_as_opaque']
114 total_layers
= data
['total_layers']
115 total_picture_layers
= data
['total_picture_layers']
116 total_picture_layers_with_no_content
= \
117 data
['total_picture_layers_with_no_content']
118 total_picture_layers_off_screen
= \
119 data
['total_picture_layers_off_screen']
120 # TODO(schenney): Remove this workaround when reference builds get past
121 # the change that adds this comment.
122 if 'total_pictures_in_pile_size' in data
:
123 total_pictures_in_pile_size
= data
['total_pictures_in_pile_size']
125 total_pictures_in_pile_size
= 0
127 results
.AddValue(scalar
.ScalarValue(
128 results
.current_page
, 'total_size_of_pictures_in_piles', 'bytes',
129 total_pictures_in_pile_size
))
130 results
.AddValue(scalar
.ScalarValue(
131 results
.current_page
, 'pixels_rasterized_with_non_solid_color',
132 'pixels', pixels_rasterized_with_non_solid_color
))
133 results
.AddValue(scalar
.ScalarValue(
134 results
.current_page
, 'pixels_rasterized_as_opaque', 'pixels',
135 pixels_rasterized_as_opaque
))
136 results
.AddValue(scalar
.ScalarValue(
137 results
.current_page
, 'total_layers', 'count', total_layers
))
138 results
.AddValue(scalar
.ScalarValue(
139 results
.current_page
, 'total_picture_layers', 'count',
140 total_picture_layers
))
141 results
.AddValue(scalar
.ScalarValue(
142 results
.current_page
, 'total_picture_layers_with_no_content', 'count',
143 total_picture_layers_with_no_content
))
144 results
.AddValue(scalar
.ScalarValue(
145 results
.current_page
, 'total_picture_layers_off_screen', 'count',
146 total_picture_layers_off_screen
))