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

Side by Side Diff: mojo/edk/system/message_pipe_perftest.cc

Issue 1488853002: Add multiplexing of message pipes in the new EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tsepez review comments Created 5 years 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 | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/message_pipe_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/test/perf_time_logger.h" 8 #include "base/test/perf_time_logger.h"
9 #include "mojo/edk/embedder/embedder.h" 9 #include "mojo/edk/embedder/embedder.h"
10 #include "mojo/edk/embedder/scoped_platform_handle.h" 10 #include "mojo/edk/embedder/scoped_platform_handle.h"
11 #include "mojo/edk/system/handle_signals_state.h" 11 #include "mojo/edk/system/handle_signals_state.h"
12 #include "mojo/edk/system/message_pipe_test_utils.h" 12 #include "mojo/edk/system/message_pipe_test_utils.h"
13 #include "mojo/edk/system/test_utils.h" 13 #include "mojo/edk/system/test_utils.h"
14 #include "mojo/edk/test/test_utils.h" 14 #include "mojo/edk/test/test_utils.h"
15 #include "mojo/public/c/system/functions.h" 15 #include "mojo/public/c/system/functions.h"
16 #include "mojo/public/cpp/system/message_pipe.h" 16 #include "mojo/public/cpp/system/message_pipe.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace edk { 20 namespace edk {
21 namespace { 21 namespace {
22 22
23 class MultiprocessMessagePipePerfTest 23 class MultiprocessMessagePipePerfTest
24 : public test::MultiprocessMessagePipeTestBase { 24 : public test::MultiprocessMessagePipeTestBase {
25 public: 25 public:
26 MultiprocessMessagePipePerfTest() 26 MultiprocessMessagePipePerfTest()
27 : test::MultiprocessMessagePipeTestBase(base::MessageLoop::TYPE_IO), 27 : message_count_(0),
28 message_count_(0),
29 message_size_(0) {} 28 message_size_(0) {}
30 29
31 void SetUpMeasurement(int message_count, size_t message_size) { 30 void SetUpMeasurement(int message_count, size_t message_size) {
32 message_count_ = message_count; 31 message_count_ = message_count;
33 message_size_ = message_size; 32 message_size_ = message_size;
34 payload_ = std::string(message_size, '*'); 33 payload_ = std::string(message_size, '*');
35 read_buffer_.resize(message_size * 2); 34 read_buffer_.resize(message_size * 2);
36 } 35 }
37 36
38 protected: 37 protected:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 std::string payload_; 78 std::string payload_;
80 std::string read_buffer_; 79 std::string read_buffer_;
81 scoped_ptr<base::PerfTimeLogger> perf_logger_; 80 scoped_ptr<base::PerfTimeLogger> perf_logger_;
82 }; 81 };
83 82
84 // For each message received, sends a reply message with the same contents 83 // For each message received, sends a reply message with the same contents
85 // repeated twice, until the other end is closed or it receives "quitquitquit" 84 // repeated twice, until the other end is closed or it receives "quitquitquit"
86 // (which it doesn't reply to). It'll return the number of messages received, 85 // (which it doesn't reply to). It'll return the number of messages received,
87 // not including any "quitquitquit" message, modulo 100. 86 // not including any "quitquitquit" message, modulo 100.
88 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) { 87 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) {
89 SimplePlatformSupport platform_support;
90 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
91 base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart);
92 test::ScopedIPCSupport ipc_support(test_io_thread.task_runner());
93
94 ScopedPlatformHandle client_platform_handle = 88 ScopedPlatformHandle client_platform_handle =
95 test::MultiprocessTestHelper::client_platform_handle.Pass(); 89 test::MultiprocessTestHelper::client_platform_handle.Pass();
96 CHECK(client_platform_handle.is_valid()); 90 CHECK(client_platform_handle.is_valid());
97 ScopedMessagePipeHandle mp = 91 ScopedMessagePipeHandle mp =
98 CreateMessagePipe(client_platform_handle.Pass()); 92 CreateMessagePipe(client_platform_handle.Pass());
99 93
100 std::string buffer(1000000, '\0'); 94 std::string buffer(1000000, '\0');
101 int rv = 0; 95 int rv = 0;
102 while (true) { 96 while (true) {
103 // Wait for our end of the message pipe to be readable. 97 // Wait for our end of the message pipe to be readable.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 Measure(mp.get().value()); 147 Measure(mp.get().value());
154 } 148 }
155 149
156 SendQuitMessage(mp.get().value()); 150 SendQuitMessage(mp.get().value());
157 EXPECT_EQ(0, helper()->WaitForChildShutdown()); 151 EXPECT_EQ(0, helper()->WaitForChildShutdown());
158 } 152 }
159 153
160 } // namespace 154 } // namespace
161 } // namespace edk 155 } // namespace edk
162 } // namespace mojo 156 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/message_pipe_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698