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 // | |
5 // Note: This header should be compilable as C. | |
6 | 4 |
7 #ifndef MOJO_PUBLIC_C_SYSTEM_TESTS_PERFTEST_UTILS_H_ | 5 #ifndef MOJO_PUBLIC_C_SYSTEM_TESTS_PERFTEST_UTILS_H_ |
8 #define MOJO_PUBLIC_C_SYSTEM_TESTS_PERFTEST_UTILS_H_ | 6 #define MOJO_PUBLIC_C_SYSTEM_TESTS_PERFTEST_UTILS_H_ |
9 | 7 |
10 #include <functional> | 8 #include <functional> |
11 | 9 |
12 #include "mojo/public/c/system/time.h" | 10 #include "mojo/public/c/system/time.h" |
13 | 11 |
14 namespace mojo { | 12 namespace mojo { |
15 namespace test { | 13 namespace test { |
16 | 14 |
17 // How long to run each perf test for (in microseconds). | 15 // How long to run each perf test for (in microseconds). |
18 constexpr MojoTimeTicks kPerftestTimeMicroseconds = 3 * 1000000; | 16 constexpr MojoTimeTicks kPerftestTimeMicroseconds = 3 * 1000000; |
19 | 17 |
20 // Iterates the given function for |kPerftestTimeMicroseconds| and reports the | 18 // Iterates the given function for |kPerftestTimeMicroseconds| and reports the |
21 // number of iterations executed per second. | 19 // number of iterations executed per second. |
22 void IterateAndReportPerf(const char* test_name, | 20 void IterateAndReportPerf(const char* test_name, |
23 const char* sub_test_name, | 21 const char* sub_test_name, |
24 std::function<void()> single_iteration); | 22 std::function<void()> single_iteration); |
25 | 23 |
26 // Sleeps for the given amount of time (in microseconds). | 24 // Sleeps for the given amount of time (in microseconds). |
27 void Sleep(MojoTimeTicks microseconds); | 25 void Sleep(MojoTimeTicks microseconds); |
28 | 26 |
29 } // namespace test | 27 } // namespace test |
30 } // namespace mojo | 28 } // namespace mojo |
31 | 29 |
32 #endif // MOJO_PUBLIC_C_SYSTEM_TESTS_PERFTEST_UTILS_H_ | 30 #endif // MOJO_PUBLIC_C_SYSTEM_TESTS_PERFTEST_UTILS_H_ |
OLD | NEW |