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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/pickle.h" | 13 #include "base/pickle.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/test/perftimer.h" | 15 #include "base/test/perf_time_logger.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "ipc/ipc_channel.h" | 18 #include "ipc/ipc_channel.h" |
19 #include "ipc/ipc_channel_proxy.h" | 19 #include "ipc/ipc_channel_proxy.h" |
20 #include "ipc/ipc_descriptors.h" | 20 #include "ipc/ipc_descriptors.h" |
21 #include "ipc/ipc_message_utils.h" | 21 #include "ipc/ipc_message_utils.h" |
22 #include "ipc/ipc_sender.h" | 22 #include "ipc/ipc_sender.h" |
23 #include "ipc/ipc_test_base.h" | 23 #include "ipc/ipc_test_base.h" |
24 | 24 |
25 namespace { | 25 namespace { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 // Include message deserialization in latency. | 178 // Include message deserialization in latency. |
179 base::TimeTicks now = base::TimeTicks::Now(); | 179 base::TimeTicks now = base::TimeTicks::Now(); |
180 | 180 |
181 if (reflected_payload == "hello") { | 181 if (reflected_payload == "hello") { |
182 // Start timing on hello. | 182 // Start timing on hello. |
183 latency_tracker_.Reset(); | 183 latency_tracker_.Reset(); |
184 DCHECK(!perf_logger_.get()); | 184 DCHECK(!perf_logger_.get()); |
185 std::string test_name = base::StringPrintf( | 185 std::string test_name = base::StringPrintf( |
186 "IPC_Perf_%dx_%u", msg_count_, static_cast<unsigned>(msg_size_)); | 186 "IPC_Perf_%dx_%u", msg_count_, static_cast<unsigned>(msg_size_)); |
187 perf_logger_.reset(new PerfTimeLogger(test_name.c_str())); | 187 perf_logger_.reset(new base::PerfTimeLogger(test_name.c_str())); |
188 } else { | 188 } else { |
189 DCHECK_EQ(payload_.size(), reflected_payload.size()); | 189 DCHECK_EQ(payload_.size(), reflected_payload.size()); |
190 | 190 |
191 latency_tracker_.AddEvent( | 191 latency_tracker_.AddEvent( |
192 base::TimeTicks::FromInternalValue(time_internal), now); | 192 base::TimeTicks::FromInternalValue(time_internal), now); |
193 | 193 |
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. |
(...skipping 12 matching lines...) Expand all Loading... |
210 } | 210 } |
211 | 211 |
212 private: | 212 private: |
213 IPC::Channel* channel_; | 213 IPC::Channel* channel_; |
214 int msg_count_; | 214 int msg_count_; |
215 size_t msg_size_; | 215 size_t msg_size_; |
216 | 216 |
217 int count_down_; | 217 int count_down_; |
218 std::string payload_; | 218 std::string payload_; |
219 EventTimeTracker latency_tracker_; | 219 EventTimeTracker latency_tracker_; |
220 scoped_ptr<PerfTimeLogger> perf_logger_; | 220 scoped_ptr<base::PerfTimeLogger> perf_logger_; |
221 }; | 221 }; |
222 | 222 |
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()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |