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

Side by Side Diff: cc/layers/picture_layer_impl_perftest.cc

Issue 404583002: cc: Add layer eviction iterator perftests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include "cc/debug/lap_timer.h" 7 #include "cc/debug/lap_timer.h"
8 #include "cc/test/fake_impl_proxy.h" 8 #include "cc/test/fake_impl_proxy.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/fake_output_surface.h" 10 #include "cc/test/fake_output_surface.h"
11 #include "cc/test/fake_picture_layer_impl.h" 11 #include "cc/test/fake_picture_layer_impl.h"
12 #include "cc/test/fake_picture_pile_impl.h" 12 #include "cc/test/fake_picture_pile_impl.h"
13 #include "cc/test/impl_side_painting_settings.h" 13 #include "cc/test/impl_side_painting_settings.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 14 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/trees/layer_tree_impl.h" 15 #include "cc/trees/layer_tree_impl.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/perf/perf_test.h" 17 #include "testing/perf/perf_test.h"
18 18
19 namespace cc { 19 namespace cc {
20 namespace { 20 namespace {
21 21
22 static const int kTimeLimitMillis = 2000; 22 static const int kTimeLimitMillis = 2000;
23 static const int kWarmupRuns = 5; 23 static const int kWarmupRuns = 5;
24 static const int kTimeCheckInterval = 10; 24 static const int kTimeCheckInterval = 10;
25 25
26 void AddTiling(float scale,
27 FakePictureLayerImpl* layer,
28 std::vector<Tile*>* all_tiles) {
29 PictureLayerTiling* tiling = layer->AddTiling(scale);
30
31 tiling->CreateAllTilesForTesting();
32 const std::vector<Tile*>& tiling_tiles = tiling->AllTilesForTesting();
reveman 2014/07/17 19:30:36 why "const std::vector<Tile*>&"? doesn't AllTilesF
vmpstr 2014/07/17 19:39:13 const ref extends the lifetime of temporaries. I c
reveman 2014/07/17 20:19:28 I think that would be better but I don't feel that
vmpstr 2014/07/17 20:21:47 Changed.
33 std::copy(
34 tiling_tiles.begin(), tiling_tiles.end(), std::back_inserter(*all_tiles));
35 }
36
26 class PictureLayerImplPerfTest : public testing::Test { 37 class PictureLayerImplPerfTest : public testing::Test {
27 public: 38 public:
28 PictureLayerImplPerfTest() 39 PictureLayerImplPerfTest()
29 : proxy_(base::MessageLoopProxy::current()), 40 : proxy_(base::MessageLoopProxy::current()),
30 host_impl_(ImplSidePaintingSettings(), 41 host_impl_(ImplSidePaintingSettings(),
31 &proxy_, 42 &proxy_,
32 &shared_bitmap_manager_), 43 &shared_bitmap_manager_),
33 timer_(kWarmupRuns, 44 timer_(kWarmupRuns,
34 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 45 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
35 kTimeCheckInterval) {} 46 kTimeCheckInterval) {}
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } while (!timer_.HasTimeLimitExpired()); 86 } while (!timer_.HasTimeLimitExpired());
76 87
77 perf_test::PrintResult("layer_raster_tile_iterator", 88 perf_test::PrintResult("layer_raster_tile_iterator",
78 "", 89 "",
79 test_name, 90 test_name,
80 timer_.LapsPerSecond(), 91 timer_.LapsPerSecond(),
81 "runs/s", 92 "runs/s",
82 true); 93 true);
83 } 94 }
84 95
96 void RunEvictionIteratorConstructAndIterateTest(
97 const std::string& test_name,
98 int num_tiles,
99 const gfx::Size& viewport_size) {
100 host_impl_.SetViewportSize(viewport_size);
101 host_impl_.pending_tree()->UpdateDrawProperties();
102
103 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
104 SMOOTHNESS_TAKES_PRIORITY,
105 NEW_CONTENT_TAKES_PRIORITY};
106 int priority_count = 0;
107 timer_.Reset();
108 do {
109 int count = num_tiles;
110 PictureLayerImpl::LayerEvictionTileIterator it(
111 pending_layer_, priorities[priority_count]);
112 while (count--) {
113 ASSERT_TRUE(it) << "count: " << count;
114 ASSERT_TRUE(*it != NULL) << "count: " << count;
115 ++it;
116 }
117 priority_count = (priority_count + 1) % arraysize(priorities);
118 timer_.NextLap();
119 } while (!timer_.HasTimeLimitExpired());
120
121 perf_test::PrintResult("layer_eviction_tile_iterator_construct_and_iterate",
122 "",
123 test_name,
124 timer_.LapsPerSecond(),
125 "runs/s",
126 true);
127 }
128
129 void RunEvictionIteratorConstructTest(const std::string& test_name,
130 const gfx::Rect& viewport) {
131 host_impl_.SetViewportSize(viewport.size());
132 pending_layer_->SetScrollOffset(gfx::Vector2d(viewport.x(), viewport.y()));
133 host_impl_.pending_tree()->UpdateDrawProperties();
134
135 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
136 SMOOTHNESS_TAKES_PRIORITY,
137 NEW_CONTENT_TAKES_PRIORITY};
138 int priority_count = 0;
139 timer_.Reset();
140 do {
141 PictureLayerImpl::LayerEvictionTileIterator it(
142 pending_layer_, priorities[priority_count]);
143 priority_count = (priority_count + 1) % arraysize(priorities);
144 timer_.NextLap();
145 } while (!timer_.HasTimeLimitExpired());
146
147 perf_test::PrintResult("layer_eviction_tile_iterator_construct",
148 "",
149 test_name,
150 timer_.LapsPerSecond(),
151 "runs/s",
152 true);
153 }
154
85 protected: 155 protected:
86 TestSharedBitmapManager shared_bitmap_manager_; 156 TestSharedBitmapManager shared_bitmap_manager_;
87 FakeImplProxy proxy_; 157 FakeImplProxy proxy_;
88 FakeLayerTreeHostImpl host_impl_; 158 FakeLayerTreeHostImpl host_impl_;
89 FakePictureLayerImpl* pending_layer_; 159 FakePictureLayerImpl* pending_layer_;
90 LapTimer timer_; 160 LapTimer timer_;
91 161
92 private: 162 private:
93 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); 163 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest);
94 }; 164 };
95 165
96 TEST_F(PictureLayerImplPerfTest, LayerRasterTileIterator) { 166 TEST_F(PictureLayerImplPerfTest, LayerRasterTileIterator) {
97 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256)); 167 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256));
98 168
99 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 169 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
100 170
101 pending_layer_->AddTiling(low_res_factor); 171 pending_layer_->AddTiling(low_res_factor);
102 pending_layer_->AddTiling(0.3f); 172 pending_layer_->AddTiling(0.3f);
103 pending_layer_->AddTiling(0.7f); 173 pending_layer_->AddTiling(0.7f);
104 pending_layer_->AddTiling(1.0f); 174 pending_layer_->AddTiling(1.0f);
105 pending_layer_->AddTiling(2.0f); 175 pending_layer_->AddTiling(2.0f);
106 176
107 RunLayerRasterTileIteratorTest("32_100x100", 32, gfx::Size(100, 100)); 177 RunLayerRasterTileIteratorTest("32_100x100", 32, gfx::Size(100, 100));
108 RunLayerRasterTileIteratorTest("32_500x500", 32, gfx::Size(500, 500)); 178 RunLayerRasterTileIteratorTest("32_500x500", 32, gfx::Size(500, 500));
109 RunLayerRasterTileIteratorTest("64_100x100", 64, gfx::Size(100, 100)); 179 RunLayerRasterTileIteratorTest("64_100x100", 64, gfx::Size(100, 100));
110 RunLayerRasterTileIteratorTest("64_500x500", 64, gfx::Size(500, 500)); 180 RunLayerRasterTileIteratorTest("64_500x500", 64, gfx::Size(500, 500));
111 } 181 }
112 182
183 TEST_F(PictureLayerImplPerfTest, LayerEvictionTileIteratorConstructAndIterate) {
184 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256));
185
186 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
187
188 std::vector<Tile*> all_tiles;
189 AddTiling(low_res_factor, pending_layer_, &all_tiles);
190 AddTiling(0.3f, pending_layer_, &all_tiles);
191 AddTiling(0.7f, pending_layer_, &all_tiles);
192 AddTiling(1.0f, pending_layer_, &all_tiles);
193 AddTiling(2.0f, pending_layer_, &all_tiles);
194
195 ASSERT_TRUE(host_impl_.tile_manager() != NULL);
196 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
197
198 RunEvictionIteratorConstructAndIterateTest(
199 "32_100x100", 32, gfx::Size(100, 100));
200 RunEvictionIteratorConstructAndIterateTest(
201 "32_500x500", 32, gfx::Size(500, 500));
202 RunEvictionIteratorConstructAndIterateTest(
203 "64_100x100", 64, gfx::Size(100, 100));
204 RunEvictionIteratorConstructAndIterateTest(
205 "64_500x500", 64, gfx::Size(500, 500));
206 }
207
208 TEST_F(PictureLayerImplPerfTest, LayerEvictionTileIteratorConstruct) {
209 SetupPendingTree(gfx::Size(10000, 10000), gfx::Size(256, 256));
210
211 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
212
213 std::vector<Tile*> all_tiles;
214 AddTiling(low_res_factor, pending_layer_, &all_tiles);
215 AddTiling(0.3f, pending_layer_, &all_tiles);
216 AddTiling(0.7f, pending_layer_, &all_tiles);
217 AddTiling(1.0f, pending_layer_, &all_tiles);
218 AddTiling(2.0f, pending_layer_, &all_tiles);
219
220 ASSERT_TRUE(host_impl_.tile_manager() != NULL);
221 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
222
223 RunEvictionIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
224 RunEvictionIteratorConstructTest("5000_0_100x100",
225 gfx::Rect(5000, 0, 100, 100));
226 RunEvictionIteratorConstructTest("9999_0_100x100",
227 gfx::Rect(9999, 0, 100, 100));
228 }
229
113 } // namespace 230 } // namespace
114 } // namespace cc 231 } // 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