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

Side by Side Diff: cc/debug/rasterize_and_record_benchmark.cc

Issue 885753004: Revert of Report viewport memory and timing correctly for Slimming Paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « cc/debug/rasterize_and_record_benchmark.h ('k') | 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 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 #include "cc/debug/rasterize_and_record_benchmark.h" 5 #include "cc/debug/rasterize_and_record_benchmark.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "cc/debug/lap_timer.h" 14 #include "cc/debug/lap_timer.h"
15 #include "cc/debug/rasterize_and_record_benchmark_impl.h" 15 #include "cc/debug/rasterize_and_record_benchmark_impl.h"
16 #include "cc/layers/content_layer_client.h"
17 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
18 #include "cc/layers/picture_layer.h" 17 #include "cc/layers/picture_layer.h"
19 #include "cc/resources/display_item_list.h"
20 #include "cc/resources/picture_pile.h" 18 #include "cc/resources/picture_pile.h"
21 #include "cc/trees/layer_tree_host.h" 19 #include "cc/trees/layer_tree_host.h"
22 #include "cc/trees/layer_tree_host_common.h" 20 #include "cc/trees/layer_tree_host_common.h"
23 #include "third_party/skia/include/utils/SkPictureUtils.h" 21 #include "third_party/skia/include/utils/SkPictureUtils.h"
24 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
25 23
26 namespace cc { 24 namespace cc {
27 25
28 namespace { 26 namespace {
29 27
30 const int kDefaultRecordRepeatCount = 100; 28 const int kDefaultRecordRepeatCount = 100;
31 29
32 // Parameters for LapTimer.
33 const int kTimeLimitMillis = 1;
34 const int kWarmupRuns = 0;
35 const int kTimeCheckInterval = 1;
36
37 const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = { 30 const char* kModeSuffixes[Picture::RECORDING_MODE_COUNT] = {
38 "", 31 "",
39 "_sk_null_canvas", 32 "_sk_null_canvas",
40 "_painting_disabled"}; 33 "_painting_disabled"};
41 34
42 } // namespace 35 } // namespace
43 36
44 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark( 37 RasterizeAndRecordBenchmark::RasterizeAndRecordBenchmark(
45 scoped_ptr<base::Value> value, 38 scoped_ptr<base::Value> value,
46 const MicroBenchmark::DoneCallback& callback) 39 const MicroBenchmark::DoneCallback& callback)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 settings_.get(), 95 settings_.get(),
103 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults, 96 base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults,
104 weak_ptr_factory_.GetWeakPtr()))); 97 weak_ptr_factory_.GetWeakPtr())));
105 } 98 }
106 99
107 void RasterizeAndRecordBenchmark::Run(Layer* layer) { 100 void RasterizeAndRecordBenchmark::Run(Layer* layer) {
108 layer->RunMicroBenchmark(this); 101 layer->RunMicroBenchmark(this);
109 } 102 }
110 103
111 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { 104 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) {
105 ContentLayerClient* painter = layer->client();
106 gfx::Size content_bounds = layer->content_bounds();
107
112 DCHECK(host_); 108 DCHECK(host_);
109 gfx::Size tile_grid_size = host_->settings().default_tile_size;
113 110
114 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( 111 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect(
115 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); 112 layer->visible_content_rect(), 1.f / layer->contents_scale_x());
116 if (visible_content_rect.IsEmpty()) 113 if (visible_content_rect.IsEmpty())
117 return; 114 return;
118 115
119 if (host_->settings().use_display_lists) {
120 RunOnDisplayListLayer(layer, visible_content_rect);
121 } else {
122 RunOnPictureLayer(layer, visible_content_rect);
123 }
124 }
125
126 void RasterizeAndRecordBenchmark::RunOnPictureLayer(
127 PictureLayer* layer,
128 const gfx::Rect& visible_content_rect) {
129 ContentLayerClient* painter = layer->client();
130
131 DCHECK(host_ && !host_->settings().use_display_lists);
132
133 gfx::Size tile_grid_size = host_->settings().default_tile_size;
134
135 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; 116 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT;
136 mode_index++) { 117 mode_index++) {
137 Picture::RecordingMode mode = 118 Picture::RecordingMode mode =
138 static_cast<Picture::RecordingMode>(mode_index); 119 static_cast<Picture::RecordingMode>(mode_index);
139 base::TimeDelta min_time = base::TimeDelta::Max(); 120 base::TimeDelta min_time = base::TimeDelta::Max();
140 size_t memory_used = 0; 121 size_t memory_used = 0;
141 122
123 // Parameters for LapTimer.
124 const int kTimeLimitMillis = 1;
125 const int kWarmupRuns = 0;
126 const int kTimeCheckInterval = 1;
127
142 for (int i = 0; i < record_repeat_count_; ++i) { 128 for (int i = 0; i < record_repeat_count_; ++i) {
143 // Run for a minimum amount of time to avoid problems with timer 129 // Run for a minimum amount of time to avoid problems with timer
144 // quantization when the layer is very small. 130 // quantization when the layer is very small.
145 LapTimer timer(kWarmupRuns, 131 LapTimer timer(kWarmupRuns,
146 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 132 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
147 kTimeCheckInterval); 133 kTimeCheckInterval);
148 scoped_refptr<Picture> picture; 134 scoped_refptr<Picture> picture;
149 do { 135 do {
150 picture = Picture::Create(visible_content_rect, painter, tile_grid_size, 136 picture = Picture::Create(visible_content_rect, painter, tile_grid_size,
151 false, mode); 137 false, mode);
152 if (memory_used) {
153 // Verify we are recording the same thing each time.
154 DCHECK(memory_used == picture->ApproximateMemoryUsage());
155 } else {
156 memory_used = picture->ApproximateMemoryUsage();
157 }
158
159 timer.NextLap(); 138 timer.NextLap();
160 } while (!timer.HasTimeLimitExpired()); 139 } while (!timer.HasTimeLimitExpired());
161 base::TimeDelta duration = 140 base::TimeDelta duration =
162 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); 141 base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
163 if (duration < min_time) 142 if (duration < min_time)
164 min_time = duration; 143 min_time = duration;
144 memory_used = picture->ApproximateMemoryUsage();
165 } 145 }
166 146
167 if (mode == Picture::RECORD_NORMALLY) { 147 if (mode == Picture::RECORD_NORMALLY) {
168 record_results_.bytes_used += memory_used; 148 record_results_.bytes_used += memory_used;
169 record_results_.pixels_recorded += 149 record_results_.pixels_recorded +=
170 visible_content_rect.width() * visible_content_rect.height(); 150 visible_content_rect.width() * visible_content_rect.height();
171 } 151 }
172 record_results_.total_best_time[mode_index] += min_time; 152 record_results_.total_best_time[mode_index] += min_time;
173 } 153 }
174 } 154 }
175 155
176 void RasterizeAndRecordBenchmark::RunOnDisplayListLayer(
177 PictureLayer* layer,
178 const gfx::Rect& visible_content_rect) {
179 ContentLayerClient* painter = layer->client();
180
181 DCHECK(host_ && host_->settings().use_display_lists);
182
183 base::TimeDelta min_time = base::TimeDelta::Max();
184 size_t memory_used = 0;
185
186 // TODO(schenney): What are the corresponding Picture::RecordingMode modes
187 // for Slimming Paint. We could disable SkPicture creation in
188 // DrawingDisplayItems, or we could only generate the display list and not
189 // do any work on it in the compositor, or something else, or all of the
190 // above.
191 scoped_refptr<DisplayItemList> display_list;
192 for (int i = 0; i < record_repeat_count_; ++i) {
193 // Run for a minimum amount of time to avoid problems with timer
194 // quantization when the layer is very small.
195 LapTimer timer(kWarmupRuns,
196 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
197 kTimeCheckInterval);
198
199 do {
200 // TODO(schenney): Cached content will not be regenerated, which skews
201 // the results significantly in favor of Slimming Paint (or should).
202 // Add a flag or API call to disable caching, and maybe run the test
203 // twice, without and with caching.
204 display_list = painter->PaintContentsToDisplayList(
205 visible_content_rect, ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
206
207 if (memory_used) {
208 // Verify we are recording the same thing each time.
209 DCHECK(memory_used == display_list->PictureMemoryUsage());
210 } else {
211 memory_used = display_list->PictureMemoryUsage();
212 }
213
214 timer.NextLap();
215 } while (!timer.HasTimeLimitExpired());
216 base::TimeDelta duration =
217 base::TimeDelta::FromMillisecondsD(timer.MsPerLap());
218 if (duration < min_time)
219 min_time = duration;
220 }
221
222 record_results_.bytes_used += memory_used;
223 record_results_.pixels_recorded +=
224 visible_content_rect.width() * visible_content_rect.height();
225 record_results_.total_best_time[Picture::RECORD_NORMALLY] += min_time;
226 }
227
228 RasterizeAndRecordBenchmark::RecordResults::RecordResults() 156 RasterizeAndRecordBenchmark::RecordResults::RecordResults()
229 : pixels_recorded(0), bytes_used(0) { 157 : pixels_recorded(0), bytes_used(0) {
230 } 158 }
231 159
232 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} 160 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {}
233 161
234 } // namespace cc 162 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/rasterize_and_record_benchmark.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698