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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/environment/tests/run_loop_async_wait_perftest.cc
diff --git a/mojo/public/cpp/environment/tests/run_loop_async_wait_perftest.cc b/mojo/public/cpp/environment/tests/run_loop_async_wait_perftest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c93cc76f0d3c360c5f997510e7c46e969329a88f
--- /dev/null
+++ b/mojo/public/cpp/environment/tests/run_loop_async_wait_perftest.cc
@@ -0,0 +1,47 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file has perf tests for async waits using |mojo::RunLoop| (i.e., the
+// "standalone" |Environment|).
+
+#include <stdio.h>
+
+#include "mojo/public/c/environment/tests/async_waiter_perftest_helpers.h"
+#include "mojo/public/cpp/environment/environment.h"
+#include "mojo/public/cpp/test_support/test_support.h"
+#include "mojo/public/cpp/utility/run_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace mojo {
+namespace {
+
+constexpr MojoTimeTicks kPerftestTimeMicroseconds = 3 * 1000000;
+
+TEST(RunLoopAsyncWaitPerftest, SingleThreaded) {
+ for (uint32_t num_handles = 1u; num_handles <= 10000u; num_handles *= 10u) {
+ RunLoop run_loop;
+
+ MojoTimeTicks start_time = 0;
+ MojoTimeTicks end_time = 0;
+ uint64_t raw_result = test::DoAsyncWaiterPerfTest(
+ Environment::GetDefaultAsyncWaiter(), num_handles,
+ [&start_time, &end_time]() {
+ RunLoop::current()->PostDelayedTask(
+ []() { RunLoop::current()->Quit(); }, kPerftestTimeMicroseconds);
+ start_time = MojoGetTimeTicksNow();
+ RunLoop::current()->Run();
+ end_time = MojoGetTimeTicksNow();
+ });
+
+ double result = static_cast<double>(raw_result) /
+ (static_cast<double>(end_time - start_time) / 1000000.0);
+ char sub_test_name[100] = {};
+ sprintf(sub_test_name, "%u", static_cast<unsigned>(num_handles));
+ test::LogPerfResult("RunLoopAsyncWaitPerftest.SingleThreaded",
+ sub_test_name, result, "callbacks/second");
+ }
+}
+
+} // namespace
+} // namespace mojo
« 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