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

Unified Diff: ipc/mojo/ipc_mojo_perftest.cc

Issue 536213002: Add ipc_mojo_perftests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed garbage Created 6 years, 3 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 | « ipc/mojo/ipc_mojo.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_mojo_perftest.cc
diff --git a/ipc/mojo/ipc_mojo_perftest.cc b/ipc/mojo/ipc_mojo_perftest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d4337037a9dcacda733d77637d7141275cfb0f07
--- /dev/null
+++ b/ipc/mojo/ipc_mojo_perftest.cc
@@ -0,0 +1,87 @@
+// Copyright 2014 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 "base/lazy_instance.h"
+#include "ipc/ipc_perftest_support.h"
+#include "ipc/mojo/ipc_channel_mojo.h"
+#include "mojo/embedder/test_embedder.h"
+
+namespace {
+
+// This is needed because we rely on //base/test:test_support_perf and
+// it provides main() which doesn't have Mojo initialization. We need
+// some way to call InitWithSimplePlatformSupport() only once before
+// using Mojo.
+struct MojoInitialier {
+ MojoInitialier() {
+ mojo::embedder::test::InitWithSimplePlatformSupport();
+ }
+};
+
+base::LazyInstance<MojoInitialier> g_mojo_initializer
+ = LAZY_INSTANCE_INITIALIZER;
+
+class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase {
+public:
+ typedef IPC::test::IPCChannelPerfTestBase Super;
+
+ MojoChannelPerfTest();
+
+ virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
+ const IPC::ChannelHandle& handle,
+ base::TaskRunner* runner) OVERRIDE {
+ return IPC::ChannelMojo::CreateFactory(
+ handle, IPC::Channel::MODE_SERVER, runner);
+ }
+
+ void set_io_thread_task_runner(base::TaskRunner* runner) {
+ io_thread_task_runner_ = runner;
+ }
+
+ private:
+ base::TaskRunner* io_thread_task_runner_;
+};
+
+MojoChannelPerfTest::MojoChannelPerfTest()
+ : io_thread_task_runner_() {
+ g_mojo_initializer.Get();
+}
+
+
+TEST_F(MojoChannelPerfTest, ChannelPingPong) {
+ RunTestChannelPingPong(GetDefaultTestParams());
+}
+
+TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) {
+ RunTestChannelProxyPingPong(GetDefaultTestParams());
+}
+
+class MojoTestClient : public IPC::test::PingPongTestClient {
+ public:
+ typedef IPC::test::PingPongTestClient SuperType;
+
+ MojoTestClient();
+
+ virtual scoped_ptr<IPC::Channel> CreateChannel(
+ IPC::Listener* listener) OVERRIDE;
+};
+
+MojoTestClient::MojoTestClient() {
+ g_mojo_initializer.Get();
+}
+
+scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
+ IPC::Listener* listener) {
+ return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create(
+ IPCTestBase::GetChannelName("PerformanceClient"),
+ IPC::Channel::MODE_CLIENT, listener,
+ task_runner()));
+}
+
+MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
+ MojoTestClient client;
+ return client.RunMain();
+}
+
+} // namespace
« no previous file with comments | « ipc/mojo/ipc_mojo.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698