OLD | NEW |
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 base::TimeDelta duration = paddle0.Serve(kTestIterations); | 211 base::TimeDelta duration = paddle0.Serve(kTestIterations); |
212 | 212 |
213 test::LogPerfResult("RouterPingPong", nullptr, | 213 test::LogPerfResult("RouterPingPong", nullptr, |
214 kTestIterations / duration.InSecondsF(), "pings/second"); | 214 kTestIterations / duration.InSecondsF(), "pings/second"); |
215 } | 215 } |
216 | 216 |
217 TEST_F(MojoBindingsPerftest, MultiplexRouterPingPong) { | 217 TEST_F(MojoBindingsPerftest, MultiplexRouterPingPong) { |
218 MessagePipe pipe; | 218 MessagePipe pipe; |
219 scoped_refptr<internal::MultiplexRouter> router0( | 219 scoped_refptr<internal::MultiplexRouter> router0( |
220 new internal::MultiplexRouter(true, std::move(pipe.handle0), | 220 new internal::MultiplexRouter(std::move(pipe.handle0), |
221 base::ThreadTaskRunnerHandle::Get())); | 221 internal::MultiplexRouter::SINGLE_INTERFACE, |
| 222 true, base::ThreadTaskRunnerHandle::Get())); |
222 scoped_refptr<internal::MultiplexRouter> router1( | 223 scoped_refptr<internal::MultiplexRouter> router1( |
223 new internal::MultiplexRouter(false, std::move(pipe.handle1), | 224 new internal::MultiplexRouter( |
224 base::ThreadTaskRunnerHandle::Get())); | 225 std::move(pipe.handle1), internal::MultiplexRouter::SINGLE_INTERFACE, |
| 226 false, base::ThreadTaskRunnerHandle::Get())); |
225 | 227 |
226 PingPongPaddle paddle0(nullptr); | 228 PingPongPaddle paddle0(nullptr); |
227 PingPongPaddle paddle1(nullptr); | 229 PingPongPaddle paddle1(nullptr); |
228 | 230 |
229 InterfaceEndpointClient client0( | 231 InterfaceEndpointClient client0( |
230 router0->CreateLocalEndpointHandle(kMasterInterfaceId), &paddle0, nullptr, | 232 router0->CreateLocalEndpointHandle(kMasterInterfaceId), &paddle0, nullptr, |
231 false, base::ThreadTaskRunnerHandle::Get(), 0u); | 233 false, base::ThreadTaskRunnerHandle::Get(), 0u); |
232 InterfaceEndpointClient client1( | 234 InterfaceEndpointClient client1( |
233 router1->CreateLocalEndpointHandle(kMasterInterfaceId), &paddle1, nullptr, | 235 router1->CreateLocalEndpointHandle(kMasterInterfaceId), &paddle1, nullptr, |
234 false, base::ThreadTaskRunnerHandle::Get(), 0u); | 236 false, base::ThreadTaskRunnerHandle::Get(), 0u); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 test::LogPerfResult("RouterDispatchCost", nullptr, | 297 test::LogPerfResult("RouterDispatchCost", nullptr, |
296 kIterations[i] / duration.InSecondsF(), | 298 kIterations[i] / duration.InSecondsF(), |
297 "times/second"); | 299 "times/second"); |
298 } | 300 } |
299 } | 301 } |
300 } | 302 } |
301 | 303 |
302 TEST_F(MojoBindingsPerftest, MultiplexRouterDispatchCost) { | 304 TEST_F(MojoBindingsPerftest, MultiplexRouterDispatchCost) { |
303 MessagePipe pipe; | 305 MessagePipe pipe; |
304 scoped_refptr<internal::MultiplexRouter> router(new internal::MultiplexRouter( | 306 scoped_refptr<internal::MultiplexRouter> router(new internal::MultiplexRouter( |
305 true, std::move(pipe.handle0), base::ThreadTaskRunnerHandle::Get())); | 307 std::move(pipe.handle0), internal::MultiplexRouter::SINGLE_INTERFACE, |
| 308 true, base::ThreadTaskRunnerHandle::Get())); |
306 CounterReceiver receiver; | 309 CounterReceiver receiver; |
307 InterfaceEndpointClient client( | 310 InterfaceEndpointClient client( |
308 router->CreateLocalEndpointHandle(kMasterInterfaceId), &receiver, nullptr, | 311 router->CreateLocalEndpointHandle(kMasterInterfaceId), &receiver, nullptr, |
309 false, base::ThreadTaskRunnerHandle::Get(), 0u); | 312 false, base::ThreadTaskRunnerHandle::Get(), 0u); |
310 | 313 |
311 static const uint32_t kIterations[] = {1000, 3000000}; | 314 static const uint32_t kIterations[] = {1000, 3000000}; |
312 | 315 |
313 for (size_t i = 0; i < 2; ++i) { | 316 for (size_t i = 0; i < 2; ++i) { |
314 receiver.Reset(); | 317 receiver.Reset(); |
315 base::TimeTicks start_time = base::TimeTicks::Now(); | 318 base::TimeTicks start_time = base::TimeTicks::Now(); |
(...skipping 11 matching lines...) Expand all Loading... |
327 if (i == 1) { | 330 if (i == 1) { |
328 test::LogPerfResult("MultiplexRouterDispatchCost", nullptr, | 331 test::LogPerfResult("MultiplexRouterDispatchCost", nullptr, |
329 kIterations[i] / duration.InSecondsF(), | 332 kIterations[i] / duration.InSecondsF(), |
330 "times/second"); | 333 "times/second"); |
331 } | 334 } |
332 } | 335 } |
333 } | 336 } |
334 | 337 |
335 } // namespace | 338 } // namespace |
336 } // namespace mojo | 339 } // namespace mojo |
OLD | NEW |