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

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

Issue 134823005: Mojo: re-organize public tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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
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/system/core.h" 7 #include "mojo/public/system/core.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "mojo/public/tests/test_support.h" 12 #include "mojo/public/tests/test_support.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace { 15 namespace {
16 16
17 class SystemPerftest : public testing::Test { 17 class CorePerftest : public testing::Test {
18 public: 18 public:
19 SystemPerftest() {} 19 CorePerftest() {}
20 virtual ~SystemPerftest() {} 20 virtual ~CorePerftest() {}
21 21
22 void NoOp() { 22 void NoOp() {
23 } 23 }
24 24
25 void MessagePipe_CreateAndClose() { 25 void MessagePipe_CreateAndClose() {
26 MojoResult result; 26 MojoResult result;
27 result = MojoCreateMessagePipe(&h_0_, &h_1_); 27 result = MojoCreateMessagePipe(&h_0_, &h_1_);
28 DCHECK_EQ(result, MOJO_RESULT_OK); 28 DCHECK_EQ(result, MOJO_RESULT_OK);
29 result = MojoClose(h_0_); 29 result = MojoClose(h_0_);
30 DCHECK_EQ(result, MOJO_RESULT_OK); 30 DCHECK_EQ(result, MOJO_RESULT_OK);
(...skipping 23 matching lines...) Expand all
54 NULL, NULL, 54 NULL, NULL,
55 MOJO_READ_MESSAGE_FLAG_MAY_DISCARD); 55 MOJO_READ_MESSAGE_FLAG_MAY_DISCARD);
56 DCHECK_EQ(result, MOJO_RESULT_SHOULD_WAIT); 56 DCHECK_EQ(result, MOJO_RESULT_SHOULD_WAIT);
57 } 57 }
58 58
59 protected: 59 protected:
60 MojoHandle h_0_; 60 MojoHandle h_0_;
61 MojoHandle h_1_; 61 MojoHandle h_1_;
62 62
63 private: 63 private:
64 DISALLOW_COPY_AND_ASSIGN(SystemPerftest); 64 DISALLOW_COPY_AND_ASSIGN(CorePerftest);
65 }; 65 };
66 66
67 // A no-op test so we can compare performance. 67 // A no-op test so we can compare performance.
68 TEST_F(SystemPerftest, NoOp) { 68 TEST_F(CorePerftest, NoOp) {
69 mojo::test::IterateAndReportPerf( 69 mojo::test::IterateAndReportPerf(
70 "NoOp", 70 "NoOp",
71 base::Bind(&SystemPerftest::NoOp, 71 base::Bind(&CorePerftest::NoOp,
72 base::Unretained(this))); 72 base::Unretained(this)));
73 } 73 }
74 74
75 TEST_F(SystemPerftest, MessagePipe_CreateAndClose) { 75 TEST_F(CorePerftest, MessagePipe_CreateAndClose) {
76 mojo::test::IterateAndReportPerf( 76 mojo::test::IterateAndReportPerf(
77 "MessagePipe_CreateAndClose", 77 "MessagePipe_CreateAndClose",
78 base::Bind(&SystemPerftest::MessagePipe_CreateAndClose, 78 base::Bind(&CorePerftest::MessagePipe_CreateAndClose,
79 base::Unretained(this))); 79 base::Unretained(this)));
80 } 80 }
81 81
82 TEST_F(SystemPerftest, MessagePipe_WriteAndRead) { 82 TEST_F(CorePerftest, MessagePipe_WriteAndRead) {
83 CHECK_EQ(MojoCreateMessagePipe(&h_0_, &h_1_), MOJO_RESULT_OK); 83 CHECK_EQ(MojoCreateMessagePipe(&h_0_, &h_1_), MOJO_RESULT_OK);
84 char buffer[10000] = { 0 }; 84 char buffer[10000] = { 0 };
85 mojo::test::IterateAndReportPerf( 85 mojo::test::IterateAndReportPerf(
86 "MessagePipe_WriteAndRead_10bytes", 86 "MessagePipe_WriteAndRead_10bytes",
87 base::Bind(&SystemPerftest::MessagePipe_WriteAndRead, 87 base::Bind(&CorePerftest::MessagePipe_WriteAndRead,
88 base::Unretained(this), 88 base::Unretained(this),
89 static_cast<void*>(buffer), static_cast<uint32_t>(10))); 89 static_cast<void*>(buffer), static_cast<uint32_t>(10)));
90 mojo::test::IterateAndReportPerf( 90 mojo::test::IterateAndReportPerf(
91 "MessagePipe_WriteAndRead_100bytes", 91 "MessagePipe_WriteAndRead_100bytes",
92 base::Bind(&SystemPerftest::MessagePipe_WriteAndRead, 92 base::Bind(&CorePerftest::MessagePipe_WriteAndRead,
93 base::Unretained(this), 93 base::Unretained(this),
94 static_cast<void*>(buffer), static_cast<uint32_t>(100))); 94 static_cast<void*>(buffer), static_cast<uint32_t>(100)));
95 mojo::test::IterateAndReportPerf( 95 mojo::test::IterateAndReportPerf(
96 "MessagePipe_WriteAndRead_1000bytes", 96 "MessagePipe_WriteAndRead_1000bytes",
97 base::Bind(&SystemPerftest::MessagePipe_WriteAndRead, 97 base::Bind(&CorePerftest::MessagePipe_WriteAndRead,
98 base::Unretained(this), 98 base::Unretained(this),
99 static_cast<void*>(buffer), static_cast<uint32_t>(1000))); 99 static_cast<void*>(buffer), static_cast<uint32_t>(1000)));
100 mojo::test::IterateAndReportPerf( 100 mojo::test::IterateAndReportPerf(
101 "MessagePipe_WriteAndRead_10000bytes", 101 "MessagePipe_WriteAndRead_10000bytes",
102 base::Bind(&SystemPerftest::MessagePipe_WriteAndRead, 102 base::Bind(&CorePerftest::MessagePipe_WriteAndRead,
103 base::Unretained(this), 103 base::Unretained(this),
104 static_cast<void*>(buffer), static_cast<uint32_t>(10000))); 104 static_cast<void*>(buffer), static_cast<uint32_t>(10000)));
105 CHECK_EQ(MojoClose(h_0_), MOJO_RESULT_OK); 105 CHECK_EQ(MojoClose(h_0_), MOJO_RESULT_OK);
106 CHECK_EQ(MojoClose(h_1_), MOJO_RESULT_OK); 106 CHECK_EQ(MojoClose(h_1_), MOJO_RESULT_OK);
107 } 107 }
108 108
109 TEST_F(SystemPerftest, MessagePipe_EmptyRead) { 109 TEST_F(CorePerftest, MessagePipe_EmptyRead) {
110 CHECK_EQ(MojoCreateMessagePipe(&h_0_, &h_1_), MOJO_RESULT_OK); 110 CHECK_EQ(MojoCreateMessagePipe(&h_0_, &h_1_), MOJO_RESULT_OK);
111 mojo::test::IterateAndReportPerf( 111 mojo::test::IterateAndReportPerf(
112 "MessagePipe_EmptyRead", 112 "MessagePipe_EmptyRead",
113 base::Bind(&SystemPerftest::MessagePipe_EmptyRead, 113 base::Bind(&CorePerftest::MessagePipe_EmptyRead,
114 base::Unretained(this))); 114 base::Unretained(this)));
115 CHECK_EQ(MojoClose(h_0_), MOJO_RESULT_OK); 115 CHECK_EQ(MojoClose(h_0_), MOJO_RESULT_OK);
116 CHECK_EQ(MojoClose(h_1_), MOJO_RESULT_OK); 116 CHECK_EQ(MojoClose(h_1_), MOJO_RESULT_OK);
117 } 117 }
118 118
119 } // namespace 119 } // namespace
OLDNEW
« no previous file with comments | « mojo/public/tests/system/core_cpp_unittest.cc ('k') | mojo/public/tests/system/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698