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

Side by Side Diff: mojo/public/cpp/environment/tests/run_loop_async_wait_perftest.cc

Issue 2141083003: Add a perf test for async wait and fix a bug in mojo::RunLoop. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops Created 4 years, 5 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
« no previous file with comments | « mojo/public/cpp/environment/tests/BUILD.gn ('k') | mojo/public/cpp/utility/lib/run_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file has perf tests for async waits using |mojo::RunLoop| (i.e., the
6 // "standalone" |Environment|).
7
8 #include <stdio.h>
9
10 #include "mojo/public/c/environment/tests/async_waiter_perftest_helpers.h"
11 #include "mojo/public/cpp/environment/environment.h"
12 #include "mojo/public/cpp/test_support/test_support.h"
13 #include "mojo/public/cpp/utility/run_loop.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace mojo {
17 namespace {
18
19 constexpr MojoTimeTicks kPerftestTimeMicroseconds = 3 * 1000000;
20
21 TEST(RunLoopAsyncWaitPerftest, SingleThreaded) {
22 for (uint32_t num_handles = 1u; num_handles <= 10000u; num_handles *= 10u) {
23 RunLoop run_loop;
24
25 MojoTimeTicks start_time = 0;
26 MojoTimeTicks end_time = 0;
27 uint64_t raw_result = test::DoAsyncWaiterPerfTest(
28 Environment::GetDefaultAsyncWaiter(), num_handles,
29 [&start_time, &end_time]() {
30 RunLoop::current()->PostDelayedTask(
31 []() { RunLoop::current()->Quit(); }, kPerftestTimeMicroseconds);
32 start_time = MojoGetTimeTicksNow();
33 RunLoop::current()->Run();
34 end_time = MojoGetTimeTicksNow();
35 });
36
37 double result = static_cast<double>(raw_result) /
38 (static_cast<double>(end_time - start_time) / 1000000.0);
39 char sub_test_name[100] = {};
40 sprintf(sub_test_name, "%u", static_cast<unsigned>(num_handles));
41 test::LogPerfResult("RunLoopAsyncWaitPerftest.SingleThreaded",
42 sub_test_name, result, "callbacks/second");
43 }
44 }
45
46 } // namespace
47 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/environment/tests/BUILD.gn ('k') | mojo/public/cpp/utility/lib/run_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698