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

Side by Side Diff: cc/ipc/cc_serialization_perftest.cc

Issue 2190943002: cc serialization perf: Add a couple more tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ali's comments Created 4 years, 4 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 <utility> 5 #include <utility>
6 6
7 #include "base/test/launcher/unit_test_launcher.h" 7 #include "base/test/launcher/unit_test_launcher.h"
8 #include "base/test/test_suite.h" 8 #include "base/test/test_suite.h"
9 #include "cc/ipc/cc_param_traits.h" 9 #include "cc/ipc/cc_param_traits.h"
10 #include "cc/ipc/compositor_frame.mojom.h" 10 #include "cc/ipc/compositor_frame.mojom.h"
(...skipping 17 matching lines...) Expand all
28 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" 28 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
29 #include "ui/gfx/mojo/selection_bound_struct_traits.h" 29 #include "ui/gfx/mojo/selection_bound_struct_traits.h"
30 30
31 namespace cc { 31 namespace cc {
32 namespace { 32 namespace {
33 33
34 static const int kTimeLimitMillis = 2000; 34 static const int kTimeLimitMillis = 2000;
35 static const int kNumWarmupRuns = 20; 35 static const int kNumWarmupRuns = 20;
36 static const int kTimeCheckInterval = 10; 36 static const int kTimeCheckInterval = 10;
37 37
38 enum class UseSingleSharedQuadState { YES, NO };
39
38 class CCSerializationPerfTest : public testing::Test { 40 class CCSerializationPerfTest : public testing::Test {
39 protected: 41 protected:
40 static bool ReadMessage(const IPC::Message* msg, CompositorFrame* frame) { 42 static bool ReadMessage(const IPC::Message* msg, CompositorFrame* frame) {
41 base::PickleIterator iter(*msg); 43 base::PickleIterator iter(*msg);
42 return IPC::ParamTraits<CompositorFrame>::Read(msg, &iter, frame); 44 return IPC::ParamTraits<CompositorFrame>::Read(msg, &iter, frame);
43 } 45 }
44 46
45 static void RunDeserializationTestParamTraits(const std::string& test_name, 47 static void RunDeserializationTestParamTraits(const std::string& test_name,
46 const CompositorFrame& frame) { 48 const CompositorFrame& frame) {
47 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 49 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 174 }
173 175
174 perf_test::PrintResult( 176 perf_test::PrintResult(
175 "StructTraits serialization min_frame_serialization_time", "", 177 "StructTraits serialization min_frame_serialization_time", "",
176 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", 178 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us",
177 true); 179 true);
178 perf_test::PrintResult("StructTraits serialization: num runs in 2 seconds", 180 perf_test::PrintResult("StructTraits serialization: num runs in 2 seconds",
179 "", test_name, count, "", true); 181 "", test_name, count, "", true);
180 } 182 }
181 183
184 static void RunCompositorFrameTest(const std::string& test_name,
185 uint32_t num_quads,
186 uint32_t num_passes,
187 UseSingleSharedQuadState single_sqs) {
188 CompositorFrame frame;
189 frame.delegated_frame_data.reset(new DelegatedFrameData);
190
191 for (uint32_t i = 0; i < num_passes; ++i) {
192 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
193 render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
194 gfx::Transform());
195 for (uint32_t j = 0; j < num_quads; ++j) {
196 if (j == 0 || single_sqs == UseSingleSharedQuadState::NO)
197 render_pass->CreateAndAppendSharedQuadState();
198 const gfx::Rect bounds(100, 100, 100, 100);
199 const bool kForceAntiAliasingOff = true;
200 SolidColorDrawQuad* quad =
201 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
202 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
203 SK_ColorRED, kForceAntiAliasingOff);
204 }
205 frame.delegated_frame_data->render_pass_list.push_back(
206 std::move(render_pass));
207 }
208 RunTest(test_name, std::move(frame));
209 }
210
182 static void RunTest(const std::string& test_name, CompositorFrame frame) { 211 static void RunTest(const std::string& test_name, CompositorFrame frame) {
183 RunSerializationTestStructTraits(test_name, frame); 212 RunSerializationTestStructTraits(test_name, frame);
184 RunDeserializationTestStructTraits(test_name, frame); 213 RunDeserializationTestStructTraits(test_name, frame);
185 RunSerializationTestParamTraits(test_name, frame); 214 RunSerializationTestParamTraits(test_name, frame);
186 RunDeserializationTestParamTraits(test_name, frame); 215 RunDeserializationTestParamTraits(test_name, frame);
187 } 216 }
188 }; 217 };
189 218
190 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) { 219 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) {
191 CompositorFrame frame; 220 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1,
192 221 UseSingleSharedQuadState::YES);
193 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
194 render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
195 gfx::Transform());
196 render_pass->CreateAndAppendSharedQuadState();
197 for (int i = 0; i < 4000; ++i) {
198 const gfx::Rect bounds(100, 100, 100, 100);
199 const bool kForceAntiAliasingOff = true;
200 SolidColorDrawQuad* quad =
201 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
202 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
203 SK_ColorRED, kForceAntiAliasingOff);
204 }
205
206 frame.delegated_frame_data.reset(new DelegatedFrameData);
207 frame.delegated_frame_data->render_pass_list.push_back(
208 std::move(render_pass));
209
210 RunTest("DelegatedFrame_ManyQuads_1_4000", std::move(frame));
211 } 222 }
212 223
213 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_100000) { 224 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_100000) {
214 CompositorFrame frame; 225 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_100000", 100000, 1,
215 226 UseSingleSharedQuadState::YES);
216 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
217 render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
218 gfx::Transform());
219 render_pass->CreateAndAppendSharedQuadState();
220 for (int i = 0; i < 100000; ++i) {
221 const gfx::Rect bounds(100, 100, 100, 100);
222 const bool kForceAntiAliasingOff = true;
223 SolidColorDrawQuad* quad =
224 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
225 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
226 SK_ColorRED, kForceAntiAliasingOff);
227 }
228
229 frame.delegated_frame_data.reset(new DelegatedFrameData);
230 frame.delegated_frame_data->render_pass_list.push_back(
231 std::move(render_pass));
232
233 RunTest("DelegatedFrame_ManyQuads_1_100000", std::move(frame));
234 } 227 }
235 228
236 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_4000_4000) { 229 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_4000_4000) {
237 CompositorFrame frame; 230 RunCompositorFrameTest("DelegatedFrame_ManyQuads_4000_4000", 4000, 1,
238 231 UseSingleSharedQuadState::NO);
239 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
240 render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
241 gfx::Transform());
242 for (int i = 0; i < 4000; ++i) {
243 const gfx::Rect bounds(100, 100, 100, 100);
244 const bool kForceAntiAliasingOff = true;
245 render_pass->CreateAndAppendSharedQuadState();
246 SolidColorDrawQuad* quad =
247 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
248 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
249 SK_ColorRED, kForceAntiAliasingOff);
250 }
251
252 frame.delegated_frame_data.reset(new DelegatedFrameData);
253 frame.delegated_frame_data->render_pass_list.push_back(
254 std::move(render_pass));
255
256 RunTest("DelegatedFrame_ManyQuads_4000_4000", std::move(frame));
257 } 232 }
258 233
259 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_100000_100000) { 234 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_100000_100000) {
260 CompositorFrame frame; 235 RunCompositorFrameTest("DelegatedFrame_ManyQuads_100000_100000", 100000, 1,
236 UseSingleSharedQuadState::NO);
237 }
261 238
262 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 239 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_5_100) {
263 render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), 240 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_5_100", 100, 5,
264 gfx::Transform()); 241 UseSingleSharedQuadState::NO);
265 for (int i = 0; i < 100000; ++i) { 242 }
266 render_pass->CreateAndAppendSharedQuadState();
267 const gfx::Rect bounds(100, 100, 100, 100);
268 const bool kForceAntiAliasingOff = true;
269 SolidColorDrawQuad* quad =
270 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
271 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
272 SK_ColorRED, kForceAntiAliasingOff);
273 }
274 243
275 frame.delegated_frame_data.reset(new DelegatedFrameData); 244 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_10_500) {
276 frame.delegated_frame_data->render_pass_list.push_back( 245 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_10_500", 500, 10,
277 std::move(render_pass)); 246 UseSingleSharedQuadState::NO);
278
279 RunTest("DelegatedFrame_ManyQuads_100000_100000", std::move(frame));
280 } 247 }
281 248
282 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) { 249 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) {
283 CompositorFrame frame; 250 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_10000_100", 100, 1000,
ajuma 2016/07/28 20:06:29 Should the constant here be 10000 rather than 1000
Fady Samuel 2016/07/28 20:16:14 Changed the name because I don't want to lose the
284 frame.delegated_frame_data.reset(new DelegatedFrameData); 251 UseSingleSharedQuadState::NO);
285
286 for (int i = 0; i < 1000; ++i) {
287 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
288 render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
289 gfx::Transform());
290 for (int j = 0; j < 100; ++j) {
291 render_pass->CreateAndAppendSharedQuadState();
292 const gfx::Rect bounds(100, 100, 100, 100);
293 const bool kForceAntiAliasingOff = true;
294 SolidColorDrawQuad* quad =
295 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
296 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
297 SK_ColorRED, kForceAntiAliasingOff);
298 }
299 frame.delegated_frame_data->render_pass_list.push_back(
300 std::move(render_pass));
301 }
302
303 RunTest("DelegatedFrame_ManyRenderPasses_10000_100", std::move(frame));
304 } 252 }
305 253
306 } // namespace 254 } // namespace
307 } // namespace cc 255 } // 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