| OLD | NEW |
| 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 #include "mojo/public/cpp/test_support/test_utils.h" | 5 #include "mojo/public/cpp/test_support/test_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/system/core.h" | 10 #include "mojo/public/cpp/system/core.h" |
| 11 #include "mojo/public/cpp/system/wait.h" |
| 11 #include "mojo/public/cpp/test_support/test_support.h" | 12 #include "mojo/public/cpp/test_support/test_support.h" |
| 12 | 13 |
| 13 namespace mojo { | 14 namespace mojo { |
| 14 namespace test { | 15 namespace test { |
| 15 | 16 |
| 16 bool WriteTextMessage(const MessagePipeHandle& handle, | 17 bool WriteTextMessage(const MessagePipeHandle& handle, |
| 17 const std::string& text) { | 18 const std::string& text) { |
| 18 MojoResult rv = WriteMessageRaw(handle, | 19 MojoResult rv = WriteMessageRaw(handle, |
| 19 text.data(), | 20 text.data(), |
| 20 static_cast<uint32_t>(text.size()), | 21 static_cast<uint32_t>(text.size()), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 nullptr, | 35 nullptr, |
| 35 &num_bytes, | 36 &num_bytes, |
| 36 nullptr, | 37 nullptr, |
| 37 &num_handles, | 38 &num_handles, |
| 38 MOJO_READ_MESSAGE_FLAG_NONE); | 39 MOJO_READ_MESSAGE_FLAG_NONE); |
| 39 if (rv == MOJO_RESULT_SHOULD_WAIT) { | 40 if (rv == MOJO_RESULT_SHOULD_WAIT) { |
| 40 if (did_wait) { | 41 if (did_wait) { |
| 41 assert(false); // Looping endlessly!? | 42 assert(false); // Looping endlessly!? |
| 42 return false; | 43 return false; |
| 43 } | 44 } |
| 44 rv = Wait(handle, MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE, | 45 rv = Wait(handle, MOJO_HANDLE_SIGNAL_READABLE); |
| 45 nullptr); | |
| 46 if (rv != MOJO_RESULT_OK) | 46 if (rv != MOJO_RESULT_OK) |
| 47 return false; | 47 return false; |
| 48 did_wait = true; | 48 did_wait = true; |
| 49 } else { | 49 } else { |
| 50 assert(!num_handles); | 50 assert(!num_handles); |
| 51 break; | 51 break; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 text->resize(num_bytes); | 55 text->resize(num_bytes); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 end_time = GetTimeTicksNow(); | 91 end_time = GetTimeTicksNow(); |
| 92 } while (end_time - start_time < kPerftestTimeMicroseconds); | 92 } while (end_time - start_time < kPerftestTimeMicroseconds); |
| 93 | 93 |
| 94 MojoTestSupportLogPerfResult(test_name, sub_test_name, | 94 MojoTestSupportLogPerfResult(test_name, sub_test_name, |
| 95 1000000.0 * iterations / (end_time - start_time), | 95 1000000.0 * iterations / (end_time - start_time), |
| 96 "iterations/second"); | 96 "iterations/second"); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace test | 99 } // namespace test |
| 100 } // namespace mojo | 100 } // namespace mojo |
| OLD | NEW |