OLD | NEW |
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } else if (payload == "quit") { | 115 } else if (payload == "quit") { |
116 latency_tracker_.ShowResults(); | 116 latency_tracker_.ShowResults(); |
117 base::MessageLoop::current()->QuitWhenIdle(); | 117 base::MessageLoop::current()->QuitWhenIdle(); |
118 return true; | 118 return true; |
119 } else { | 119 } else { |
120 // Don't track hello and quit messages. | 120 // Don't track hello and quit messages. |
121 latency_tracker_.AddEvent( | 121 latency_tracker_.AddEvent( |
122 base::TimeTicks::FromInternalValue(time_internal), now); | 122 base::TimeTicks::FromInternalValue(time_internal), now); |
123 } | 123 } |
124 | 124 |
125 IPC::Message* msg = new IPC::Message(0, 2); | 125 IPC::Message* msg = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); |
126 msg->WriteInt64(base::TimeTicks::Now().ToInternalValue()); | 126 msg->WriteInt64(base::TimeTicks::Now().ToInternalValue()); |
127 msg->WriteInt(msgid); | 127 msg->WriteInt(msgid); |
128 msg->WriteString(payload); | 128 msg->WriteString(payload); |
129 channel_->Send(msg); | 129 channel_->Send(msg); |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 private: | 133 private: |
134 IPC::Channel* channel_; | 134 IPC::Channel* channel_; |
135 EventTimeTracker latency_tracker_; | 135 EventTimeTracker latency_tracker_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 CHECK(count_down_ > 0); | 194 CHECK(count_down_ > 0); |
195 count_down_--; | 195 count_down_--; |
196 if (count_down_ == 0) { | 196 if (count_down_ == 0) { |
197 perf_logger_.reset(); // Stop the perf timer now. | 197 perf_logger_.reset(); // Stop the perf timer now. |
198 latency_tracker_.ShowResults(); | 198 latency_tracker_.ShowResults(); |
199 base::MessageLoop::current()->QuitWhenIdle(); | 199 base::MessageLoop::current()->QuitWhenIdle(); |
200 return true; | 200 return true; |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 IPC::Message* msg = new IPC::Message(0, 2); | 204 IPC::Message* msg = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); |
205 msg->WriteInt64(base::TimeTicks::Now().ToInternalValue()); | 205 msg->WriteInt64(base::TimeTicks::Now().ToInternalValue()); |
206 msg->WriteInt(count_down_); | 206 msg->WriteInt(count_down_); |
207 msg->WriteString(payload_); | 207 msg->WriteString(payload_); |
208 channel_->Send(msg); | 208 channel_->Send(msg); |
209 return true; | 209 return true; |
210 } | 210 } |
211 | 211 |
212 private: | 212 private: |
213 IPC::Channel* channel_; | 213 IPC::Channel* channel_; |
214 int msg_count_; | 214 int msg_count_; |
(...skipping 17 matching lines...) Expand all Loading... |
232 | 232 |
233 const size_t kMsgSizeBase = 12; | 233 const size_t kMsgSizeBase = 12; |
234 const int kMsgSizeMaxExp = 5; | 234 const int kMsgSizeMaxExp = 5; |
235 int msg_count = 100000; | 235 int msg_count = 100000; |
236 size_t msg_size = kMsgSizeBase; | 236 size_t msg_size = kMsgSizeBase; |
237 for (int i = 1; i <= kMsgSizeMaxExp; i++) { | 237 for (int i = 1; i <= kMsgSizeMaxExp; i++) { |
238 listener.SetTestParams(msg_count, msg_size); | 238 listener.SetTestParams(msg_count, msg_size); |
239 | 239 |
240 // This initial message will kick-start the ping-pong of messages. | 240 // This initial message will kick-start the ping-pong of messages. |
241 IPC::Message* message = | 241 IPC::Message* message = |
242 new IPC::Message(0, 2); | 242 new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); |
243 message->WriteInt64(base::TimeTicks::Now().ToInternalValue()); | 243 message->WriteInt64(base::TimeTicks::Now().ToInternalValue()); |
244 message->WriteInt(-1); | 244 message->WriteInt(-1); |
245 message->WriteString("hello"); | 245 message->WriteString("hello"); |
246 sender()->Send(message); | 246 sender()->Send(message); |
247 | 247 |
248 // Run message loop. | 248 // Run message loop. |
249 base::MessageLoop::current()->Run(); | 249 base::MessageLoop::current()->Run(); |
250 | 250 |
251 msg_size *= kMsgSizeBase; | 251 msg_size *= kMsgSizeBase; |
252 } | 252 } |
253 | 253 |
254 // Send quit message. | 254 // Send quit message. |
255 IPC::Message* message = new IPC::Message(0, 2); | 255 IPC::Message* message = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL); |
256 message->WriteInt64(base::TimeTicks::Now().ToInternalValue()); | 256 message->WriteInt64(base::TimeTicks::Now().ToInternalValue()); |
257 message->WriteInt(-1); | 257 message->WriteInt(-1); |
258 message->WriteString("quit"); | 258 message->WriteString("quit"); |
259 sender()->Send(message); | 259 sender()->Send(message); |
260 | 260 |
261 EXPECT_TRUE(WaitForClientShutdown()); | 261 EXPECT_TRUE(WaitForClientShutdown()); |
262 DestroyChannel(); | 262 DestroyChannel(); |
263 } | 263 } |
264 | 264 |
265 // This message loop bounces all messages back to the sender. | 265 // This message loop bounces all messages back to the sender. |
266 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { | 266 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { |
267 base::MessageLoopForIO main_message_loop; | 267 base::MessageLoopForIO main_message_loop; |
268 ChannelReflectorListener listener; | 268 ChannelReflectorListener listener; |
269 IPC::Channel channel(IPCTestBase::GetChannelName("PerformanceClient"), | 269 IPC::Channel channel(IPCTestBase::GetChannelName("PerformanceClient"), |
270 IPC::Channel::MODE_CLIENT, | 270 IPC::Channel::MODE_CLIENT, |
271 &listener); | 271 &listener); |
272 listener.Init(&channel); | 272 listener.Init(&channel); |
273 CHECK(channel.Connect()); | 273 CHECK(channel.Connect()); |
274 | 274 |
275 base::MessageLoop::current()->Run(); | 275 base::MessageLoop::current()->Run(); |
276 return 0; | 276 return 0; |
277 } | 277 } |
278 | 278 |
279 } // namespace | 279 } // namespace |
OLD | NEW |