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

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

Issue 2196873002: CC serialization perftests: more accurate "num runs in 2 seconds". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 49 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
50 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame); 50 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
51 for (int i = 0; i < kNumWarmupRuns; ++i) { 51 for (int i = 0; i < kNumWarmupRuns; ++i) {
52 CompositorFrame compositor_frame; 52 CompositorFrame compositor_frame;
53 ReadMessage(&msg, &compositor_frame); 53 ReadMessage(&msg, &compositor_frame);
54 } 54 }
55 55
56 base::TimeTicks start = base::TimeTicks::Now(); 56 base::TimeTicks start = base::TimeTicks::Now();
57 base::TimeTicks end = 57 base::TimeTicks end =
58 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis); 58 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
59 base::TimeTicks now = start;
59 base::TimeDelta min_time; 60 base::TimeDelta min_time;
60 size_t count = 0; 61 size_t count = 0;
61 while (start < end) { 62 while (start < end) {
62 for (int i = 0; i < kTimeCheckInterval; ++i) { 63 for (int i = 0; i < kTimeCheckInterval; ++i) {
63 ++count;
64 CompositorFrame compositor_frame; 64 CompositorFrame compositor_frame;
65 ReadMessage(&msg, &compositor_frame); 65 ReadMessage(&msg, &compositor_frame);
66 now = base::TimeTicks::Now();
67 // We don't count iterations after the end time.
68 if (now < end)
69 ++count;
66 } 70 }
67 71
68 base::TimeTicks now = base::TimeTicks::Now();
69 if (now - start < min_time || min_time.is_zero()) 72 if (now - start < min_time || min_time.is_zero())
70 min_time = now - start; 73 min_time = now - start;
71 start = base::TimeTicks::Now(); 74 start = now;
72 } 75 }
73 76
74 perf_test::PrintResult( 77 perf_test::PrintResult(
75 "ParamTraits deserialization: min_frame_deserialization_time", "", 78 "ParamTraits deserialization: min_frame_deserialization_time", "",
76 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", 79 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us",
77 true); 80 true);
78 perf_test::PrintResult("ParamTraits deserialization: num runs in 2 seconds", 81 perf_test::PrintResult("ParamTraits deserialization: num runs in 2 seconds",
79 "", test_name, count, "", true); 82 "", test_name, count, "", true);
80 } 83 }
81 84
82 static void RunSerializationTestParamTraits(const std::string& test_name, 85 static void RunSerializationTestParamTraits(const std::string& test_name,
83 const CompositorFrame& frame) { 86 const CompositorFrame& frame) {
84 for (int i = 0; i < kNumWarmupRuns; ++i) { 87 for (int i = 0; i < kNumWarmupRuns; ++i) {
85 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 88 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
86 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame); 89 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
87 } 90 }
88 91
89 base::TimeTicks start = base::TimeTicks::Now(); 92 base::TimeTicks start = base::TimeTicks::Now();
90 base::TimeTicks end = 93 base::TimeTicks end =
91 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis); 94 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
95 base::TimeTicks now = start;
92 base::TimeDelta min_time; 96 base::TimeDelta min_time;
93 size_t count = 0; 97 size_t count = 0;
94 while (start < end) { 98 while (start < end) {
95 for (int i = 0; i < kTimeCheckInterval; ++i) { 99 for (int i = 0; i < kTimeCheckInterval; ++i) {
96 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 100 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
97 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame); 101 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame);
98 ++count; 102 now = base::TimeTicks::Now();
103 // We don't count iterations after the end time.
104 if (now < end)
105 ++count;
99 } 106 }
100 107
101 base::TimeTicks now = base::TimeTicks::Now();
102 if (now - start < min_time || min_time.is_zero()) 108 if (now - start < min_time || min_time.is_zero())
103 min_time = now - start; 109 min_time = now - start;
104 start = base::TimeTicks::Now(); 110 start = now;
105 } 111 }
106 112
107 perf_test::PrintResult( 113 perf_test::PrintResult(
108 "ParamTraits serialization: min_frame_serialization_time", "", 114 "ParamTraits serialization: min_frame_serialization_time", "",
109 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", 115 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us",
110 true); 116 true);
111 perf_test::PrintResult("ParamTraits serialization: num runs in 2 seconds", 117 perf_test::PrintResult("ParamTraits serialization: num runs in 2 seconds",
112 "", test_name, count, "", true); 118 "", test_name, count, "", true);
113 } 119 }
114 120
115 static void RunDeserializationTestStructTraits(const std::string& test_name, 121 static void RunDeserializationTestStructTraits(const std::string& test_name,
116 const CompositorFrame& frame) { 122 const CompositorFrame& frame) {
117 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame); 123 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame);
118 DCHECK_GT(data.size(), 0u); 124 DCHECK_GT(data.size(), 0u);
119 for (int i = 0; i < kNumWarmupRuns; ++i) { 125 for (int i = 0; i < kNumWarmupRuns; ++i) {
120 CompositorFrame compositor_frame; 126 CompositorFrame compositor_frame;
121 mojom::CompositorFrame::Deserialize(data, &compositor_frame); 127 mojom::CompositorFrame::Deserialize(data, &compositor_frame);
122 } 128 }
123 129
124 base::TimeTicks start = base::TimeTicks::Now(); 130 base::TimeTicks start = base::TimeTicks::Now();
125 base::TimeTicks end = 131 base::TimeTicks end =
126 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis); 132 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
133 base::TimeTicks now = start;
127 base::TimeDelta min_time; 134 base::TimeDelta min_time;
128 size_t count = 0; 135 size_t count = 0;
129 while (start < end) { 136 while (start < end) {
130 for (int i = 0; i < kTimeCheckInterval; ++i) { 137 for (int i = 0; i < kTimeCheckInterval; ++i) {
131 CompositorFrame compositor_frame; 138 CompositorFrame compositor_frame;
132 mojom::CompositorFrame::Deserialize(data, &compositor_frame); 139 mojom::CompositorFrame::Deserialize(data, &compositor_frame);
133 ++count; 140 now = base::TimeTicks::Now();
141 // We don't count iterations after the end time.
142 if (now < end)
143 ++count;
134 } 144 }
135 145
136 base::TimeTicks now = base::TimeTicks::Now();
137 if (now - start < min_time || min_time.is_zero()) 146 if (now - start < min_time || min_time.is_zero())
138 min_time = now - start; 147 min_time = now - start;
139 start = base::TimeTicks::Now(); 148 start = now;
140 } 149 }
141 150
142 perf_test::PrintResult( 151 perf_test::PrintResult(
143 "StructTraits deserialization min_frame_deserialization_time", "", 152 "StructTraits deserialization min_frame_deserialization_time", "",
144 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", 153 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us",
145 true); 154 true);
146 perf_test::PrintResult( 155 perf_test::PrintResult(
147 "StructTraits deserialization: num runs in 2 seconds", "", test_name, 156 "StructTraits deserialization: num runs in 2 seconds", "", test_name,
148 count, "", true); 157 count, "", true);
149 } 158 }
150 159
151 static void RunSerializationTestStructTraits(const std::string& test_name, 160 static void RunSerializationTestStructTraits(const std::string& test_name,
152 const CompositorFrame& frame) { 161 const CompositorFrame& frame) {
153 for (int i = 0; i < kNumWarmupRuns; ++i) { 162 for (int i = 0; i < kNumWarmupRuns; ++i) {
154 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame); 163 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame);
155 DCHECK_GT(data.size(), 0u); 164 DCHECK_GT(data.size(), 0u);
156 } 165 }
157 166
158 base::TimeTicks start = base::TimeTicks::Now(); 167 base::TimeTicks start = base::TimeTicks::Now();
159 base::TimeTicks end = 168 base::TimeTicks end =
160 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis); 169 start + base::TimeDelta::FromMilliseconds(kTimeLimitMillis);
170 base::TimeTicks now = start;
161 base::TimeDelta min_time; 171 base::TimeDelta min_time;
162 size_t count = 0; 172 size_t count = 0;
163 while (start < end) { 173 while (start < end) {
164 for (int i = 0; i < kTimeCheckInterval; ++i) { 174 for (int i = 0; i < kTimeCheckInterval; ++i) {
165 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame); 175 mojo::Array<uint8_t> data = mojom::CompositorFrame::Serialize(&frame);
166 DCHECK_GT(data.size(), 0u); 176 DCHECK_GT(data.size(), 0u);
167 ++count; 177 now = base::TimeTicks::Now();
178 // We don't count iterations after the end time.
179 if (now < end)
180 ++count;
168 } 181 }
169 182
170 base::TimeTicks now = base::TimeTicks::Now();
171 if (now - start < min_time || min_time.is_zero()) 183 if (now - start < min_time || min_time.is_zero())
172 min_time = now - start; 184 min_time = now - start;
173 start = base::TimeTicks::Now(); 185 start = now;
174 } 186 }
175 187
176 perf_test::PrintResult( 188 perf_test::PrintResult(
177 "StructTraits serialization min_frame_serialization_time", "", 189 "StructTraits serialization min_frame_serialization_time", "",
178 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", 190 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us",
179 true); 191 true);
180 perf_test::PrintResult("StructTraits serialization: num runs in 2 seconds", 192 perf_test::PrintResult("StructTraits serialization: num runs in 2 seconds",
181 "", test_name, count, "", true); 193 "", test_name, count, "", true);
182 } 194 }
183 195
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 UseSingleSharedQuadState::NO); 258 UseSingleSharedQuadState::NO);
247 } 259 }
248 260
249 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_1000_100) { 261 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyRenderPasses_1000_100) {
250 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_10000_100", 100, 1000, 262 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_10000_100", 100, 1000,
251 UseSingleSharedQuadState::NO); 263 UseSingleSharedQuadState::NO);
252 } 264 }
253 265
254 } // namespace 266 } // namespace
255 } // namespace cc 267 } // 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