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 RunRasterIteratorTest(const std::string& test_name, | 178 void RunRasterQueueConstructTest(const std::string& test_name) { |
179 unsigned tile_count) { | 179 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 180 SMOOTHNESS_TAKES_PRIORITY, |
| 181 NEW_CONTENT_TAKES_PRIORITY}; |
| 182 int priority_count = 0; |
180 timer_.Reset(); | 183 timer_.Reset(); |
181 do { | 184 do { |
182 int count = tile_count; | |
183 RasterTilePriorityQueue queue; | 185 RasterTilePriorityQueue queue; |
184 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); | 186 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); |
185 while (count--) { | 187 priority_count = (priority_count + 1) % arraysize(priorities); |
186 ASSERT_FALSE(queue.IsEmpty()); | |
187 ASSERT_TRUE(queue.Top() != NULL); | |
188 queue.Pop(); | |
189 } | |
190 timer_.NextLap(); | 188 timer_.NextLap(); |
191 } while (!timer_.HasTimeLimitExpired()); | 189 } while (!timer_.HasTimeLimitExpired()); |
192 | 190 |
193 perf_test::PrintResult("tile_manager_raster_tile_iterator", | 191 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", |
194 "", | 192 "", |
195 test_name, | 193 test_name, |
196 timer_.LapsPerSecond(), | 194 timer_.LapsPerSecond(), |
197 "runs/s", | 195 "runs/s", |
198 true); | 196 true); |
199 } | 197 } |
200 | 198 |
| 199 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, |
| 200 unsigned tile_count) { |
| 201 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| 202 SMOOTHNESS_TAKES_PRIORITY, |
| 203 NEW_CONTENT_TAKES_PRIORITY}; |
| 204 int priority_count = 0; |
| 205 timer_.Reset(); |
| 206 do { |
| 207 int count = tile_count; |
| 208 RasterTilePriorityQueue queue; |
| 209 host_impl_.BuildRasterQueue(&queue, priorities[priority_count]); |
| 210 while (count--) { |
| 211 ASSERT_FALSE(queue.IsEmpty()); |
| 212 ASSERT_TRUE(queue.Top() != NULL); |
| 213 queue.Pop(); |
| 214 } |
| 215 priority_count = (priority_count + 1) % arraysize(priorities); |
| 216 timer_.NextLap(); |
| 217 } while (!timer_.HasTimeLimitExpired()); |
| 218 |
| 219 perf_test::PrintResult( |
| 220 "tile_manager_raster_tile_queue_construct_and_iterate", |
| 221 "", |
| 222 test_name, |
| 223 timer_.LapsPerSecond(), |
| 224 "runs/s", |
| 225 true); |
| 226 } |
| 227 |
201 std::vector<LayerImpl*> CreateLayers(int layer_count, | 228 std::vector<LayerImpl*> CreateLayers(int layer_count, |
202 int tiles_per_layer_count) { | 229 int tiles_per_layer_count) { |
203 // Compute the width/height required for high res to get | 230 // Compute the width/height required for high res to get |
204 // tiles_per_layer_count tiles. | 231 // tiles_per_layer_count tiles. |
205 float width = std::sqrt(static_cast<float>(tiles_per_layer_count)); | 232 float width = std::sqrt(static_cast<float>(tiles_per_layer_count)); |
206 float height = tiles_per_layer_count / width; | 233 float height = tiles_per_layer_count / width; |
207 | 234 |
208 // Adjust the width and height to account for the fact that tiles | 235 // Adjust the width and height to account for the fact that tiles |
209 // are bigger than 1x1. Also, account for the fact that that we | 236 // are bigger than 1x1. Also, account for the fact that that we |
210 // will be creating one high res and one low res tiling. That is, | 237 // will be creating one high res and one low res tiling. That is, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 RunManageTilesTest("5_500", 5, 500); | 343 RunManageTilesTest("5_500", 5, 500); |
317 RunManageTilesTest("5_1000", 5, 1000); | 344 RunManageTilesTest("5_1000", 5, 1000); |
318 RunManageTilesTest("10_100", 10, 100); | 345 RunManageTilesTest("10_100", 10, 100); |
319 RunManageTilesTest("10_500", 10, 500); | 346 RunManageTilesTest("10_500", 10, 500); |
320 RunManageTilesTest("10_1000", 10, 1000); | 347 RunManageTilesTest("10_1000", 10, 1000); |
321 RunManageTilesTest("100_100", 100, 100); | 348 RunManageTilesTest("100_100", 100, 100); |
322 RunManageTilesTest("100_500", 100, 500); | 349 RunManageTilesTest("100_500", 100, 500); |
323 RunManageTilesTest("100_1000", 100, 1000); | 350 RunManageTilesTest("100_1000", 100, 1000); |
324 } | 351 } |
325 | 352 |
326 TEST_F(TileManagerPerfTest, RasterTileIterator) { | 353 TEST_F(TileManagerPerfTest, RasterTileQueueConstruct) { |
327 SetupDefaultTrees(gfx::Size(10000, 10000)); | 354 SetupDefaultTrees(gfx::Size(10000, 10000)); |
328 active_root_layer_->CreateDefaultTilingsAndTiles(); | 355 active_root_layer_->CreateDefaultTilingsAndTiles(); |
329 pending_root_layer_->CreateDefaultTilingsAndTiles(); | 356 pending_root_layer_->CreateDefaultTilingsAndTiles(); |
330 | 357 |
331 RunRasterIteratorTest("2_16", 16); | 358 RunRasterQueueConstructTest("2"); |
332 RunRasterIteratorTest("2_32", 32); | 359 |
333 RunRasterIteratorTest("2_64", 64); | 360 for (int i = 0; i < 8; ++i) { |
334 RunRasterIteratorTest("2_128", 128); | 361 PictureLayerTiling* tiling = active_root_layer_->AddTiling(i * 0.3f); |
| 362 tiling->CreateAllTilesForTesting(); |
| 363 } |
| 364 |
| 365 RunRasterQueueConstructTest("10"); |
| 366 |
| 367 for (int i = 0; i < 90; ++i) { |
| 368 PictureLayerTiling* tiling = |
| 369 active_root_layer_->AddTiling(1.0f + i * 0.03f); |
| 370 tiling->CreateAllTilesForTesting(); |
| 371 } |
| 372 |
| 373 RunRasterQueueConstructTest("100"); |
| 374 } |
| 375 |
| 376 TEST_F(TileManagerPerfTest, RasterTileQueueConstructAndIterate) { |
| 377 SetupDefaultTrees(gfx::Size(10000, 10000)); |
| 378 active_root_layer_->CreateDefaultTilingsAndTiles(); |
| 379 pending_root_layer_->CreateDefaultTilingsAndTiles(); |
| 380 |
| 381 RunRasterQueueConstructAndIterateTest("2_16", 16); |
| 382 RunRasterQueueConstructAndIterateTest("2_32", 32); |
| 383 RunRasterQueueConstructAndIterateTest("2_64", 64); |
| 384 RunRasterQueueConstructAndIterateTest("2_128", 128); |
335 } | 385 } |
336 | 386 |
337 } // namespace | 387 } // namespace |
338 | 388 |
339 } // namespace cc | 389 } // namespace cc |
OLD | NEW |