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

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

Issue 2109863002: cc::CompositorFrame: Implement ParamTraits vs. StructTraits perf test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove test from gyp Created 4 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
« no previous file with comments | « cc/ipc/cc_param_traits_perftest.cc ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <utility>
6
7 #include "base/test/launcher/unit_test_launcher.h"
8 #include "base/test/test_suite.h"
9 #include "cc/ipc/cc_param_traits.h"
10 #include "cc/ipc/compositor_frame.mojom.h"
11 #include "cc/ipc/compositor_frame_metadata_struct_traits.h"
12 #include "cc/ipc/compositor_frame_struct_traits.h"
13 #include "cc/ipc/render_pass_struct_traits.h"
14 #include "cc/ipc/selection_struct_traits.h"
15 #include "cc/ipc/shared_quad_state_struct_traits.h"
16 #include "cc/ipc/surface_id_struct_traits.h"
17 #include "cc/ipc/transferable_resource_struct_traits.h"
18 #include "cc/output/compositor_frame.h"
19 #include "cc/quads/picture_draw_quad.h"
20 #include "gpu/ipc/common/mailbox_holder_struct_traits.h"
21 #include "gpu/ipc/common/mailbox_struct_traits.h"
22 #include "gpu/ipc/common/sync_token_struct_traits.h"
23 #include "ipc/ipc_message.h"
24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "testing/perf/perf_test.h"
26 #include "ui/events/mojo/latency_info_struct_traits.h"
27 #include "ui/gfx/geometry/mojo/geometry.mojom.h"
28 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
29 #include "ui/gfx/mojo/selection_bound_struct_traits.h"
30
31 namespace cc {
32 namespace {
33
34 static const int kTimeLimitMillis = 2000;
35 static const int kNumWarmupRuns = 20;
36 static const int kTimeCheckInterval = 10;
37
38 class CCSerializationPerfTest : public testing::Test {
39 protected:
40 static void RunTestParamTraits(const std::string& test_name,
41 const CompositorFrame& frame) {
42 for (int i = 0; i < kNumWarmupRuns; ++i) {
43 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
44 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
45 }
46
47 base::TimeTicks start = base::TimeTicks::Now();
48 base::TimeTicks end =
49 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
50 base::TimeDelta min_time;
51 size_t count = 0;
52 while (start < end) {
53 for (int i = 0; i < kTimeCheckInterval; ++i) {
54 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
55 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
56 ++count;
57 }
58
59 base::TimeTicks now = base::TimeTicks::Now();
60 if (now - start < min_time || min_time.is_zero())
61 min_time = now - start;
62 start = base::TimeTicks::Now();
63 }
64
65 perf_test::PrintResult(
66 "ParamTraits: min_frame_serialization_time", "", test_name,
67 min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true);
68 perf_test::PrintResult("ParamTraits: num runs in 2 seconds", "", test_name,
69 count, "", true);
70 }
71
72 static void RunTestStructTraits(const std::string& test_name,
73 const CompositorFrame& frame) {
74 for (int i = 0; i < kNumWarmupRuns; ++i) {
75 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame);
76 DCHECK_GT(data.size(), 0u);
77 }
78
79 base::TimeTicks start = base::TimeTicks::Now();
80 base::TimeTicks end =
81 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
82 base::TimeDelta min_time;
83 size_t count = 0;
84 while (start < end) {
85 for (int i = 0; i < kTimeCheckInterval; ++i) {
86 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame);
87 DCHECK_GT(data.size(), 0u);
88 ++count;
89 }
90
91 base::TimeTicks now = base::TimeTicks::Now();
92 if (now - start < min_time || min_time.is_zero())
93 min_time = now - start;
94 start = base::TimeTicks::Now();
95 }
96
97 perf_test::PrintResult(
98 "StructTraits min_frame_serialization_time", "", test_name,
99 min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true);
100 perf_test::PrintResult("StructTraits: num runs in 2 seconds", "", test_name,
101 count, "", true);
102 }
103
104 static void RunTest(const std::string& test_name, CompositorFrame frame) {
105 RunTestStructTraits(test_name, frame);
106 RunTestParamTraits(test_name, frame);
107 }
108 };
109
110 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) {
111 CompositorFrame frame;
112
113 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
114 render_pass->CreateAndAppendSharedQuadState();
115 for (int i = 0; i < 4000; ++i) {
116 const gfx::Rect bounds(100, 100, 100, 100);
117 const bool kForceAntiAliasingOff = true;
118 SolidColorDrawQuad* quad =
119 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
120 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
121 SK_ColorRED, kForceAntiAliasingOff);
122 }
123
124 frame.delegated_frame_data.reset(new DelegatedFrameData);
125 frame.delegated_frame_data->render_pass_list.push_back(
126 std::move(render_pass));
127
128 RunTest("DelegatedFrame_ManyQuads_1_4000", std::move(frame));
129 }
130
131 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_100000) {
132 CompositorFrame frame;
133
134 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
135 render_pass->CreateAndAppendSharedQuadState();
136 for (int i = 0; i < 100000; ++i) {
137 const gfx::Rect bounds(100, 100, 100, 100);
138 const bool kForceAntiAliasingOff = true;
139 SolidColorDrawQuad* quad =
140 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
141 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
142 SK_ColorRED, kForceAntiAliasingOff);
143 }
144
145 frame.delegated_frame_data.reset(new DelegatedFrameData);
146 frame.delegated_frame_data->render_pass_list.push_back(
147 std::move(render_pass));
148
149 RunTest("DelegatedFrame_ManyQuads_1_100000", std::move(frame));
150 }
151
152 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_4000_4000) {
153 CompositorFrame frame;
154
155 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
156 for (int i = 0; i < 4000; ++i) {
157 const gfx::Rect bounds(100, 100, 100, 100);
158 const bool kForceAntiAliasingOff = true;
159 render_pass->CreateAndAppendSharedQuadState();
160 SolidColorDrawQuad* quad =
161 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
162 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
163 SK_ColorRED, kForceAntiAliasingOff);
164 }
165
166 frame.delegated_frame_data.reset(new DelegatedFrameData);
167 frame.delegated_frame_data->render_pass_list.push_back(
168 std::move(render_pass));
169
170 RunTest("DelegatedFrame_ManyQuads_4000_4000", std::move(frame));
171 }
172
173 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_100000_100000) {
174 CompositorFrame frame;
175
176 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
177 for (int i = 0; i < 100000; ++i) {
178 render_pass->CreateAndAppendSharedQuadState();
179 const gfx::Rect bounds(100, 100, 100, 100);
180 const bool kForceAntiAliasingOff = true;
181 SolidColorDrawQuad* quad =
182 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
183 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
184 SK_ColorRED, kForceAntiAliasingOff);
185 }
186
187 frame.delegated_frame_data.reset(new DelegatedFrameData);
188 frame.delegated_frame_data->render_pass_list.push_back(
189 std::move(render_pass));
190
191 RunTest("DelegatedFrame_ManyQuads_100000_100000", std::move(frame));
192 }
193
194 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) {
195 CompositorFrame frame;
196 frame.delegated_frame_data.reset(new DelegatedFrameData);
197
198 for (int i = 0; i < 1000; ++i) {
199 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
200 for (int j = 0; j < 100; ++j) {
201 render_pass->CreateAndAppendSharedQuadState();
202 const gfx::Rect bounds(100, 100, 100, 100);
203 const bool kForceAntiAliasingOff = true;
204 SolidColorDrawQuad* quad =
205 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
206 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
207 SK_ColorRED, kForceAntiAliasingOff);
208 }
209 frame.delegated_frame_data->render_pass_list.push_back(
210 std::move(render_pass));
211 }
212
213 RunTest("DelegatedFrame_ManyRenderPasses_10000_100", std::move(frame));
214 }
215
216 } // namespace
217 } // namespace cc
OLDNEW
« no previous file with comments | « cc/ipc/cc_param_traits_perftest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698