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

Unified Diff: mojo/public/cpp/bindings/tests/bindings_perftest.cc

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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
Index: mojo/public/cpp/bindings/tests/bindings_perftest.cc
diff --git a/mojo/public/cpp/bindings/tests/bindings_perftest.cc b/mojo/public/cpp/bindings/tests/bindings_perftest.cc
deleted file mode 100644
index 11b92ba44b47e1f74d4ae95d9d5b3bdc3328d696..0000000000000000000000000000000000000000
--- a/mojo/public/cpp/bindings/tests/bindings_perftest.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2015 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.
-
-#include "gtest/gtest.h"
-#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/test_support/test_support.h"
-#include "mojo/public/cpp/utility/run_loop.h"
-#include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h"
-
-namespace mojo {
-namespace {
-
-const double kMojoTicksPerSecond = 1000000.0;
-
-double MojoTicksToSeconds(MojoTimeTicks ticks) {
- return ticks / kMojoTicksPerSecond;
-}
-
-class PingServiceImpl : public test::PingService {
- public:
- explicit PingServiceImpl() {}
- ~PingServiceImpl() override {}
-
- // |PingService| methods:
- void Ping(const Callback<void()>& callback) override;
-
- private:
- MOJO_DISALLOW_COPY_AND_ASSIGN(PingServiceImpl);
-};
-
-void PingServiceImpl::Ping(const Callback<void()>& callback) {
- callback.Run();
-}
-
-class PingPongTest {
- public:
- explicit PingPongTest(test::PingServicePtr service);
-
- void Run(unsigned int iterations);
-
- private:
- void OnPingDone();
-
- test::PingServicePtr service_;
- unsigned int iterations_to_run_;
- unsigned int current_iterations_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(PingPongTest);
-};
-
-PingPongTest::PingPongTest(test::PingServicePtr service)
- : service_(service.Pass()) {}
-
-void PingPongTest::Run(unsigned int iterations) {
- iterations_to_run_ = iterations;
- current_iterations_ = 0;
-
- service_->Ping([this]() { OnPingDone(); });
- RunLoop::current()->Run();
-}
-
-void PingPongTest::OnPingDone() {
- current_iterations_++;
- if (current_iterations_ >= iterations_to_run_) {
- RunLoop::current()->Quit();
- return;
- }
-
- service_->Ping([this]() { OnPingDone(); });
-}
-
-struct BoundPingService {
- BoundPingService() : binding(&impl) { binding.Bind(GetProxy(&service)); }
-
- PingServiceImpl impl;
- test::PingServicePtr service;
- Binding<test::PingService> binding;
-};
-
-class MojoBindingsPerftest : public testing::Test {
- protected:
- RunLoop run_loop_;
-};
-
-TEST_F(MojoBindingsPerftest, InProcessPingPong) {
- test::PingServicePtr service;
- PingServiceImpl impl;
- Binding<test::PingService> binding(&impl, GetProxy(&service));
- PingPongTest test(service.Pass());
-
- {
- const unsigned int kIterations = 100000;
- const MojoTimeTicks start_time = MojoGetTimeTicksNow();
- test.Run(kIterations);
- const MojoTimeTicks end_time = MojoGetTimeTicksNow();
- test::LogPerfResult("InProcessPingPong", "0_Inactive",
- kIterations / MojoTicksToSeconds(end_time - start_time),
- "pings/second");
- }
-
- {
- const size_t kNumInactiveServices = 1000;
- BoundPingService* inactive_services =
- new BoundPingService[kNumInactiveServices];
-
- const unsigned int kIterations = 10000;
- const MojoTimeTicks start_time = MojoGetTimeTicksNow();
- test.Run(kIterations);
- const MojoTimeTicks end_time = MojoGetTimeTicksNow();
- test::LogPerfResult("InProcessPingPong", "1000_Inactive",
- kIterations / MojoTicksToSeconds(end_time - start_time),
- "pings/second");
-
- delete[] inactive_services;
- }
-}
-
-} // namespace
-} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/tests/binding_unittest.cc ('k') | mojo/public/cpp/bindings/tests/bounds_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698