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

Side by Side Diff: ipc/ipc_perftests.cc

Issue 196343019: IPC: Make ipc_perftests run on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 9 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 | « ipc/ipc_multiprocess_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 TEST_F(IPCChannelPerfTest, Performance) { 223 TEST_F(IPCChannelPerfTest, Performance) {
224 Init("PerformanceClient"); 224 Init("PerformanceClient");
225 225
226 // Set up IPC channel and start client. 226 // Set up IPC channel and start client.
227 PerformanceChannelListener listener; 227 PerformanceChannelListener listener;
228 CreateChannel(&listener); 228 CreateChannel(&listener);
229 listener.Init(channel()); 229 listener.Init(channel());
230 ASSERT_TRUE(ConnectChannel()); 230 ASSERT_TRUE(ConnectChannel());
231 ASSERT_TRUE(StartClient()); 231 ASSERT_TRUE(StartClient());
232 232
233 const size_t kMsgSizeBase = 12; 233 // Test several sizes. We use 12^N for message size, and limit the message
234 const int kMsgSizeMaxExp = 5; 234 // count to keep the test duration reasonable.
235 int msg_count = 100000; 235 const size_t kMsgSize[5] = {12, 144, 1728, 20736, 248832};
236 size_t msg_size = kMsgSizeBase; 236 const size_t kMessageCount[5] = {50000, 50000, 50000, 12000, 1000};
237 for (int i = 1; i <= kMsgSizeMaxExp; i++) { 237
238 listener.SetTestParams(msg_count, msg_size); 238 for (size_t i = 0; i < 5; i++) {
239 listener.SetTestParams(kMessageCount[i], kMsgSize[i]);
239 240
240 // This initial message will kick-start the ping-pong of messages. 241 // This initial message will kick-start the ping-pong of messages.
241 IPC::Message* message = 242 IPC::Message* message =
242 new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); 243 new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL);
243 message->WriteInt64(base::TimeTicks::Now().ToInternalValue()); 244 message->WriteInt64(base::TimeTicks::Now().ToInternalValue());
244 message->WriteInt(-1); 245 message->WriteInt(-1);
245 message->WriteString("hello"); 246 message->WriteString("hello");
246 sender()->Send(message); 247 sender()->Send(message);
247 248
248 // Run message loop. 249 // Run message loop.
249 base::MessageLoop::current()->Run(); 250 base::MessageLoop::current()->Run();
250
251 msg_size *= kMsgSizeBase;
252 } 251 }
253 252
254 // Send quit message. 253 // Send quit message.
255 IPC::Message* message = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); 254 IPC::Message* message = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL);
256 message->WriteInt64(base::TimeTicks::Now().ToInternalValue()); 255 message->WriteInt64(base::TimeTicks::Now().ToInternalValue());
257 message->WriteInt(-1); 256 message->WriteInt(-1);
258 message->WriteString("quit"); 257 message->WriteString("quit");
259 sender()->Send(message); 258 sender()->Send(message);
260 259
261 EXPECT_TRUE(WaitForClientShutdown()); 260 EXPECT_TRUE(WaitForClientShutdown());
262 DestroyChannel(); 261 DestroyChannel();
263 } 262 }
264 263
265 // This message loop bounces all messages back to the sender. 264 // This message loop bounces all messages back to the sender.
266 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { 265 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
267 base::MessageLoopForIO main_message_loop; 266 base::MessageLoopForIO main_message_loop;
268 ChannelReflectorListener listener; 267 ChannelReflectorListener listener;
269 IPC::Channel channel(IPCTestBase::GetChannelName("PerformanceClient"), 268 IPC::Channel channel(IPCTestBase::GetChannelName("PerformanceClient"),
270 IPC::Channel::MODE_CLIENT, 269 IPC::Channel::MODE_CLIENT,
271 &listener); 270 &listener);
272 listener.Init(&channel); 271 listener.Init(&channel);
273 CHECK(channel.Connect()); 272 CHECK(channel.Connect());
274 273
275 base::MessageLoop::current()->Run(); 274 base::MessageLoop::current()->Run();
276 return 0; 275 return 0;
277 } 276 }
278 277
279 } // namespace 278 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_multiprocess_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698