OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 wait sets via the C API. | 5 // This tests the performance of wait sets via the C API. |
6 | 6 |
7 #include "mojo/public/c/system/wait_set.h" | 7 #include "mojo/public/c/system/wait_set.h" |
8 | 8 |
9 #include <assert.h> | 9 #include <assert.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 | 12 |
13 #include <atomic> | 13 #include <atomic> |
14 #include <thread> | 14 #include <thread> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "mojo/public/c/system/handle.h" | 17 #include "mojo/public/c/system/handle.h" |
| 18 #include "mojo/public/c/system/macros.h" |
18 #include "mojo/public/c/system/message_pipe.h" | 19 #include "mojo/public/c/system/message_pipe.h" |
19 #include "mojo/public/c/system/result.h" | 20 #include "mojo/public/c/system/result.h" |
20 #include "mojo/public/c/system/tests/perftest_utils.h" | 21 #include "mojo/public/c/system/tests/perftest_utils.h" |
21 #include "mojo/public/cpp/system/macros.h" | |
22 #include "mojo/public/cpp/test_support/test_support.h" | 22 #include "mojo/public/cpp/test_support/test_support.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Creates a wait set, creates a bunch of message pipes, and populates the wait | 27 // Creates a wait set, creates a bunch of message pipes, and populates the wait |
28 // set with entries. There will be |num_entries| entries; the |i|-th entry will | 28 // set with entries. There will be |num_entries| entries; the |i|-th entry will |
29 // be given cookie |i| and will be watching for readability on the message pipe | 29 // be given cookie |i| and will be watching for readability on the message pipe |
30 // endpoint |h0s->at(i)| whose corresponding endpoint is |h1s->at(i)|. | 30 // endpoint |h0s->at(i)| whose corresponding endpoint is |h1s->at(i)|. |
31 void CreateAndPopulateWaitSet(unsigned num_entries, | 31 void CreateAndPopulateWaitSet(unsigned num_entries, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 TEST(WaitSetPerftest, ThreadedWait) { | 172 TEST(WaitSetPerftest, ThreadedWait) { |
173 DoWaitSetThreadedWaitTest(10u); | 173 DoWaitSetThreadedWaitTest(10u); |
174 DoWaitSetThreadedWaitTest(100u); | 174 DoWaitSetThreadedWaitTest(100u); |
175 DoWaitSetThreadedWaitTest(1000u); | 175 DoWaitSetThreadedWaitTest(1000u); |
176 DoWaitSetThreadedWaitTest(10000u); | 176 DoWaitSetThreadedWaitTest(10000u); |
177 } | 177 } |
178 | 178 |
179 } // namespace | 179 } // namespace |
OLD | NEW |