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

Side by Side Diff: mojo/public/c/system/tests/core_perftest.cc

Issue 324783002: Mojo: Add a MojoCreateMessagePipeOptions struct parameter to MojoCreateMessagePipe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/c/system/message_pipe.h ('k') | mojo/public/c/system/tests/core_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This tests the performance of the C API. 5 // This tests the performance of the C API.
6 6
7 #include "mojo/public/c/system/core.h" 7 #include "mojo/public/c/system/core.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 public: 117 public:
118 CorePerftest() : buffer_(NULL), num_bytes_(0) {} 118 CorePerftest() : buffer_(NULL), num_bytes_(0) {}
119 virtual ~CorePerftest() {} 119 virtual ~CorePerftest() {}
120 120
121 static void NoOp(void* /*closure*/) { 121 static void NoOp(void* /*closure*/) {
122 } 122 }
123 123
124 static void MessagePipe_CreateAndClose(void* closure) { 124 static void MessagePipe_CreateAndClose(void* closure) {
125 CorePerftest* self = static_cast<CorePerftest*>(closure); 125 CorePerftest* self = static_cast<CorePerftest*>(closure);
126 MojoResult result MOJO_ALLOW_UNUSED; 126 MojoResult result MOJO_ALLOW_UNUSED;
127 result = MojoCreateMessagePipe(&self->h0_, &self->h1_); 127 result = MojoCreateMessagePipe(NULL, &self->h0_, &self->h1_);
128 assert(result == MOJO_RESULT_OK); 128 assert(result == MOJO_RESULT_OK);
129 result = MojoClose(self->h0_); 129 result = MojoClose(self->h0_);
130 assert(result == MOJO_RESULT_OK); 130 assert(result == MOJO_RESULT_OK);
131 result = MojoClose(self->h1_); 131 result = MojoClose(self->h1_);
132 assert(result == MOJO_RESULT_OK); 132 assert(result == MOJO_RESULT_OK);
133 } 133 }
134 134
135 static void MessagePipe_WriteAndRead(void* closure) { 135 static void MessagePipe_WriteAndRead(void* closure) {
136 CorePerftest* self = static_cast<CorePerftest*>(closure); 136 CorePerftest* self = static_cast<CorePerftest*>(closure);
137 MojoResult result MOJO_ALLOW_UNUSED; 137 MojoResult result MOJO_ALLOW_UNUSED;
(...skipping 24 matching lines...) Expand all
162 #if !defined(WIN32) 162 #if !defined(WIN32)
163 void DoMessagePipeThreadedTest(unsigned num_writers, 163 void DoMessagePipeThreadedTest(unsigned num_writers,
164 unsigned num_readers, 164 unsigned num_readers,
165 uint32_t num_bytes) { 165 uint32_t num_bytes) {
166 static const int64_t kPerftestTimeMicroseconds = 3 * 1000000; 166 static const int64_t kPerftestTimeMicroseconds = 3 * 1000000;
167 167
168 assert(num_writers > 0); 168 assert(num_writers > 0);
169 assert(num_readers > 0); 169 assert(num_readers > 0);
170 170
171 MojoResult result MOJO_ALLOW_UNUSED; 171 MojoResult result MOJO_ALLOW_UNUSED;
172 result = MojoCreateMessagePipe(&h0_, &h1_); 172 result = MojoCreateMessagePipe(NULL, &h0_, &h1_);
173 assert(result == MOJO_RESULT_OK); 173 assert(result == MOJO_RESULT_OK);
174 174
175 std::vector<MessagePipeWriterThread*> writers; 175 std::vector<MessagePipeWriterThread*> writers;
176 for (unsigned i = 0; i < num_writers; i++) 176 for (unsigned i = 0; i < num_writers; i++)
177 writers.push_back(new MessagePipeWriterThread(h0_, num_bytes)); 177 writers.push_back(new MessagePipeWriterThread(h0_, num_bytes));
178 178
179 std::vector<MessagePipeReaderThread*> readers; 179 std::vector<MessagePipeReaderThread*> readers;
180 for (unsigned i = 0; i < num_readers; i++) 180 for (unsigned i = 0; i < num_readers; i++)
181 readers.push_back(new MessagePipeReaderThread(h1_)); 181 readers.push_back(new MessagePipeReaderThread(h1_));
182 182
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 TEST_F(CorePerftest, MessagePipe_CreateAndClose) { 268 TEST_F(CorePerftest, MessagePipe_CreateAndClose) {
269 mojo::test::IterateAndReportPerf("MessagePipe_CreateAndClose", 269 mojo::test::IterateAndReportPerf("MessagePipe_CreateAndClose",
270 &CorePerftest::MessagePipe_CreateAndClose, 270 &CorePerftest::MessagePipe_CreateAndClose,
271 this); 271 this);
272 } 272 }
273 273
274 TEST_F(CorePerftest, MessagePipe_WriteAndRead) { 274 TEST_F(CorePerftest, MessagePipe_WriteAndRead) {
275 MojoResult result MOJO_ALLOW_UNUSED; 275 MojoResult result MOJO_ALLOW_UNUSED;
276 result = MojoCreateMessagePipe(&h0_, &h1_); 276 result = MojoCreateMessagePipe(NULL, &h0_, &h1_);
277 assert(result == MOJO_RESULT_OK); 277 assert(result == MOJO_RESULT_OK);
278 char buffer[10000] = { 0 }; 278 char buffer[10000] = { 0 };
279 buffer_ = buffer; 279 buffer_ = buffer;
280 num_bytes_ = 10u; 280 num_bytes_ = 10u;
281 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_10bytes", 281 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_10bytes",
282 &CorePerftest::MessagePipe_WriteAndRead, 282 &CorePerftest::MessagePipe_WriteAndRead,
283 this); 283 this);
284 num_bytes_ = 100u; 284 num_bytes_ = 100u;
285 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_100bytes", 285 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_100bytes",
286 &CorePerftest::MessagePipe_WriteAndRead, 286 &CorePerftest::MessagePipe_WriteAndRead,
287 this); 287 this);
288 num_bytes_ = 1000u; 288 num_bytes_ = 1000u;
289 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_1000bytes", 289 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_1000bytes",
290 &CorePerftest::MessagePipe_WriteAndRead, 290 &CorePerftest::MessagePipe_WriteAndRead,
291 this); 291 this);
292 num_bytes_ = 10000u; 292 num_bytes_ = 10000u;
293 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_10000bytes", 293 mojo::test::IterateAndReportPerf("MessagePipe_WriteAndRead_10000bytes",
294 &CorePerftest::MessagePipe_WriteAndRead, 294 &CorePerftest::MessagePipe_WriteAndRead,
295 this); 295 this);
296 result = MojoClose(h0_); 296 result = MojoClose(h0_);
297 assert(result == MOJO_RESULT_OK); 297 assert(result == MOJO_RESULT_OK);
298 result = MojoClose(h1_); 298 result = MojoClose(h1_);
299 assert(result == MOJO_RESULT_OK); 299 assert(result == MOJO_RESULT_OK);
300 } 300 }
301 301
302 TEST_F(CorePerftest, MessagePipe_EmptyRead) { 302 TEST_F(CorePerftest, MessagePipe_EmptyRead) {
303 MojoResult result MOJO_ALLOW_UNUSED; 303 MojoResult result MOJO_ALLOW_UNUSED;
304 result = MojoCreateMessagePipe(&h0_, &h1_); 304 result = MojoCreateMessagePipe(NULL, &h0_, &h1_);
305 assert(result == MOJO_RESULT_OK); 305 assert(result == MOJO_RESULT_OK);
306 mojo::test::IterateAndReportPerf("MessagePipe_EmptyRead", 306 mojo::test::IterateAndReportPerf("MessagePipe_EmptyRead",
307 &CorePerftest::MessagePipe_EmptyRead, 307 &CorePerftest::MessagePipe_EmptyRead,
308 this); 308 this);
309 result = MojoClose(h0_); 309 result = MojoClose(h0_);
310 assert(result == MOJO_RESULT_OK); 310 assert(result == MOJO_RESULT_OK);
311 result = MojoClose(h1_); 311 result = MojoClose(h1_);
312 assert(result == MOJO_RESULT_OK); 312 assert(result == MOJO_RESULT_OK);
313 } 313 }
314 314
(...skipping 13 matching lines...) Expand all
328 DoMessagePipeThreadedTest(1u, 1u, 10000u); 328 DoMessagePipeThreadedTest(1u, 1u, 10000u);
329 329
330 DoMessagePipeThreadedTest(3u, 3u, 10u); 330 DoMessagePipeThreadedTest(3u, 3u, 10u);
331 // 100 was done above. 331 // 100 was done above.
332 DoMessagePipeThreadedTest(3u, 3u, 1000u); 332 DoMessagePipeThreadedTest(3u, 3u, 1000u);
333 DoMessagePipeThreadedTest(3u, 3u, 10000u); 333 DoMessagePipeThreadedTest(3u, 3u, 10000u);
334 } 334 }
335 #endif // !defined(WIN32) 335 #endif // !defined(WIN32)
336 336
337 } // namespace 337 } // namespace
OLDNEW
« no previous file with comments | « mojo/public/c/system/message_pipe.h ('k') | mojo/public/c/system/tests/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698