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 "ipc/ipc_perftest_support.h" | 5 #include "ipc/ipc_perftest_support.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 void Reset() { | 61 void Reset() { |
62 count_ = 0; | 62 count_ = 0; |
63 total_duration_ = base::TimeDelta(); | 63 total_duration_ = base::TimeDelta(); |
64 max_duration_ = base::TimeDelta(); | 64 max_duration_ = base::TimeDelta(); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 const std::string name_; | 68 const std::string name_; |
69 | 69 |
70 uint64 count_; | 70 uint64_t count_; |
71 base::TimeDelta total_duration_; | 71 base::TimeDelta total_duration_; |
72 base::TimeDelta max_duration_; | 72 base::TimeDelta max_duration_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(EventTimeTracker); | 74 DISALLOW_COPY_AND_ASSIGN(EventTimeTracker); |
75 }; | 75 }; |
76 | 76 |
77 // This channel listener just replies to all messages with the exact same | 77 // This channel listener just replies to all messages with the exact same |
78 // message. It assumes each message has one string parameter. When the string | 78 // message. It assumes each message has one string parameter. When the string |
79 // "quit" is sent, it will exit. | 79 // "quit" is sent, it will exit. |
80 class ChannelReflectorListener : public Listener { | 80 class ChannelReflectorListener : public Listener { |
(...skipping 11 matching lines...) Expand all Loading... |
92 | 92 |
93 void Init(Channel* channel) { | 93 void Init(Channel* channel) { |
94 DCHECK(!channel_); | 94 DCHECK(!channel_); |
95 channel_ = channel; | 95 channel_ = channel; |
96 } | 96 } |
97 | 97 |
98 bool OnMessageReceived(const Message& message) override { | 98 bool OnMessageReceived(const Message& message) override { |
99 CHECK(channel_); | 99 CHECK(channel_); |
100 | 100 |
101 base::PickleIterator iter(message); | 101 base::PickleIterator iter(message); |
102 int64 time_internal; | 102 int64_t time_internal; |
103 EXPECT_TRUE(iter.ReadInt64(&time_internal)); | 103 EXPECT_TRUE(iter.ReadInt64(&time_internal)); |
104 int msgid; | 104 int msgid; |
105 EXPECT_TRUE(iter.ReadInt(&msgid)); | 105 EXPECT_TRUE(iter.ReadInt(&msgid)); |
106 base::StringPiece payload; | 106 base::StringPiece payload; |
107 EXPECT_TRUE(iter.ReadStringPiece(&payload)); | 107 EXPECT_TRUE(iter.ReadStringPiece(&payload)); |
108 | 108 |
109 // Include message deserialization in latency. | 109 // Include message deserialization in latency. |
110 base::TimeTicks now = base::TimeTicks::Now(); | 110 base::TimeTicks now = base::TimeTicks::Now(); |
111 | 111 |
112 if (payload == "hello") { | 112 if (payload == "hello") { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 msg_count_ = msg_count; | 161 msg_count_ = msg_count; |
162 msg_size_ = msg_size; | 162 msg_size_ = msg_size; |
163 count_down_ = msg_count_; | 163 count_down_ = msg_count_; |
164 payload_ = std::string(msg_size_, 'a'); | 164 payload_ = std::string(msg_size_, 'a'); |
165 } | 165 } |
166 | 166 |
167 bool OnMessageReceived(const Message& message) override { | 167 bool OnMessageReceived(const Message& message) override { |
168 CHECK(sender_); | 168 CHECK(sender_); |
169 | 169 |
170 base::PickleIterator iter(message); | 170 base::PickleIterator iter(message); |
171 int64 time_internal; | 171 int64_t time_internal; |
172 EXPECT_TRUE(iter.ReadInt64(&time_internal)); | 172 EXPECT_TRUE(iter.ReadInt64(&time_internal)); |
173 int msgid; | 173 int msgid; |
174 EXPECT_TRUE(iter.ReadInt(&msgid)); | 174 EXPECT_TRUE(iter.ReadInt(&msgid)); |
175 std::string reflected_payload; | 175 std::string reflected_payload; |
176 EXPECT_TRUE(iter.ReadString(&reflected_payload)); | 176 EXPECT_TRUE(iter.ReadString(&reflected_payload)); |
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") { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 auto set_result = SetThreadAffinityMask(GetCurrentThread(), old_affinity_); | 372 auto set_result = SetThreadAffinityMask(GetCurrentThread(), old_affinity_); |
373 DCHECK_NE(0u, set_result); | 373 DCHECK_NE(0u, set_result); |
374 #elif defined(OS_LINUX) | 374 #elif defined(OS_LINUX) |
375 auto set_result = sched_setaffinity(0, sizeof(old_cpuset_), &old_cpuset_); | 375 auto set_result = sched_setaffinity(0, sizeof(old_cpuset_), &old_cpuset_); |
376 DCHECK_EQ(0, set_result); | 376 DCHECK_EQ(0, set_result); |
377 #endif | 377 #endif |
378 } | 378 } |
379 | 379 |
380 } // namespace test | 380 } // namespace test |
381 } // namespace IPC | 381 } // namespace IPC |
OLD | NEW |