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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 current_iterations_++; | 79 current_iterations_++; |
80 if (current_iterations_ >= iterations_to_run_) { | 80 if (current_iterations_ >= iterations_to_run_) { |
81 quit_closure_.Run(); | 81 quit_closure_.Run(); |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 service_->Ping(base::Bind(&PingPongTest::OnPingDone, base::Unretained(this))); | 85 service_->Ping(base::Bind(&PingPongTest::OnPingDone, base::Unretained(this))); |
86 } | 86 } |
87 | 87 |
88 struct BoundPingService { | 88 struct BoundPingService { |
89 BoundPingService() : binding(&impl) { | 89 BoundPingService() : binding(&impl) { binding.Bind(MakeRequest(&service)); } |
90 binding.Bind(GetProxy(&service)); | |
91 } | |
92 | 90 |
93 PingServiceImpl impl; | 91 PingServiceImpl impl; |
94 test::PingServicePtr service; | 92 test::PingServicePtr service; |
95 Binding<test::PingService> binding; | 93 Binding<test::PingService> binding; |
96 }; | 94 }; |
97 | 95 |
98 class MojoBindingsPerftest : public testing::Test { | 96 class MojoBindingsPerftest : public testing::Test { |
99 public: | 97 public: |
100 MojoBindingsPerftest() {} | 98 MojoBindingsPerftest() {} |
101 | 99 |
102 protected: | 100 protected: |
103 base::MessageLoop loop_; | 101 base::MessageLoop loop_; |
104 }; | 102 }; |
105 | 103 |
106 TEST_F(MojoBindingsPerftest, InProcessPingPong) { | 104 TEST_F(MojoBindingsPerftest, InProcessPingPong) { |
107 test::PingServicePtr service; | 105 test::PingServicePtr service; |
108 PingServiceImpl impl; | 106 PingServiceImpl impl; |
109 Binding<test::PingService> binding(&impl, GetProxy(&service)); | 107 Binding<test::PingService> binding(&impl, MakeRequest(&service)); |
110 PingPongTest test(std::move(service)); | 108 PingPongTest test(std::move(service)); |
111 | 109 |
112 { | 110 { |
113 const unsigned int kIterations = 100000; | 111 const unsigned int kIterations = 100000; |
114 const MojoTimeTicks start_time = MojoGetTimeTicksNow(); | 112 const MojoTimeTicks start_time = MojoGetTimeTicksNow(); |
115 test.Run(kIterations); | 113 test.Run(kIterations); |
116 const MojoTimeTicks end_time = MojoGetTimeTicksNow(); | 114 const MojoTimeTicks end_time = MojoGetTimeTicksNow(); |
117 test::LogPerfResult( | 115 test::LogPerfResult( |
118 "InProcessPingPong", "0_Inactive", | 116 "InProcessPingPong", "0_Inactive", |
119 kIterations / MojoTicksToSeconds(end_time - start_time), | 117 kIterations / MojoTicksToSeconds(end_time - start_time), |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 if (i == 1) { | 274 if (i == 1) { |
277 test::LogPerfResult("MultiplexRouterDispatchCost", nullptr, | 275 test::LogPerfResult("MultiplexRouterDispatchCost", nullptr, |
278 kIterations[i] / duration.InSecondsF(), | 276 kIterations[i] / duration.InSecondsF(), |
279 "times/second"); | 277 "times/second"); |
280 } | 278 } |
281 } | 279 } |
282 } | 280 } |
283 | 281 |
284 } // namespace | 282 } // namespace |
285 } // namespace mojo | 283 } // namespace mojo |
OLD | NEW |