OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 namespace { | 33 namespace { |
34 | 34 |
35 class MultiprocessMessagePipePerfTest | 35 class MultiprocessMessagePipePerfTest |
36 : public test::MultiprocessMessagePipeTestBase { | 36 : public test::MultiprocessMessagePipeTestBase { |
37 public: | 37 public: |
38 MultiprocessMessagePipePerfTest() : message_count_(0), message_size_(0) {} | 38 MultiprocessMessagePipePerfTest() : message_count_(0), message_size_(0) {} |
39 | 39 |
40 void SetUpMeasurement(int message_count, size_t message_size) { | 40 void SetUpMeasurement(int message_count, size_t message_size) { |
41 message_count_ = message_count; | 41 message_count_ = message_count; |
42 message_size_ = message_size; | 42 message_size_ = message_size; |
43 payload_ = Pickle(); | 43 payload_ = base::Pickle(); |
44 payload_.WriteString(std::string(message_size, '*')); | 44 payload_.WriteString(std::string(message_size, '*')); |
45 read_buffer_.resize(message_size * 2); | 45 read_buffer_.resize(message_size * 2); |
46 } | 46 } |
47 | 47 |
48 protected: | 48 protected: |
49 void WriteWaitThenRead(scoped_refptr<MessagePipe> mp) { | 49 void WriteWaitThenRead(scoped_refptr<MessagePipe> mp) { |
50 CHECK_EQ(mp->WriteMessage(0, UserPointer<const void>(payload_.data()), | 50 CHECK_EQ(mp->WriteMessage(0, UserPointer<const void>(payload_.data()), |
51 static_cast<uint32_t>(payload_.size()), nullptr, | 51 static_cast<uint32_t>(payload_.size()), nullptr, |
52 MOJO_WRITE_MESSAGE_FLAG_NONE), | 52 MOJO_WRITE_MESSAGE_FLAG_NONE), |
53 MOJO_RESULT_OK); | 53 MOJO_RESULT_OK); |
(...skipping 25 matching lines...) Expand all Loading... |
79 | 79 |
80 for (int i = 0; i < message_count_; ++i) | 80 for (int i = 0; i < message_count_; ++i) |
81 WriteWaitThenRead(mp); | 81 WriteWaitThenRead(mp); |
82 | 82 |
83 logger.Done(); | 83 logger.Done(); |
84 } | 84 } |
85 | 85 |
86 private: | 86 private: |
87 int message_count_; | 87 int message_count_; |
88 size_t message_size_; | 88 size_t message_size_; |
89 Pickle payload_; | 89 base::Pickle payload_; |
90 std::string read_buffer_; | 90 std::string read_buffer_; |
91 scoped_ptr<base::PerfTimeLogger> perf_logger_; | 91 scoped_ptr<base::PerfTimeLogger> perf_logger_; |
92 }; | 92 }; |
93 | 93 |
94 // For each message received, sends a reply message with the same contents | 94 // For each message received, sends a reply message with the same contents |
95 // repeated twice, until the other end is closed or it receives "quitquitquit" | 95 // repeated twice, until the other end is closed or it receives "quitquitquit" |
96 // (which it doesn't reply to). It'll return the number of messages received, | 96 // (which it doesn't reply to). It'll return the number of messages received, |
97 // not including any "quitquitquit" message, modulo 100. | 97 // not including any "quitquitquit" message, modulo 100. |
98 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) { | 98 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) { |
99 embedder::SimplePlatformSupport platform_support; | 99 embedder::SimplePlatformSupport platform_support; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 163 } |
164 | 164 |
165 SendQuitMessage(mp); | 165 SendQuitMessage(mp); |
166 mp->Close(0); | 166 mp->Close(0); |
167 EXPECT_EQ(0, helper()->WaitForChildShutdown()); | 167 EXPECT_EQ(0, helper()->WaitForChildShutdown()); |
168 } | 168 } |
169 | 169 |
170 } // namespace | 170 } // namespace |
171 } // namespace system | 171 } // namespace system |
172 } // namespace mojo | 172 } // namespace mojo |
OLD | NEW |