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

Side by Side Diff: cc/resources/picture_layer_tiling_perftest.cc

Issue 392413002: cc: Add tiling eviction iterator perftests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 6 years, 5 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 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/lap_timer.h" 5 #include "cc/debug/lap_timer.h"
6 #include "cc/resources/picture_layer_tiling.h" 6 #include "cc/resources/picture_layer_tiling.h"
7 #include "cc/resources/resource_provider.h"
8 #include "cc/resources/scoped_resource.h"
9 #include "cc/test/fake_output_surface.h"
10 #include "cc/test/fake_output_surface_client.h"
7 #include "cc/test/fake_picture_layer_tiling_client.h" 11 #include "cc/test/fake_picture_layer_tiling_client.h"
12 #include "cc/test/test_context_provider.h"
13 #include "cc/test/test_shared_bitmap_manager.h"
8 14
9 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/perf/perf_test.h" 16 #include "testing/perf/perf_test.h"
11 17
12 namespace cc { 18 namespace cc {
13 19
14 namespace { 20 namespace {
15 21
16 static const int kTimeLimitMillis = 2000; 22 static const int kTimeLimitMillis = 2000;
17 static const int kWarmupRuns = 5; 23 static const int kWarmupRuns = 5;
18 static const int kTimeCheckInterval = 10; 24 static const int kTimeCheckInterval = 10;
19 25
20 class PictureLayerTilingPerfTest : public testing::Test { 26 class PictureLayerTilingPerfTest : public testing::Test {
21 public: 27 public:
22 PictureLayerTilingPerfTest() 28 PictureLayerTilingPerfTest()
23 : timer_(kWarmupRuns, 29 : timer_(kWarmupRuns,
24 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 30 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
25 kTimeCheckInterval) {} 31 kTimeCheckInterval),
32 context_provider_(TestContextProvider::Create()) {
33 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass();
34 CHECK(output_surface_->BindToClient(&output_surface_client_));
35
36 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
37 resource_provider_ = ResourceProvider::Create(output_surface_.get(),
38 shared_bitmap_manager_.get(),
39 0,
40 false,
41 1,
42 false).Pass();
43 }
26 44
27 virtual void SetUp() OVERRIDE { 45 virtual void SetUp() OVERRIDE {
28 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); 46 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256));
29 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250); 47 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250);
30 picture_layer_tiling_ = PictureLayerTiling::Create( 48 picture_layer_tiling_ = PictureLayerTiling::Create(
31 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); 49 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_);
32 picture_layer_tiling_->CreateAllTilesForTesting(); 50 picture_layer_tiling_->CreateAllTilesForTesting();
33 } 51 }
34 52
35 virtual void TearDown() OVERRIDE { 53 virtual void TearDown() OVERRIDE {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } while (!timer_.HasTimeLimitExpired()); 152 } while (!timer_.HasTimeLimitExpired());
135 153
136 perf_test::PrintResult("tiling_raster_tile_iterator", 154 perf_test::PrintResult("tiling_raster_tile_iterator",
137 "", 155 "",
138 test_name, 156 test_name,
139 timer_.LapsPerSecond(), 157 timer_.LapsPerSecond(),
140 "runs/s", 158 "runs/s",
141 true); 159 true);
142 } 160 }
143 161
162 void RunEvictionIteratorConstructTest(const std::string& test_name,
163 const gfx::Rect& viewport) {
164 gfx::Size bounds(viewport.size());
165 picture_layer_tiling_ =
166 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_);
167 picture_layer_tiling_->UpdateTilePriorities(
168 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
169
170 timer_.Reset();
171 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
172 SMOOTHNESS_TAKES_PRIORITY,
173 NEW_CONTENT_TAKES_PRIORITY};
174 int priority_count = 0;
175 do {
176 PictureLayerTiling::TilingEvictionTileIterator it(
177 picture_layer_tiling_.get(), priorities[priority_count]);
178 priority_count = (priority_count + 1) % arraysize(priorities);
179 timer_.NextLap();
180 } while (!timer_.HasTimeLimitExpired());
181
182 perf_test::PrintResult("tiling_eviction_tile_iterator_construct",
183 "",
184 test_name,
185 timer_.LapsPerSecond(),
186 "runs/s",
187 true);
188 }
189
190 void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name,
191 int num_tiles,
192 const gfx::Rect& viewport) {
193 gfx::Size bounds(10000, 10000);
194 picture_layer_tiling_ =
195 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_);
196 picture_layer_tiling_->UpdateTilePriorities(
197 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
198
199 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
200 SMOOTHNESS_TAKES_PRIORITY,
201 NEW_CONTENT_TAKES_PRIORITY};
202
203 // Ensure all tiles have resources.
204 for (PictureLayerTiling::TilingRasterTileIterator it(
reveman 2014/07/17 16:26:23 nit: I think it's a bit awkward to use an iterator
vmpstr 2014/07/17 16:40:54 Done.
205 picture_layer_tiling_.get(), ACTIVE_TREE);
206 it;
207 ++it) {
208 Tile* tile = *it;
209 ManagedTileState::TileVersion& tile_version =
210 tile->GetTileVersionForTesting(tile->GetRasterModeForTesting());
211 tile_version.SetResourceForTesting(
212 ScopedResource::Create(resource_provider_.get()).Pass());
213 }
214
215 int priority_count = 0;
216 timer_.Reset();
217 do {
218 int count = num_tiles;
219 PictureLayerTiling::TilingEvictionTileIterator it(
220 picture_layer_tiling_.get(), priorities[priority_count]);
221 ASSERT_TRUE(it);
222 for (; it && count; ++it) {
223 --count;
224 }
225 ASSERT_EQ(0, count);
reveman 2014/07/17 16:26:23 nit: same suggestion as the other patch, maybe rep
vmpstr 2014/07/17 16:40:54 Done.
226 priority_count = (priority_count + 1) % arraysize(priorities);
227 timer_.NextLap();
228 } while (!timer_.HasTimeLimitExpired());
229
230 // Remove all resources form tiles to make sure the tile version destructor
231 // doesn't complain.
232 for (PictureLayerTiling::TilingEvictionTileIterator it(
233 picture_layer_tiling_.get(), SAME_PRIORITY_FOR_BOTH_TREES);
234 it;
235 ++it) {
236 Tile* tile = *it;
237 ManagedTileState::TileVersion& tile_version =
238 tile->GetTileVersionForTesting(tile->GetRasterModeForTesting());
239 tile_version.SetResourceForTesting(scoped_ptr<ScopedResource>());
240 }
241
242 perf_test::PrintResult(
243 "tiling_eviction_tile_iterator_construct_and_iterate",
244 "",
245 test_name,
246 timer_.LapsPerSecond(),
247 "runs/s",
248 true);
249 }
250
144 private: 251 private:
145 FakePictureLayerTilingClient picture_layer_tiling_client_; 252 FakePictureLayerTilingClient picture_layer_tiling_client_;
146 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; 253 scoped_ptr<PictureLayerTiling> picture_layer_tiling_;
147 254
148 LapTimer timer_; 255 LapTimer timer_;
256
257 scoped_refptr<ContextProvider> context_provider_;
258 FakeOutputSurfaceClient output_surface_client_;
259 scoped_ptr<FakeOutputSurface> output_surface_;
260 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
261 scoped_ptr<ResourceProvider> resource_provider_;
149 }; 262 };
150 263
151 TEST_F(PictureLayerTilingPerfTest, Invalidate) { 264 TEST_F(PictureLayerTilingPerfTest, Invalidate) {
152 Region one_tile(gfx::Rect(256, 256)); 265 Region one_tile(gfx::Rect(256, 256));
153 RunInvalidateTest("1x1", one_tile); 266 RunInvalidateTest("1x1", one_tile);
154 267
155 Region half_region(gfx::Rect(25 * 256, 50 * 256)); 268 Region half_region(gfx::Rect(25 * 256, 50 * 256));
156 RunInvalidateTest("25x50", half_region); 269 RunInvalidateTest("25x50", half_region);
157 270
158 Region full_region(gfx::Rect(50 * 256, 50 * 256)); 271 Region full_region(gfx::Rect(50 * 256, 50 * 256));
(...skipping 20 matching lines...) Expand all
179 RunUpdateTilePrioritiesScrollingTest("perspective", transform); 292 RunUpdateTilePrioritiesScrollingTest("perspective", transform);
180 } 293 }
181 294
182 TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIterator) { 295 TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIterator) {
183 RunTilingRasterTileIteratorTest("32_100x100", 32, gfx::Rect(0, 0, 100, 100)); 296 RunTilingRasterTileIteratorTest("32_100x100", 32, gfx::Rect(0, 0, 100, 100));
184 RunTilingRasterTileIteratorTest("32_500x500", 32, gfx::Rect(0, 0, 500, 500)); 297 RunTilingRasterTileIteratorTest("32_500x500", 32, gfx::Rect(0, 0, 500, 500));
185 RunTilingRasterTileIteratorTest("64_100x100", 64, gfx::Rect(0, 0, 100, 100)); 298 RunTilingRasterTileIteratorTest("64_100x100", 64, gfx::Rect(0, 0, 100, 100));
186 RunTilingRasterTileIteratorTest("64_500x500", 64, gfx::Rect(0, 0, 500, 500)); 299 RunTilingRasterTileIteratorTest("64_500x500", 64, gfx::Rect(0, 0, 500, 500));
187 } 300 }
188 301
302 TEST_F(PictureLayerTilingPerfTest, TilingEvictionTileIteratorConstruct) {
303 RunEvictionIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
304 RunEvictionIteratorConstructTest("50_0_100x100", gfx::Rect(50, 0, 100, 100));
305 RunEvictionIteratorConstructTest("100_0_100x100",
306 gfx::Rect(100, 0, 100, 100));
307 RunEvictionIteratorConstructTest("150_0_100x100",
308 gfx::Rect(150, 0, 100, 100));
309 }
310
311 TEST_F(PictureLayerTilingPerfTest,
312 TilingEvictionTileIteratorConstructAndIterate) {
313 RunEvictionIteratorConstructAndIterateTest(
314 "32_100x100", 32, gfx::Rect(0, 0, 100, 100));
315 RunEvictionIteratorConstructAndIterateTest(
316 "32_500x500", 32, gfx::Rect(0, 0, 500, 500));
317 RunEvictionIteratorConstructAndIterateTest(
318 "64_100x100", 64, gfx::Rect(0, 0, 100, 100));
319 RunEvictionIteratorConstructAndIterateTest(
320 "64_500x500", 64, gfx::Rect(0, 0, 500, 500));
321 }
322
189 } // namespace 323 } // namespace
190 324
191 } // namespace cc 325 } // namespace cc
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