OLD | NEW |
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 "base/time/time.h" | 5 #include "base/time/time.h" |
6 #include "cc/debug/lap_timer.h" | 6 #include "cc/debug/lap_timer.h" |
7 #include "cc/resources/tile.h" | 7 #include "cc/resources/tile.h" |
8 #include "cc/resources/tile_priority.h" | 8 #include "cc/resources/tile_priority.h" |
9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 168 } |
169 | 169 |
170 void CreateHighLowResAndSetAllTilesVisible() { | 170 void CreateHighLowResAndSetAllTilesVisible() { |
171 // Active layer must get updated first so pending layer can share from it. | 171 // Active layer must get updated first so pending layer can share from it. |
172 active_root_layer_->CreateDefaultTilingsAndTiles(); | 172 active_root_layer_->CreateDefaultTilingsAndTiles(); |
173 active_root_layer_->SetAllTilesVisible(); | 173 active_root_layer_->SetAllTilesVisible(); |
174 pending_root_layer_->CreateDefaultTilingsAndTiles(); | 174 pending_root_layer_->CreateDefaultTilingsAndTiles(); |
175 pending_root_layer_->SetAllTilesVisible(); | 175 pending_root_layer_->SetAllTilesVisible(); |
176 } | 176 } |
177 | 177 |
178 void RunRasterQueueConstructTest(const std::string& test_name) { | 178 void RunRasterQueueConstructTest(const std::string& test_name, |
| 179 int layer_count) { |
179 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 180 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
180 SMOOTHNESS_TAKES_PRIORITY, | 181 SMOOTHNESS_TAKES_PRIORITY, |
181 NEW_CONTENT_TAKES_PRIORITY}; | 182 NEW_CONTENT_TAKES_PRIORITY}; |
182 int priority_count = 0; | 183 int priority_count = 0; |
| 184 |
| 185 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 10); |
| 186 for (unsigned i = 0; i < layers.size(); ++i) |
| 187 layers[i]->UpdateTiles(NULL); |
| 188 |
183 timer_.Reset(); | 189 timer_.Reset(); |
184 do { | 190 do { |
185 RasterTilePriorityQueue queue; | 191 RasterTilePriorityQueue queue; |
186 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); | 192 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); |
187 priority_count = (priority_count + 1) % arraysize(priorities); | 193 priority_count = (priority_count + 1) % arraysize(priorities); |
188 timer_.NextLap(); | 194 timer_.NextLap(); |
189 } while (!timer_.HasTimeLimitExpired()); | 195 } while (!timer_.HasTimeLimitExpired()); |
190 | 196 |
191 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", | 197 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", |
192 "", | 198 "", |
193 test_name, | 199 test_name, |
194 timer_.LapsPerSecond(), | 200 timer_.LapsPerSecond(), |
195 "runs/s", | 201 "runs/s", |
196 true); | 202 true); |
197 } | 203 } |
198 | 204 |
199 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, | 205 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, |
| 206 int layer_count, |
200 unsigned tile_count) { | 207 unsigned tile_count) { |
201 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 208 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
202 SMOOTHNESS_TAKES_PRIORITY, | 209 SMOOTHNESS_TAKES_PRIORITY, |
203 NEW_CONTENT_TAKES_PRIORITY}; | 210 NEW_CONTENT_TAKES_PRIORITY}; |
| 211 |
| 212 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 100); |
| 213 for (unsigned i = 0; i < layers.size(); ++i) |
| 214 layers[i]->UpdateTiles(NULL); |
| 215 |
204 int priority_count = 0; | 216 int priority_count = 0; |
205 timer_.Reset(); | 217 timer_.Reset(); |
206 do { | 218 do { |
207 int count = tile_count; | 219 int count = tile_count; |
208 RasterTilePriorityQueue queue; | 220 RasterTilePriorityQueue queue; |
209 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); | 221 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); |
210 while (count--) { | 222 while (count--) { |
211 ASSERT_FALSE(queue.IsEmpty()); | 223 ASSERT_FALSE(queue.IsEmpty()); |
212 ASSERT_TRUE(queue.Top() != NULL); | 224 ASSERT_TRUE(queue.Top() != NULL); |
213 queue.Pop(); | 225 queue.Pop(); |
214 } | 226 } |
215 priority_count = (priority_count + 1) % arraysize(priorities); | 227 priority_count = (priority_count + 1) % arraysize(priorities); |
216 timer_.NextLap(); | 228 timer_.NextLap(); |
217 } while (!timer_.HasTimeLimitExpired()); | 229 } while (!timer_.HasTimeLimitExpired()); |
218 | 230 |
219 perf_test::PrintResult( | 231 perf_test::PrintResult( |
220 "tile_manager_raster_tile_queue_construct_and_iterate", | 232 "tile_manager_raster_tile_queue_construct_and_iterate", |
221 "", | 233 "", |
222 test_name, | 234 test_name, |
223 timer_.LapsPerSecond(), | 235 timer_.LapsPerSecond(), |
224 "runs/s", | 236 "runs/s", |
225 true); | 237 true); |
226 } | 238 } |
227 | 239 |
228 void RunEvictionQueueConstructTest(const std::string& test_name) { | 240 void RunEvictionQueueConstructTest(const std::string& test_name, |
| 241 int layer_count) { |
229 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 242 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
230 SMOOTHNESS_TAKES_PRIORITY, | 243 SMOOTHNESS_TAKES_PRIORITY, |
231 NEW_CONTENT_TAKES_PRIORITY}; | 244 NEW_CONTENT_TAKES_PRIORITY}; |
232 int priority_count = 0; | 245 int priority_count = 0; |
| 246 |
| 247 std::vector<LayerImpl*> layers = CreateLayers(layer_count, 10); |
| 248 for (unsigned i = 0; i < layers.size(); ++i) { |
| 249 FakePictureLayerImpl* layer = |
| 250 static_cast<FakePictureLayerImpl*>(layers[i]); |
| 251 layer->UpdateTiles(NULL); |
| 252 for (size_t j = 0; j < layer->GetTilings()->num_tilings(); ++j) { |
| 253 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 254 layer->GetTilings()->tiling_at(j)->AllTilesForTesting()); |
| 255 } |
| 256 } |
| 257 |
233 timer_.Reset(); | 258 timer_.Reset(); |
234 do { | 259 do { |
235 EvictionTilePriorityQueue queue; | 260 EvictionTilePriorityQueue queue; |
236 host_impl_.BuildEvictionQueue(&queue, priorities[priority_count]); | 261 host_impl_.BuildEvictionQueue(&queue, priorities[priority_count]); |
237 priority_count = (priority_count + 1) % arraysize(priorities); | 262 priority_count = (priority_count + 1) % arraysize(priorities); |
238 timer_.NextLap(); | 263 timer_.NextLap(); |
239 } while (!timer_.HasTimeLimitExpired()); | 264 } while (!timer_.HasTimeLimitExpired()); |
240 | 265 |
241 perf_test::PrintResult("tile_manager_eviction_tile_queue_construct", | 266 perf_test::PrintResult("tile_manager_eviction_tile_queue_construct", |
242 "", | 267 "", |
243 test_name, | 268 test_name, |
244 timer_.LapsPerSecond(), | 269 timer_.LapsPerSecond(), |
245 "runs/s", | 270 "runs/s", |
246 true); | 271 true); |
247 } | 272 } |
248 | 273 |
249 void RunEvictionQueueConstructAndIterateTest(const std::string& test_name, | 274 void RunEvictionQueueConstructAndIterateTest(const std::string& test_name, |
| 275 int layer_count, |
250 unsigned tile_count) { | 276 unsigned tile_count) { |
251 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 277 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
252 SMOOTHNESS_TAKES_PRIORITY, | 278 SMOOTHNESS_TAKES_PRIORITY, |
253 NEW_CONTENT_TAKES_PRIORITY}; | 279 NEW_CONTENT_TAKES_PRIORITY}; |
254 int priority_count = 0; | 280 int priority_count = 0; |
| 281 |
| 282 std::vector<LayerImpl*> layers = CreateLayers(layer_count, tile_count); |
| 283 for (unsigned i = 0; i < layers.size(); ++i) { |
| 284 FakePictureLayerImpl* layer = |
| 285 static_cast<FakePictureLayerImpl*>(layers[i]); |
| 286 layer->UpdateTiles(NULL); |
| 287 for (size_t j = 0; j < layer->GetTilings()->num_tilings(); ++j) { |
| 288 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 289 layer->GetTilings()->tiling_at(j)->AllTilesForTesting()); |
| 290 } |
| 291 } |
| 292 |
255 timer_.Reset(); | 293 timer_.Reset(); |
256 do { | 294 do { |
257 int count = tile_count; | 295 int count = tile_count; |
258 EvictionTilePriorityQueue queue; | 296 EvictionTilePriorityQueue queue; |
259 host_impl_.BuildEvictionQueue(&queue, priorities[priority_count]); | 297 host_impl_.BuildEvictionQueue(&queue, priorities[priority_count]); |
260 while (count--) { | 298 while (count--) { |
261 ASSERT_FALSE(queue.IsEmpty()); | 299 ASSERT_FALSE(queue.IsEmpty()); |
262 ASSERT_TRUE(queue.Top() != NULL); | 300 ASSERT_TRUE(queue.Top() != NULL); |
263 queue.Pop(); | 301 queue.Pop(); |
264 } | 302 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 FakeImplProxy proxy_; | 417 FakeImplProxy proxy_; |
380 FakeLayerTreeHostImpl host_impl_; | 418 FakeLayerTreeHostImpl host_impl_; |
381 FakePictureLayerImpl* pending_root_layer_; | 419 FakePictureLayerImpl* pending_root_layer_; |
382 FakePictureLayerImpl* active_root_layer_; | 420 FakePictureLayerImpl* active_root_layer_; |
383 LapTimer timer_; | 421 LapTimer timer_; |
384 scoped_refptr<FakePicturePileImpl> picture_pile_; | 422 scoped_refptr<FakePicturePileImpl> picture_pile_; |
385 LayerTreeSettings settings_; | 423 LayerTreeSettings settings_; |
386 }; | 424 }; |
387 | 425 |
388 TEST_F(TileManagerPerfTest, ManageTiles) { | 426 TEST_F(TileManagerPerfTest, ManageTiles) { |
389 RunManageTilesTest("1_100", 1, 100); | 427 RunManageTilesTest("2_100", 2, 100); |
390 RunManageTilesTest("1_500", 1, 500); | 428 RunManageTilesTest("2_500", 2, 500); |
391 RunManageTilesTest("1_1000", 1, 1000); | 429 RunManageTilesTest("2_1000", 2, 1000); |
392 RunManageTilesTest("5_100", 5, 100); | |
393 RunManageTilesTest("5_500", 5, 500); | |
394 RunManageTilesTest("5_1000", 5, 1000); | |
395 RunManageTilesTest("10_100", 10, 100); | 430 RunManageTilesTest("10_100", 10, 100); |
396 RunManageTilesTest("10_500", 10, 500); | 431 RunManageTilesTest("10_500", 10, 500); |
397 RunManageTilesTest("10_1000", 10, 1000); | 432 RunManageTilesTest("10_1000", 10, 1000); |
398 RunManageTilesTest("100_100", 100, 100); | 433 RunManageTilesTest("50_100", 100, 100); |
399 RunManageTilesTest("100_500", 100, 500); | 434 RunManageTilesTest("50_500", 100, 500); |
400 RunManageTilesTest("100_1000", 100, 1000); | 435 RunManageTilesTest("50_1000", 100, 1000); |
401 } | 436 } |
402 | 437 |
403 TEST_F(TileManagerPerfTest, RasterTileQueueConstruct) { | 438 TEST_F(TileManagerPerfTest, RasterTileQueueConstruct) { |
404 SetupDefaultTrees(gfx::Size(1000, 1000)); | 439 RunRasterQueueConstructTest("2", 2); |
405 active_root_layer_->CreateDefaultTilingsAndTiles(); | 440 RunRasterQueueConstructTest("10", 10); |
406 pending_root_layer_->CreateDefaultTilingsAndTiles(); | 441 RunRasterQueueConstructTest("50", 50); |
407 | |
408 RunRasterQueueConstructTest("2"); | |
409 | |
410 int number_of_tilings = 2; | |
411 for (; number_of_tilings < 10; ++number_of_tilings) { | |
412 PictureLayerTiling* tiling = | |
413 active_root_layer_->AddTiling(1.0f + number_of_tilings * 0.3f); | |
414 tiling->CreateAllTilesForTesting(); | |
415 } | |
416 | |
417 RunRasterQueueConstructTest("10"); | |
418 | |
419 for (; number_of_tilings < 50; ++number_of_tilings) { | |
420 PictureLayerTiling* tiling = | |
421 active_root_layer_->AddTiling(1.0f + number_of_tilings * 0.3f); | |
422 tiling->CreateAllTilesForTesting(); | |
423 } | |
424 | |
425 RunRasterQueueConstructTest("50"); | |
426 } | 442 } |
427 | 443 |
428 TEST_F(TileManagerPerfTest, RasterTileQueueConstructAndIterate) { | 444 TEST_F(TileManagerPerfTest, RasterTileQueueConstructAndIterate) { |
429 SetupDefaultTrees(gfx::Size(10000, 10000)); | 445 RunRasterQueueConstructAndIterateTest("2_16", 2, 16); |
430 active_root_layer_->CreateDefaultTilingsAndTiles(); | 446 RunRasterQueueConstructAndIterateTest("2_32", 2, 32); |
431 pending_root_layer_->CreateDefaultTilingsAndTiles(); | 447 RunRasterQueueConstructAndIterateTest("2_64", 2, 64); |
432 | 448 RunRasterQueueConstructAndIterateTest("2_128", 2, 128); |
433 RunRasterQueueConstructAndIterateTest("2_16", 16); | 449 RunRasterQueueConstructAndIterateTest("10_16", 10, 16); |
434 RunRasterQueueConstructAndIterateTest("2_32", 32); | 450 RunRasterQueueConstructAndIterateTest("10_32", 10, 32); |
435 RunRasterQueueConstructAndIterateTest("2_64", 64); | 451 RunRasterQueueConstructAndIterateTest("10_64", 10, 64); |
436 RunRasterQueueConstructAndIterateTest("2_128", 128); | 452 RunRasterQueueConstructAndIterateTest("10_128", 10, 128); |
| 453 RunRasterQueueConstructAndIterateTest("50_16", 50, 16); |
| 454 RunRasterQueueConstructAndIterateTest("50_32", 50, 32); |
| 455 RunRasterQueueConstructAndIterateTest("50_64", 50, 64); |
| 456 RunRasterQueueConstructAndIterateTest("50_128", 50, 128); |
437 } | 457 } |
438 | 458 |
439 TEST_F(TileManagerPerfTest, EvictionTileQueueConstruct) { | 459 TEST_F(TileManagerPerfTest, EvictionTileQueueConstruct) { |
440 SetupDefaultTrees(gfx::Size(1000, 1000)); | 460 RunEvictionQueueConstructTest("2", 2); |
441 active_root_layer_->CreateDefaultTilingsAndTiles(); | 461 RunEvictionQueueConstructTest("10", 10); |
442 for (size_t i = 0; i < active_root_layer_->GetTilings()->num_tilings(); ++i) { | 462 RunEvictionQueueConstructTest("50", 50); |
443 tile_manager()->InitializeTilesWithResourcesForTesting( | |
444 active_root_layer_->GetTilings()->tiling_at(i)->AllTilesForTesting()); | |
445 } | |
446 pending_root_layer_->CreateDefaultTilingsAndTiles(); | |
447 for (size_t i = 0; i < pending_root_layer_->GetTilings()->num_tilings(); | |
448 ++i) { | |
449 tile_manager()->InitializeTilesWithResourcesForTesting( | |
450 pending_root_layer_->GetTilings()->tiling_at(i)->AllTilesForTesting()); | |
451 } | |
452 | |
453 RunEvictionQueueConstructTest("2"); | |
454 | |
455 int number_of_tilings = 2; | |
456 for (; number_of_tilings < 10; ++number_of_tilings) { | |
457 PictureLayerTiling* tiling = | |
458 active_root_layer_->AddTiling(1.0f + number_of_tilings * 0.3f); | |
459 tiling->CreateAllTilesForTesting(); | |
460 tile_manager()->InitializeTilesWithResourcesForTesting( | |
461 tiling->AllTilesForTesting()); | |
462 } | |
463 | |
464 RunEvictionQueueConstructTest("10"); | |
465 | |
466 for (; number_of_tilings < 50; ++number_of_tilings) { | |
467 PictureLayerTiling* tiling = | |
468 active_root_layer_->AddTiling(1.0f + number_of_tilings * 0.3f); | |
469 tiling->CreateAllTilesForTesting(); | |
470 tile_manager()->InitializeTilesWithResourcesForTesting( | |
471 tiling->AllTilesForTesting()); | |
472 } | |
473 | |
474 RunEvictionQueueConstructTest("50"); | |
475 } | 463 } |
476 | 464 |
477 TEST_F(TileManagerPerfTest, EvictionTileQueueConstructAndIterate) { | 465 TEST_F(TileManagerPerfTest, EvictionTileQueueConstructAndIterate) { |
478 SetupDefaultTrees(gfx::Size(10000, 10000)); | 466 RunEvictionQueueConstructAndIterateTest("2_16", 2, 16); |
479 active_root_layer_->CreateDefaultTilingsAndTiles(); | 467 RunEvictionQueueConstructAndIterateTest("2_32", 2, 32); |
480 for (size_t i = 0; i < active_root_layer_->GetTilings()->num_tilings(); ++i) { | 468 RunEvictionQueueConstructAndIterateTest("2_64", 2, 64); |
481 tile_manager()->InitializeTilesWithResourcesForTesting( | 469 RunEvictionQueueConstructAndIterateTest("2_128", 2, 128); |
482 active_root_layer_->GetTilings()->tiling_at(i)->AllTilesForTesting()); | 470 RunEvictionQueueConstructAndIterateTest("10_16", 10, 16); |
483 } | 471 RunEvictionQueueConstructAndIterateTest("10_32", 10, 32); |
484 pending_root_layer_->CreateDefaultTilingsAndTiles(); | 472 RunEvictionQueueConstructAndIterateTest("10_64", 10, 64); |
485 for (size_t i = 0; i < pending_root_layer_->GetTilings()->num_tilings(); | 473 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); |
486 ++i) { | 474 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); |
487 tile_manager()->InitializeTilesWithResourcesForTesting( | 475 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); |
488 pending_root_layer_->GetTilings()->tiling_at(i)->AllTilesForTesting()); | 476 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); |
489 } | 477 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); |
490 | |
491 RunEvictionQueueConstructAndIterateTest("2_16", 16); | |
492 RunEvictionQueueConstructAndIterateTest("2_32", 32); | |
493 RunEvictionQueueConstructAndIterateTest("2_64", 64); | |
494 RunEvictionQueueConstructAndIterateTest("2_128", 128); | |
495 } | 478 } |
496 | 479 |
497 } // namespace | 480 } // namespace |
498 | 481 |
499 } // namespace cc | 482 } // namespace cc |
OLD | NEW |