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

Side by Side Diff: cc/ipc/cc_param_traits_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: Rebased + Renamed test 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/BUILD.gn ('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
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"
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"
10 #include "cc/output/compositor_frame.h" 18 #include "cc/output/compositor_frame.h"
11 #include "cc/quads/picture_draw_quad.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"
12 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
13 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/perf/perf_test.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"
15 30
16 using cc::CompositorFrame; 31 using cc::CompositorFrame;
17 using cc::DelegatedFrameData; 32 using cc::DelegatedFrameData;
18 using cc::DrawQuad; 33 using cc::DrawQuad;
19 using cc::PictureDrawQuad;
20 using cc::RenderPass; 34 using cc::RenderPass;
21 using cc::SharedQuadState; 35 using cc::SharedQuadState;
36 using cc::SolidColorDrawQuad;
22 37
23 namespace content { 38 namespace content {
24 namespace { 39 namespace {
25 40
26 static const int kTimeLimitMillis = 2000; 41 static const int kTimeLimitMillis = 2000;
27 static const int kNumWarmupRuns = 20; 42 static const int kNumWarmupRuns = 20;
28 static const int kTimeCheckInterval = 10; 43 static const int kTimeCheckInterval = 10;
29 44
30 class CCParamTraitsPerfTest : public testing::Test { 45 class CCSerializationPerfTest : public testing::Test {
31 protected: 46 protected:
32 static void RunTest(const std::string& test_name, 47 static void RunTestParamTraits(const std::string& test_name,
33 const CompositorFrame& frame) { 48 const CompositorFrame& frame) {
34 for (int i = 0; i < kNumWarmupRuns; ++i) { 49 for (int i = 0; i < kNumWarmupRuns; ++i) {
35 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 50 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
36 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame); 51 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
37 } 52 }
38 53
39 base::TimeTicks start = base::TimeTicks::Now(); 54 base::TimeTicks start = base::TimeTicks::Now();
40 base::TimeTicks end = 55 base::TimeTicks end =
41 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis); 56 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
42 base::TimeDelta min_time; 57 base::TimeDelta min_time;
43 int count = 0; 58 size_t count = 0;
44 while (start < end) { 59 while (start < end) {
45 for (int i = 0; i < kTimeCheckInterval; ++i) { 60 for (int i = 0; i < kTimeCheckInterval; ++i) {
46 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 61 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
47 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame); 62 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
48 ++count; 63 ++count;
49 } 64 }
50 65
51 base::TimeTicks now = base::TimeTicks::Now(); 66 base::TimeTicks now = base::TimeTicks::Now();
52 if (now - start < min_time || min_time.is_zero()) 67 if (now - start < min_time || min_time.is_zero())
53 min_time = now - start; 68 min_time = now - start;
54 start = base::TimeTicks::Now(); 69 start = base::TimeTicks::Now();
55 } 70 }
56 71
57 perf_test::PrintResult( 72 perf_test::PrintResult(
58 "min_frame_serialization_time", "", test_name, 73 "ParamTraits: min_frame_serialization_time", "", test_name,
59 min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true); 74 min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true);
75 perf_test::PrintResult("ParamTraits: num runs in 2 seconds", "", test_name,
76 count, "", true);
77 }
78
79 static void RunTestStructTraits(const std::string& test_name,
80 const CompositorFrame& frame) {
81 for (int i = 0; i < kNumWarmupRuns; ++i) {
82 mojo::Array<uint8_t> data = cc::mojom::CompositorFrame::Serialize(&frame);
83 DCHECK_GT(data.size(), 0u);
84 }
85
86 base::TimeTicks start = base::TimeTicks::Now();
87 base::TimeTicks end =
88 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
89 base::TimeDelta min_time;
90 size_t count = 0;
91 while (start < end) {
92 for (int i = 0; i < kTimeCheckInterval; ++i) {
93 mojo::Array<uint8_t> data =
94 cc::mojom::CompositorFrame::Serialize(&frame);
95 DCHECK_GT(data.size(), 0u);
96 ++count;
97 }
98
99 base::TimeTicks now = base::TimeTicks::Now();
100 if (now - start < min_time || min_time.is_zero())
101 min_time = now - start;
102 start = base::TimeTicks::Now();
103 }
104
105 perf_test::PrintResult(
106 "StructTraits min_frame_serialization_time", "", test_name,
107 min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", true);
108 perf_test::PrintResult("StructTraits: num runs in 2 seconds", "", test_name,
109 count, "", true);
110 }
111
112 static void RunTest(const std::string& test_name, CompositorFrame frame) {
113 RunTestStructTraits(test_name, frame);
114 RunTestParamTraits(test_name, frame);
60 } 115 }
61 }; 116 };
62 117
63 TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_1_4000) { 118 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) {
64 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 119 CompositorFrame frame;
65 120
66 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 121 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
67 render_pass->CreateAndAppendSharedQuadState(); 122 render_pass->CreateAndAppendSharedQuadState();
68 for (int i = 0; i < 4000; ++i) { 123 for (int i = 0; i < 4000; ++i) {
69 PictureDrawQuad* quad = 124 const gfx::Rect bounds(100, 100, 100, 100);
70 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 125 const bool force_anti_aliasing_off = true;
yzshen1 2016/07/06 17:11:56 style nit: compile-time constants are named kLikeT
Fady Samuel 2016/07/06 17:25:47 Done.
71 quad->shared_quad_state = render_pass->shared_quad_state_list.back(); 126 SolidColorDrawQuad* quad =
127 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
128 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
129 SK_ColorRED, force_anti_aliasing_off);
72 } 130 }
73 131
74 frame->delegated_frame_data.reset(new DelegatedFrameData); 132 frame.delegated_frame_data.reset(new DelegatedFrameData);
75 frame->delegated_frame_data->render_pass_list.push_back( 133 frame.delegated_frame_data->render_pass_list.push_back(
76 std::move(render_pass)); 134 std::move(render_pass));
77 135
78 RunTest("DelegatedFrame_ManyQuads_1_4000", *frame); 136 RunTest("DelegatedFrame_ManyQuads_1_4000", std::move(frame));
79 } 137 }
80 138
81 TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_1_100000) { 139 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_100000) {
82 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 140 CompositorFrame frame;
83 141
84 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 142 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
85 render_pass->CreateAndAppendSharedQuadState(); 143 render_pass->CreateAndAppendSharedQuadState();
86 for (int i = 0; i < 100000; ++i) { 144 for (int i = 0; i < 100000; ++i) {
87 PictureDrawQuad* quad = 145 const gfx::Rect bounds(100, 100, 100, 100);
88 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 146 const bool force_anti_aliasing_off = true;
89 quad->shared_quad_state = render_pass->shared_quad_state_list.back(); 147 SolidColorDrawQuad* quad =
148 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
149 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
150 SK_ColorRED, force_anti_aliasing_off);
90 } 151 }
91 152
92 frame->delegated_frame_data.reset(new DelegatedFrameData); 153 frame.delegated_frame_data.reset(new DelegatedFrameData);
93 frame->delegated_frame_data->render_pass_list.push_back( 154 frame.delegated_frame_data->render_pass_list.push_back(
94 std::move(render_pass)); 155 std::move(render_pass));
95 156
96 RunTest("DelegatedFrame_ManyQuads_1_100000", *frame); 157 RunTest("DelegatedFrame_ManyQuads_1_100000", std::move(frame));
97 } 158 }
98 159
99 TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_4000_4000) { 160 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_4000_4000) {
100 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 161 CompositorFrame frame;
101 162
102 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 163 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
103 for (int i = 0; i < 4000; ++i) { 164 for (int i = 0; i < 4000; ++i) {
165 const gfx::Rect bounds(100, 100, 100, 100);
166 const bool force_anti_aliasing_off = true;
104 render_pass->CreateAndAppendSharedQuadState(); 167 render_pass->CreateAndAppendSharedQuadState();
105 PictureDrawQuad* quad = 168 SolidColorDrawQuad* quad =
106 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 169 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
107 quad->shared_quad_state = render_pass->shared_quad_state_list.back(); 170 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
171 SK_ColorRED, force_anti_aliasing_off);
108 } 172 }
109 173
110 frame->delegated_frame_data.reset(new DelegatedFrameData); 174 frame.delegated_frame_data.reset(new DelegatedFrameData);
111 frame->delegated_frame_data->render_pass_list.push_back( 175 frame.delegated_frame_data->render_pass_list.push_back(
112 std::move(render_pass)); 176 std::move(render_pass));
113 177
114 RunTest("DelegatedFrame_ManyQuads_4000_4000", *frame); 178 RunTest("DelegatedFrame_ManyQuads_4000_4000", std::move(frame));
115 } 179 }
116 180
117 TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyQuads_100000_100000) { 181 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_100000_100000) {
118 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 182 CompositorFrame frame;
119 183
120 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 184 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
121 for (int i = 0; i < 100000; ++i) { 185 for (int i = 0; i < 100000; ++i) {
122 render_pass->CreateAndAppendSharedQuadState(); 186 render_pass->CreateAndAppendSharedQuadState();
123 PictureDrawQuad* quad = 187 const gfx::Rect bounds(100, 100, 100, 100);
124 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 188 const bool force_anti_aliasing_off = true;
125 quad->shared_quad_state = render_pass->shared_quad_state_list.back(); 189 SolidColorDrawQuad* quad =
190 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
191 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
192 SK_ColorRED, force_anti_aliasing_off);
126 } 193 }
127 194
128 frame->delegated_frame_data.reset(new DelegatedFrameData); 195 frame.delegated_frame_data.reset(new DelegatedFrameData);
129 frame->delegated_frame_data->render_pass_list.push_back( 196 frame.delegated_frame_data->render_pass_list.push_back(
130 std::move(render_pass)); 197 std::move(render_pass));
131 198
132 RunTest("DelegatedFrame_ManyQuads_100000_100000", *frame); 199 RunTest("DelegatedFrame_ManyQuads_100000_100000", std::move(frame));
133 } 200 }
134 201
135 TEST_F(CCParamTraitsPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) { 202 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_10000_100) {
136 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); 203 CompositorFrame frame;
137 frame->delegated_frame_data.reset(new DelegatedFrameData); 204 frame.delegated_frame_data.reset(new DelegatedFrameData);
138 205
139 for (int i = 0; i < 1000; ++i) { 206 for (int i = 0; i < 1000; ++i) {
140 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 207 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
141 for (int j = 0; j < 100; ++j) { 208 for (int j = 0; j < 100; ++j) {
142 render_pass->CreateAndAppendSharedQuadState(); 209 render_pass->CreateAndAppendSharedQuadState();
143 PictureDrawQuad* quad = 210 const gfx::Rect bounds(100, 100, 100, 100);
144 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); 211 const bool force_anti_aliasing_off = true;
145 quad->shared_quad_state = render_pass->shared_quad_state_list.back(); 212 SolidColorDrawQuad* quad =
213 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
214 quad->SetNew(render_pass->shared_quad_state_list.back(), bounds, bounds,
215 SK_ColorRED, force_anti_aliasing_off);
146 } 216 }
147 frame->delegated_frame_data->render_pass_list.push_back( 217 frame.delegated_frame_data->render_pass_list.push_back(
148 std::move(render_pass)); 218 std::move(render_pass));
149 } 219 }
150 220
151 RunTest("DelegatedFrame_ManyRenderPasses_10000_100", *frame); 221 RunTest("DelegatedFrame_ManyRenderPasses_10000_100", std::move(frame));
152 } 222 }
153 223
154 } // namespace 224 } // namespace
155 } // namespace content 225 } // namespace content
OLDNEW
« no previous file with comments | « cc/ipc/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698