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

Side by Side Diff: mojo/system/message_pipe_perftest.cc

Issue 588193004: Mojo: Have |ProxyMessagePipeEndpoint|s constructed with a |ChannelEndpoint|. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « mojo/system/message_pipe_dispatcher.cc ('k') | mojo/system/message_pipe_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // For each message received, sends a reply message with the same contents 103 // For each message received, sends a reply message with the same contents
104 // repeated twice, until the other end is closed or it receives "quitquitquit" 104 // repeated twice, until the other end is closed or it receives "quitquitquit"
105 // (which it doesn't reply to). It'll return the number of messages received, 105 // (which it doesn't reply to). It'll return the number of messages received,
106 // not including any "quitquitquit" message, modulo 100. 106 // not including any "quitquitquit" message, modulo 100.
107 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) { 107 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) {
108 embedder::SimplePlatformSupport platform_support; 108 embedder::SimplePlatformSupport platform_support;
109 test::ChannelThread channel_thread(&platform_support); 109 test::ChannelThread channel_thread(&platform_support);
110 embedder::ScopedPlatformHandle client_platform_handle = 110 embedder::ScopedPlatformHandle client_platform_handle =
111 mojo::test::MultiprocessTestHelper::client_platform_handle.Pass(); 111 mojo::test::MultiprocessTestHelper::client_platform_handle.Pass();
112 CHECK(client_platform_handle.is_valid()); 112 CHECK(client_platform_handle.is_valid());
113 scoped_refptr<MessagePipe> mp(new MessagePipe( 113 scoped_refptr<ChannelEndpoint> ep;
114 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), 114 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
115 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); 115 channel_thread.Start(client_platform_handle.Pass(), ep);
116 channel_thread.Start(client_platform_handle.Pass(), mp);
117 116
118 std::string buffer(1000000, '\0'); 117 std::string buffer(1000000, '\0');
119 int rv = 0; 118 int rv = 0;
120 while (true) { 119 while (true) {
121 // Wait for our end of the message pipe to be readable. 120 // Wait for our end of the message pipe to be readable.
122 HandleSignalsState hss; 121 HandleSignalsState hss;
123 MojoResult result = 122 MojoResult result =
124 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss); 123 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss);
125 if (result != MOJO_RESULT_OK) { 124 if (result != MOJO_RESULT_OK) {
126 rv = result; 125 rv = result;
(...skipping 24 matching lines...) Expand all
151 mp->Close(0); 150 mp->Close(0);
152 return rv; 151 return rv;
153 } 152 }
154 153
155 // Repeatedly sends messages as previous one got replied by the child. 154 // Repeatedly sends messages as previous one got replied by the child.
156 // Waits for the child to close its end before quitting once specified 155 // Waits for the child to close its end before quitting once specified
157 // number of messages has been sent. 156 // number of messages has been sent.
158 TEST_F(MultiprocessMessagePipePerfTest, PingPong) { 157 TEST_F(MultiprocessMessagePipePerfTest, PingPong) {
159 helper()->StartChild("PingPongClient"); 158 helper()->StartChild("PingPongClient");
160 159
161 scoped_refptr<MessagePipe> mp(new MessagePipe( 160 scoped_refptr<ChannelEndpoint> ep;
162 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), 161 scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
163 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); 162 Init(ep);
164 Init(mp);
165 163
166 // This values are set to align with one at ipc_pertests.cc for comparison. 164 // This values are set to align with one at ipc_pertests.cc for comparison.
167 const size_t kMsgSize[5] = {12, 144, 1728, 20736, 248832}; 165 const size_t kMsgSize[5] = {12, 144, 1728, 20736, 248832};
168 const int kMessageCount[5] = {50000, 50000, 50000, 12000, 1000}; 166 const int kMessageCount[5] = {50000, 50000, 50000, 12000, 1000};
169 167
170 for (size_t i = 0; i < 5; i++) { 168 for (size_t i = 0; i < 5; i++) {
171 SetUpMeasurement(kMessageCount[i], kMsgSize[i]); 169 SetUpMeasurement(kMessageCount[i], kMsgSize[i]);
172 Measure(mp); 170 Measure(mp);
173 } 171 }
174 172
175 SendQuitMessage(mp); 173 SendQuitMessage(mp);
176 mp->Close(0); 174 mp->Close(0);
177 EXPECT_EQ(0, helper()->WaitForChildShutdown()); 175 EXPECT_EQ(0, helper()->WaitForChildShutdown());
178 } 176 }
179 177
180 } // namespace 178 } // namespace
181 } // namespace system 179 } // namespace system
182 } // namespace mojo 180 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/message_pipe_dispatcher.cc ('k') | mojo/system/message_pipe_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698