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

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

Issue 728043002: Revert of Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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 <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 29 matching lines...) Expand all
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_ = 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,
51 static_cast<uint32_t>(payload_.size()), nullptr, 51 UserPointer<const void>(payload_.data()),
52 static_cast<uint32_t>(payload_.size()),
53 nullptr,
52 MOJO_WRITE_MESSAGE_FLAG_NONE), 54 MOJO_WRITE_MESSAGE_FLAG_NONE),
53 MOJO_RESULT_OK); 55 MOJO_RESULT_OK);
54 HandleSignalsState hss; 56 HandleSignalsState hss;
55 CHECK_EQ(test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss), 57 CHECK_EQ(test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss),
56 MOJO_RESULT_OK); 58 MOJO_RESULT_OK);
57 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer_.size()); 59 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer_.size());
58 CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&read_buffer_[0]), 60 CHECK_EQ(mp->ReadMessage(0,
59 MakeUserPointer(&read_buffer_size), nullptr, 61 UserPointer<void>(&read_buffer_[0]),
60 nullptr, MOJO_READ_MESSAGE_FLAG_NONE), 62 MakeUserPointer(&read_buffer_size),
63 nullptr,
64 nullptr,
65 MOJO_READ_MESSAGE_FLAG_NONE),
61 MOJO_RESULT_OK); 66 MOJO_RESULT_OK);
62 CHECK_EQ(read_buffer_size, static_cast<uint32_t>(payload_.size())); 67 CHECK_EQ(read_buffer_size, static_cast<uint32_t>(payload_.size()));
63 } 68 }
64 69
65 void SendQuitMessage(scoped_refptr<MessagePipe> mp) { 70 void SendQuitMessage(scoped_refptr<MessagePipe> mp) {
66 CHECK_EQ(mp->WriteMessage(0, UserPointer<const void>(""), 0, nullptr, 71 CHECK_EQ(mp->WriteMessage(0,
72 UserPointer<const void>(""),
73 0,
74 nullptr,
67 MOJO_WRITE_MESSAGE_FLAG_NONE), 75 MOJO_WRITE_MESSAGE_FLAG_NONE),
68 MOJO_RESULT_OK); 76 MOJO_RESULT_OK);
69 } 77 }
70 78
71 void Measure(scoped_refptr<MessagePipe> mp) { 79 void Measure(scoped_refptr<MessagePipe> mp) {
72 // Have one ping-pong to ensure channel being established. 80 // Have one ping-pong to ensure channel being established.
73 WriteWaitThenRead(mp); 81 WriteWaitThenRead(mp);
74 82
75 std::string test_name = 83 std::string test_name =
76 base::StringPrintf("IPC_Perf_%dx_%u", message_count_, 84 base::StringPrintf("IPC_Perf_%dx_%u",
85 message_count_,
77 static_cast<unsigned>(message_size_)); 86 static_cast<unsigned>(message_size_));
78 base::PerfTimeLogger logger(test_name.c_str()); 87 base::PerfTimeLogger logger(test_name.c_str());
79 88
80 for (int i = 0; i < message_count_; ++i) 89 for (int i = 0; i < message_count_; ++i)
81 WriteWaitThenRead(mp); 90 WriteWaitThenRead(mp);
82 91
83 logger.Done(); 92 logger.Done();
84 } 93 }
85 94
86 private: 95 private:
(...skipping 24 matching lines...) Expand all
111 // Wait for our end of the message pipe to be readable. 120 // Wait for our end of the message pipe to be readable.
112 HandleSignalsState hss; 121 HandleSignalsState hss;
113 MojoResult result = 122 MojoResult result =
114 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss); 123 test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss);
115 if (result != MOJO_RESULT_OK) { 124 if (result != MOJO_RESULT_OK) {
116 rv = result; 125 rv = result;
117 break; 126 break;
118 } 127 }
119 128
120 uint32_t read_size = static_cast<uint32_t>(buffer.size()); 129 uint32_t read_size = static_cast<uint32_t>(buffer.size());
121 CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&buffer[0]), 130 CHECK_EQ(mp->ReadMessage(0,
122 MakeUserPointer(&read_size), nullptr, nullptr, 131 UserPointer<void>(&buffer[0]),
132 MakeUserPointer(&read_size),
133 nullptr,
134 nullptr,
123 MOJO_READ_MESSAGE_FLAG_NONE), 135 MOJO_READ_MESSAGE_FLAG_NONE),
124 MOJO_RESULT_OK); 136 MOJO_RESULT_OK);
125 137
126 // Empty message indicates quitting 138 // Empty message indicates quitting
127 if (0 == read_size) 139 if (0 == read_size)
128 break; 140 break;
129 141
130 CHECK_EQ(mp->WriteMessage(0, UserPointer<const void>(&buffer[0]), 142 CHECK_EQ(mp->WriteMessage(0,
131 static_cast<uint32_t>(read_size), nullptr, 143 UserPointer<const void>(&buffer[0]),
144 static_cast<uint32_t>(read_size),
145 nullptr,
132 MOJO_WRITE_MESSAGE_FLAG_NONE), 146 MOJO_WRITE_MESSAGE_FLAG_NONE),
133 MOJO_RESULT_OK); 147 MOJO_RESULT_OK);
134 } 148 }
135 149
136 mp->Close(0); 150 mp->Close(0);
137 return rv; 151 return rv;
138 } 152 }
139 153
140 // Repeatedly sends messages as previous one got replied by the child. 154 // Repeatedly sends messages as previous one got replied by the child.
141 // Waits for the child to close its end before quitting once specified 155 // Waits for the child to close its end before quitting once specified
(...skipping 15 matching lines...) Expand all
157 } 171 }
158 172
159 SendQuitMessage(mp); 173 SendQuitMessage(mp);
160 mp->Close(0); 174 mp->Close(0);
161 EXPECT_EQ(0, helper()->WaitForChildShutdown()); 175 EXPECT_EQ(0, helper()->WaitForChildShutdown());
162 } 176 }
163 177
164 } // namespace 178 } // namespace
165 } // namespace system 179 } // namespace system
166 } // namespace mojo 180 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher_unittest.cc ('k') | mojo/edk/system/message_pipe_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698