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

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

Issue 1535943002: Convert Pass()→std::move() in //mojo/public/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove self-move checks to avoid triggering clang warning. Created 5 years 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 <utility>
6
5 #include "mojo/public/cpp/bindings/binding.h" 7 #include "mojo/public/cpp/bindings/binding.h"
6 #include "mojo/public/cpp/test_support/test_support.h" 8 #include "mojo/public/cpp/test_support/test_support.h"
7 #include "mojo/public/cpp/test_support/test_utils.h" 9 #include "mojo/public/cpp/test_support/test_utils.h"
8 #include "mojo/public/cpp/utility/run_loop.h" 10 #include "mojo/public/cpp/utility/run_loop.h"
9 #include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h" 11 #include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
12 namespace mojo { 14 namespace mojo {
13 namespace { 15 namespace {
14 16
(...skipping 29 matching lines...) Expand all
44 void OnPingDone(); 46 void OnPingDone();
45 47
46 test::PingServicePtr service_; 48 test::PingServicePtr service_;
47 unsigned int iterations_to_run_; 49 unsigned int iterations_to_run_;
48 unsigned int current_iterations_; 50 unsigned int current_iterations_;
49 51
50 MOJO_DISALLOW_COPY_AND_ASSIGN(PingPongTest); 52 MOJO_DISALLOW_COPY_AND_ASSIGN(PingPongTest);
51 }; 53 };
52 54
53 PingPongTest::PingPongTest(test::PingServicePtr service) 55 PingPongTest::PingPongTest(test::PingServicePtr service)
54 : service_(service.Pass()) { 56 : service_(std::move(service)) {}
55 }
56 57
57 void PingPongTest::Run(unsigned int iterations) { 58 void PingPongTest::Run(unsigned int iterations) {
58 iterations_to_run_ = iterations; 59 iterations_to_run_ = iterations;
59 current_iterations_ = 0; 60 current_iterations_ = 0;
60 61
61 service_->Ping([this]() { OnPingDone(); }); 62 service_->Ping([this]() { OnPingDone(); });
62 RunLoop::current()->Run(); 63 RunLoop::current()->Run();
63 } 64 }
64 65
65 void PingPongTest::OnPingDone() { 66 void PingPongTest::OnPingDone() {
(...skipping 19 matching lines...) Expand all
85 class MojoBindingsPerftest : public testing::Test { 86 class MojoBindingsPerftest : public testing::Test {
86 protected: 87 protected:
87 Environment env_; 88 Environment env_;
88 RunLoop run_loop_; 89 RunLoop run_loop_;
89 }; 90 };
90 91
91 TEST_F(MojoBindingsPerftest, InProcessPingPong) { 92 TEST_F(MojoBindingsPerftest, InProcessPingPong) {
92 test::PingServicePtr service; 93 test::PingServicePtr service;
93 PingServiceImpl impl; 94 PingServiceImpl impl;
94 Binding<test::PingService> binding(&impl, GetProxy(&service)); 95 Binding<test::PingService> binding(&impl, GetProxy(&service));
95 PingPongTest test(service.Pass()); 96 PingPongTest test(std::move(service));
96 97
97 { 98 {
98 const unsigned int kIterations = 100000; 99 const unsigned int kIterations = 100000;
99 const MojoTimeTicks start_time = MojoGetTimeTicksNow(); 100 const MojoTimeTicks start_time = MojoGetTimeTicksNow();
100 test.Run(kIterations); 101 test.Run(kIterations);
101 const MojoTimeTicks end_time = MojoGetTimeTicksNow(); 102 const MojoTimeTicks end_time = MojoGetTimeTicksNow();
102 test::LogPerfResult( 103 test::LogPerfResult(
103 "InProcessPingPong", "0_Inactive", 104 "InProcessPingPong", "0_Inactive",
104 kIterations / MojoTicksToSeconds(end_time - start_time), 105 kIterations / MojoTicksToSeconds(end_time - start_time),
105 "pings/second"); 106 "pings/second");
(...skipping 12 matching lines...) Expand all
118 "InProcessPingPong", "1000_Inactive", 119 "InProcessPingPong", "1000_Inactive",
119 kIterations / MojoTicksToSeconds(end_time - start_time), 120 kIterations / MojoTicksToSeconds(end_time - start_time),
120 "pings/second"); 121 "pings/second");
121 122
122 delete[] inactive_services; 123 delete[] inactive_services;
123 } 124 }
124 } 125 }
125 126
126 } // namespace 127 } // namespace
127 } // namespace mojo 128 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698