OLD | NEW |
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 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/test/perf_time_logger.h" | |
14 #include "mojo/edk/embedder/scoped_platform_handle.h" | 13 #include "mojo/edk/embedder/scoped_platform_handle.h" |
15 #include "mojo/edk/system/local_message_pipe_endpoint.h" | 14 #include "mojo/edk/system/local_message_pipe_endpoint.h" |
16 #include "mojo/edk/system/message_pipe.h" | 15 #include "mojo/edk/system/message_pipe.h" |
17 #include "mojo/edk/system/message_pipe_test_utils.h" | 16 #include "mojo/edk/system/message_pipe_test_utils.h" |
18 #include "mojo/edk/system/proxy_message_pipe_endpoint.h" | 17 #include "mojo/edk/system/proxy_message_pipe_endpoint.h" |
19 #include "mojo/edk/system/ref_ptr.h" | 18 #include "mojo/edk/system/ref_ptr.h" |
| 19 #include "mojo/edk/system/test/perf_log.h" |
| 20 #include "mojo/edk/system/test/stopwatch.h" |
20 #include "mojo/edk/test/test_utils.h" | 21 #include "mojo/edk/test/test_utils.h" |
21 #include "mojo/public/cpp/system/macros.h" | 22 #include "mojo/public/cpp/system/macros.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 namespace mojo { | 25 namespace mojo { |
25 namespace system { | 26 namespace system { |
26 namespace { | 27 namespace { |
27 | 28 |
28 class MultiprocessMessagePipePerfTest | 29 class MultiprocessMessagePipePerfTest |
29 : public test::MultiprocessMessagePipeTestBase { | 30 : public test::MultiprocessMessagePipeTestBase { |
(...skipping 30 matching lines...) Expand all Loading... |
60 MOJO_RESULT_OK); | 61 MOJO_RESULT_OK); |
61 } | 62 } |
62 | 63 |
63 void Measure(MessagePipe* mp) { | 64 void Measure(MessagePipe* mp) { |
64 // Have one ping-pong to ensure channel being established. | 65 // Have one ping-pong to ensure channel being established. |
65 WriteWaitThenRead(mp); | 66 WriteWaitThenRead(mp); |
66 | 67 |
67 std::string test_name = | 68 std::string test_name = |
68 base::StringPrintf("IPC_Perf_%dx_%u", message_count_, | 69 base::StringPrintf("IPC_Perf_%dx_%u", message_count_, |
69 static_cast<unsigned>(message_size_)); | 70 static_cast<unsigned>(message_size_)); |
70 base::PerfTimeLogger logger(test_name.c_str()); | 71 test::Stopwatch stopwatch; |
71 | 72 |
| 73 stopwatch.Start(); |
72 for (int i = 0; i < message_count_; ++i) | 74 for (int i = 0; i < message_count_; ++i) |
73 WriteWaitThenRead(mp); | 75 WriteWaitThenRead(mp); |
74 | 76 test::LogPerfResult(test_name.c_str(), stopwatch.Elapsed() / 1000.0, "ms"); |
75 logger.Done(); | |
76 } | 77 } |
77 | 78 |
78 private: | 79 private: |
79 int message_count_; | 80 int message_count_; |
80 size_t message_size_; | 81 size_t message_size_; |
81 std::string payload_; | 82 std::string payload_; |
82 std::string read_buffer_; | 83 std::string read_buffer_; |
83 | 84 |
84 MOJO_DISALLOW_COPY_AND_ASSIGN(MultiprocessMessagePipePerfTest); | 85 MOJO_DISALLOW_COPY_AND_ASSIGN(MultiprocessMessagePipePerfTest); |
85 }; | 86 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 157 } |
157 | 158 |
158 SendQuitMessage(mp.get()); | 159 SendQuitMessage(mp.get()); |
159 mp->Close(0); | 160 mp->Close(0); |
160 EXPECT_EQ(0, helper()->WaitForChildShutdown()); | 161 EXPECT_EQ(0, helper()->WaitForChildShutdown()); |
161 } | 162 } |
162 | 163 |
163 } // namespace | 164 } // namespace |
164 } // namespace system | 165 } // namespace system |
165 } // namespace mojo | 166 } // namespace mojo |
OLD | NEW |