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

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

Issue 98113005: Revert "cc: Added tile bundles" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/resources/tile_manager_unittest.cc » ('j') | 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 "base/time/time.h" 5 #include "base/time/time.h"
6 #include "cc/resources/tile.h" 6 #include "cc/resources/tile.h"
7 #include "cc/resources/tile_priority.h" 7 #include "cc/resources/tile_priority.h"
8 #include "cc/test/fake_output_surface.h" 8 #include "cc/test/fake_output_surface.h"
9 #include "cc/test/fake_output_surface_client.h" 9 #include "cc/test/fake_output_surface_client.h"
10 #include "cc/test/fake_picture_layer_tiling_client.h"
11 #include "cc/test/fake_picture_pile_impl.h" 10 #include "cc/test/fake_picture_pile_impl.h"
12 #include "cc/test/fake_tile_manager.h" 11 #include "cc/test/fake_tile_manager.h"
13 #include "cc/test/fake_tile_manager_client.h" 12 #include "cc/test/fake_tile_manager_client.h"
14 #include "cc/test/lap_timer.h" 13 #include "cc/test/lap_timer.h"
15 #include "cc/test/test_tile_priorities.h" 14 #include "cc/test/test_tile_priorities.h"
16 15
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/perf/perf_test.h" 17 #include "testing/perf/perf_test.h"
19 18
20 namespace cc { 19 namespace cc {
21 20
22 namespace { 21 namespace {
23 22
24 static const int kTimeLimitMillis = 2000; 23 static const int kTimeLimitMillis = 2000;
25 static const int kWarmupRuns = 5; 24 static const int kWarmupRuns = 5;
26 static const int kTimeCheckInterval = 10; 25 static const int kTimeCheckInterval = 10;
27 26
28 class TileManagerPerfTest : public testing::Test { 27 class TileManagerPerfTest : public testing::Test {
29 public: 28 public:
30 typedef std::vector<std::pair<scoped_refptr<TileBundle>, ManagedTileBin> > 29 typedef std::vector<std::pair<scoped_refptr<Tile>, ManagedTileBin> >
31 TileBundleBinVector; 30 TileBinVector;
32 31
33 TileManagerPerfTest() 32 TileManagerPerfTest()
34 : timer_(kWarmupRuns, 33 : timer_(kWarmupRuns,
35 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 34 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
36 kTimeCheckInterval) {} 35 kTimeCheckInterval) {}
37 36
38 // Overridden from testing::Test: 37 // Overridden from testing::Test:
39 virtual void SetUp() OVERRIDE { 38 virtual void SetUp() OVERRIDE {
40 output_surface_ = FakeOutputSurface::Create3d(); 39 output_surface_ = FakeOutputSurface::Create3d();
41 CHECK(output_surface_->BindToClient(&output_surface_client_)); 40 CHECK(output_surface_->BindToClient(&output_surface_client_));
42 41
43 resource_provider_ = 42 resource_provider_ =
44 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); 43 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
45 size_t raster_task_limit_bytes = 32 * 1024 * 1024; // 16-64MB in practice. 44 size_t raster_task_limit_bytes = 32 * 1024 * 1024; // 16-64MB in practice.
46 tile_manager_ = make_scoped_ptr( 45 tile_manager_ = make_scoped_ptr(
47 new FakeTileManager(&tile_manager_client_, 46 new FakeTileManager(&tile_manager_client_,
48 resource_provider_.get(), 47 resource_provider_.get(),
49 raster_task_limit_bytes)); 48 raster_task_limit_bytes));
50 picture_pile_ = FakePicturePileImpl::CreatePile(); 49 picture_pile_ = FakePicturePileImpl::CreatePile();
51 picture_layer_tiling_client_ =
52 make_scoped_ptr(new FakePictureLayerTilingClient(tile_manager_.get()));
53 } 50 }
54 51
55 GlobalStateThatImpactsTilePriority GlobalStateForTest() { 52 GlobalStateThatImpactsTilePriority GlobalStateForTest() {
56 GlobalStateThatImpactsTilePriority state; 53 GlobalStateThatImpactsTilePriority state;
57 gfx::Size tile_size = settings_.default_tile_size; 54 gfx::Size tile_size = settings_.default_tile_size;
58 state.memory_limit_in_bytes = 55 state.memory_limit_in_bytes =
59 10000u * 4u * 56 10000u * 4u *
60 static_cast<size_t>(tile_size.width() * tile_size.height()); 57 static_cast<size_t>(tile_size.width() * tile_size.height());
61 state.num_resources_limit = 10000; 58 state.num_resources_limit = 10000;
62 state.memory_limit_policy = ALLOW_ANYTHING; 59 state.memory_limit_policy = ALLOW_ANYTHING;
63 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY; 60 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY;
64 return state; 61 return state;
65 } 62 }
66 63
67 virtual void TearDown() OVERRIDE { 64 virtual void TearDown() OVERRIDE {
68 picture_layer_tiling_client_.reset(NULL);
69 tile_manager_.reset(NULL); 65 tile_manager_.reset(NULL);
70 picture_pile_ = NULL; 66 picture_pile_ = NULL;
71 } 67 }
72 68
73 TilePriority GetTilePriorityFromBin(ManagedTileBin bin) { 69 TilePriority GetTilePriorityFromBin(ManagedTileBin bin) {
74 switch (bin) { 70 switch (bin) {
75 case NOW_AND_READY_TO_DRAW_BIN: 71 case NOW_AND_READY_TO_DRAW_BIN:
76 case NOW_BIN: 72 case NOW_BIN:
77 return TilePriorityForNowBin(); 73 return TilePriorityForNowBin();
78 case SOON_BIN: 74 case SOON_BIN:
(...skipping 24 matching lines...) Expand all
103 case AT_LAST_BIN: 99 case AT_LAST_BIN:
104 case AT_LAST_AND_ACTIVE_BIN: 100 case AT_LAST_AND_ACTIVE_BIN:
105 case NEVER_BIN: 101 case NEVER_BIN:
106 return NOW_BIN; 102 return NOW_BIN;
107 default: 103 default:
108 NOTREACHED(); 104 NOTREACHED();
109 return NEVER_BIN; 105 return NEVER_BIN;
110 } 106 }
111 } 107 }
112 108
113 void CreateBinTileBundles(int count, 109 void CreateBinTiles(int count, ManagedTileBin bin, TileBinVector* tiles) {
114 ManagedTileBin bin,
115 TileBundleBinVector* bundles) {
116 for (int i = 0; i < count; ++i) { 110 for (int i = 0; i < count; ++i) {
117 scoped_refptr<TileBundle> bundle = 111 scoped_refptr<Tile> tile =
118 picture_layer_tiling_client_->CreateTileBundle(0, 0, 2, 2); 112 tile_manager_->CreateTile(picture_pile_.get(),
119 bundle->SetPriority(ACTIVE_TREE, GetTilePriorityFromBin(bin)); 113 settings_.default_tile_size,
120 bundle->SetPriority(PENDING_TREE, GetTilePriorityFromBin(bin)); 114 gfx::Rect(),
121 for (int j = 0; j < 4; ++j) { 115 gfx::Rect(),
122 scoped_refptr<Tile> tile = 116 1.0,
123 tile_manager_->CreateTile(picture_pile_.get(), 117 0,
124 settings_.default_tile_size, 118 0,
125 gfx::Rect(), 119 Tile::USE_LCD_TEXT);
126 gfx::Rect(), 120 tile->SetPriority(ACTIVE_TREE, GetTilePriorityFromBin(bin));
127 1.0, 121 tile->SetPriority(PENDING_TREE, GetTilePriorityFromBin(bin));
128 0, 122 tiles->push_back(std::make_pair(tile, bin));
129 0,
130 Tile::USE_LCD_TEXT);
131 bundle->AddTileAt(ACTIVE_TREE, j % 2, j / 2, tile);
132 bundle->AddTileAt(PENDING_TREE, j % 2, j / 2, tile);
133 }
134 bundles->push_back(std::make_pair(bundle, bin));
135 } 123 }
136 } 124 }
137 125
138 void CreateBundles(int count, TileBundleBinVector* bundles) { 126 void CreateTiles(int count, TileBinVector* tiles) {
139 // Roughly an equal amount of all bins. 127 // Roughly an equal amount of all bins.
140 int count_per_bin = count / NUM_BINS; 128 int count_per_bin = count / NUM_BINS;
141 CreateBinTileBundles(count_per_bin, NOW_BIN, bundles); 129 CreateBinTiles(count_per_bin, NOW_BIN, tiles);
142 CreateBinTileBundles(count_per_bin, SOON_BIN, bundles); 130 CreateBinTiles(count_per_bin, SOON_BIN, tiles);
143 CreateBinTileBundles(count_per_bin, EVENTUALLY_BIN, bundles); 131 CreateBinTiles(count_per_bin, EVENTUALLY_BIN, tiles);
144 CreateBinTileBundles(count - 3 * count_per_bin, NEVER_BIN, bundles); 132 CreateBinTiles(count - 3 * count_per_bin, NEVER_BIN, tiles);
145 } 133 }
146 134
147 void RunManageTilesTest(const std::string& test_name, 135 void RunManageTilesTest(const std::string& test_name,
148 unsigned tile_count, 136 unsigned tile_count,
149 int priority_change_percent) { 137 int priority_change_percent) {
150 DCHECK_GE(tile_count, 100u); 138 DCHECK_GE(tile_count, 100u);
151 DCHECK_GE(priority_change_percent, 0); 139 DCHECK_GE(priority_change_percent, 0);
152 DCHECK_LE(priority_change_percent, 100); 140 DCHECK_LE(priority_change_percent, 100);
153 TileBundleBinVector bundles; 141 TileBinVector tiles;
154 142 CreateTiles(tile_count, &tiles);
155 unsigned bundle_count = tile_count / 4;
156 CreateBundles(bundle_count, &bundles);
157 timer_.Reset(); 143 timer_.Reset();
158 do { 144 do {
159 if (priority_change_percent > 0) { 145 if (priority_change_percent > 0) {
160 for (unsigned i = 0; 146 for (unsigned i = 0;
161 i < bundle_count; 147 i < tile_count;
162 i += 100 / priority_change_percent) { 148 i += 100 / priority_change_percent) {
163 TileBundle* bundle = bundles[i].first.get(); 149 Tile* tile = tiles[i].first.get();
164 ManagedTileBin bin = GetNextBin(bundles[i].second); 150 ManagedTileBin bin = GetNextBin(tiles[i].second);
165 bundle->SetPriority(ACTIVE_TREE, GetTilePriorityFromBin(bin)); 151 tile->SetPriority(ACTIVE_TREE, GetTilePriorityFromBin(bin));
166 bundle->SetPriority(PENDING_TREE, GetTilePriorityFromBin(bin)); 152 tile->SetPriority(PENDING_TREE, GetTilePriorityFromBin(bin));
167 bundles[i].second = bin; 153 tiles[i].second = bin;
168 } 154 }
169 } 155 }
170 156
171 tile_manager_->ManageTiles(GlobalStateForTest()); 157 tile_manager_->ManageTiles(GlobalStateForTest());
172 tile_manager_->CheckForCompletedTasks(); 158 tile_manager_->CheckForCompletedTasks();
173 timer_.NextLap(); 159 timer_.NextLap();
174 } while (!timer_.HasTimeLimitExpired()); 160 } while (!timer_.HasTimeLimitExpired());
175 161
176 perf_test::PrintResult("manage_tiles", "", test_name, 162 perf_test::PrintResult("manage_tiles", "", test_name,
177 timer_.LapsPerSecond(), "runs/s", true); 163 timer_.LapsPerSecond(), "runs/s", true);
178 } 164 }
179 165
180 private: 166 private:
181 FakeTileManagerClient tile_manager_client_; 167 FakeTileManagerClient tile_manager_client_;
182 scoped_ptr<FakePictureLayerTilingClient> picture_layer_tiling_client_;
183 LayerTreeSettings settings_; 168 LayerTreeSettings settings_;
184 scoped_ptr<FakeTileManager> tile_manager_; 169 scoped_ptr<FakeTileManager> tile_manager_;
185 scoped_refptr<FakePicturePileImpl> picture_pile_; 170 scoped_refptr<FakePicturePileImpl> picture_pile_;
186 FakeOutputSurfaceClient output_surface_client_; 171 FakeOutputSurfaceClient output_surface_client_;
187 scoped_ptr<FakeOutputSurface> output_surface_; 172 scoped_ptr<FakeOutputSurface> output_surface_;
188 scoped_ptr<ResourceProvider> resource_provider_; 173 scoped_ptr<ResourceProvider> resource_provider_;
189 LapTimer timer_; 174 LapTimer timer_;
190 }; 175 };
191 176
192 TEST_F(TileManagerPerfTest, ManageTiles) { 177 TEST_F(TileManagerPerfTest, ManageTiles) {
193 RunManageTilesTest("100_0", 100, 0); 178 RunManageTilesTest("100_0", 100, 0);
194 RunManageTilesTest("1000_0", 1000, 0); 179 RunManageTilesTest("1000_0", 1000, 0);
195 RunManageTilesTest("10000_0", 10000, 0); 180 RunManageTilesTest("10000_0", 10000, 0);
196 RunManageTilesTest("100_10", 100, 10); 181 RunManageTilesTest("100_10", 100, 10);
197 RunManageTilesTest("1000_10", 1000, 10); 182 RunManageTilesTest("1000_10", 1000, 10);
198 RunManageTilesTest("10000_10", 10000, 10); 183 RunManageTilesTest("10000_10", 10000, 10);
199 RunManageTilesTest("100_100", 100, 100); 184 RunManageTilesTest("100_100", 100, 100);
200 RunManageTilesTest("1000_100", 1000, 100); 185 RunManageTilesTest("1000_100", 1000, 100);
201 RunManageTilesTest("10000_100", 10000, 100); 186 RunManageTilesTest("10000_100", 10000, 100);
202 } 187 }
203 188
204 } // namespace 189 } // namespace
205 190
206 } // namespace cc 191 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698