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

Side by Side Diff: mojo/public/cpp/bindings/tests/bindings_perftest.cc

Issue 2660733002: Mojo C++ bindings: introduce an optional array to store transferred interface IDs in messages. (Closed)
Patch Set: . Created 3 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 uint32_t count = message->header()->name; 147 uint32_t count = message->header()->name;
148 if (!quit_closure_.is_null()) { 148 if (!quit_closure_.is_null()) {
149 count++; 149 count++;
150 if (count >= expected_count_) { 150 if (count >= expected_count_) {
151 end_time_ = base::TimeTicks::Now(); 151 end_time_ = base::TimeTicks::Now();
152 quit_closure_.Run(); 152 quit_closure_.Run();
153 return true; 153 return true;
154 } 154 }
155 } 155 }
156 156
157 internal::MessageBuilder builder(count, 8); 157 internal::MessageBuilder builder(count, 0, 8, 0);
158 bool result = sender_->Accept(builder.message()); 158 bool result = sender_->Accept(builder.message());
159 DCHECK(result); 159 DCHECK(result);
160 return true; 160 return true;
161 } 161 }
162 162
163 bool AcceptWithResponder(Message* message, 163 bool AcceptWithResponder(Message* message,
164 MessageReceiverWithStatus* responder) override { 164 MessageReceiverWithStatus* responder) override {
165 NOTREACHED(); 165 NOTREACHED();
166 return true; 166 return true;
167 } 167 }
168 168
169 base::TimeDelta Serve(uint32_t expected_count) { 169 base::TimeDelta Serve(uint32_t expected_count) {
170 base::RunLoop run_loop; 170 base::RunLoop run_loop;
171 171
172 expected_count_ = expected_count; 172 expected_count_ = expected_count;
173 quit_closure_ = run_loop.QuitClosure(); 173 quit_closure_ = run_loop.QuitClosure();
174 174
175 start_time_ = base::TimeTicks::Now(); 175 start_time_ = base::TimeTicks::Now();
176 internal::MessageBuilder builder(0, 8); 176 internal::MessageBuilder builder(0, 0, 8, 0);
177 bool result = sender_->Accept(builder.message()); 177 bool result = sender_->Accept(builder.message());
178 DCHECK(result); 178 DCHECK(result);
179 179
180 run_loop.Run(); 180 run_loop.Run();
181 181
182 return end_time_ - start_time_; 182 return end_time_ - start_time_;
183 } 183 }
184 184
185 private: 185 private:
186 base::TimeTicks start_time_; 186 base::TimeTicks start_time_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 InterfaceEndpointClient client( 255 InterfaceEndpointClient client(
256 router->CreateLocalEndpointHandle(kMasterInterfaceId), &receiver, nullptr, 256 router->CreateLocalEndpointHandle(kMasterInterfaceId), &receiver, nullptr,
257 false, base::ThreadTaskRunnerHandle::Get(), 0u); 257 false, base::ThreadTaskRunnerHandle::Get(), 0u);
258 258
259 static const uint32_t kIterations[] = {1000, 3000000}; 259 static const uint32_t kIterations[] = {1000, 3000000};
260 260
261 for (size_t i = 0; i < 2; ++i) { 261 for (size_t i = 0; i < 2; ++i) {
262 receiver.Reset(); 262 receiver.Reset();
263 base::TimeTicks start_time = base::TimeTicks::Now(); 263 base::TimeTicks start_time = base::TimeTicks::Now();
264 for (size_t j = 0; j < kIterations[i]; ++j) { 264 for (size_t j = 0; j < kIterations[i]; ++j) {
265 internal::MessageBuilder builder(0, 8); 265 internal::MessageBuilder builder(0, 0, 8, 0);
266 bool result = 266 bool result =
267 router->SimulateReceivingMessageForTesting(builder.message()); 267 router->SimulateReceivingMessageForTesting(builder.message());
268 DCHECK(result); 268 DCHECK(result);
269 } 269 }
270 270
271 base::TimeTicks end_time = base::TimeTicks::Now(); 271 base::TimeTicks end_time = base::TimeTicks::Now();
272 base::TimeDelta duration = end_time - start_time; 272 base::TimeDelta duration = end_time - start_time;
273 CHECK_EQ(kIterations[i], receiver.counter()); 273 CHECK_EQ(kIterations[i], receiver.counter());
274 274
275 if (i == 1) { 275 if (i == 1) {
276 test::LogPerfResult("MultiplexRouterDispatchCost", nullptr, 276 test::LogPerfResult("MultiplexRouterDispatchCost", nullptr,
277 kIterations[i] / duration.InSecondsF(), 277 kIterations[i] / duration.InSecondsF(),
278 "times/second"); 278 "times/second");
279 } 279 }
280 } 280 }
281 } 281 }
282 282
283 } // namespace 283 } // namespace
284 } // namespace mojo 284 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/pipe_control_message_handler.h ('k') | mojo/public/cpp/bindings/tests/connector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698