Commit ca86c9e8 authored by jam's avatar jam Committed by Commit bot

Add some perf tests to compare Mojo overhead.

Specifically, this compares making mojo interface calls vs just sending raw IPC::Messages or callbacks.

Review-Url: https://codereview.chromium.org/2608403002
Cr-Commit-Position: refs/heads/master@{#442016}
parent a37268b7
......@@ -206,12 +206,14 @@ if (!is_ios) {
deps = [
":ipc",
":test_interfaces",
":test_support",
"//base",
"//base:i18n",
"//base/test:test_support",
"//mojo/edk/system",
"//mojo/edk/test:test_support",
"//mojo/edk/test:test_support_impl",
"//testing/gtest",
]
}
......@@ -219,8 +221,6 @@ if (!is_ios) {
static_library("test_support") {
testonly = true
sources = [
"ipc_perftest_support.cc",
"ipc_perftest_support.h",
"ipc_security_test_util.cc",
"ipc_security_test_util.h",
"ipc_test_base.cc",
......
This diff is collapsed.
This diff is collapsed.
// Copyright (c) 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.
#ifndef IPC_IPC_PERFTEST_SUPPORT_H_
#define IPC_IPC_PERFTEST_SUPPORT_H_
#include <stddef.h>
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/test/test_io_thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_test_base.h"
namespace IPC {
namespace test {
class ChannelReflectorListener;
class PingPongTestParams {
public:
PingPongTestParams(size_t size, int count)
: message_size_(size), message_count_(count) {
}
size_t message_size() const { return message_size_; }
int message_count() const { return message_count_; }
private:
size_t message_size_;
int message_count_;
};
class IPCChannelPerfTestBase : public IPCChannelMojoTestBase {
public:
IPCChannelPerfTestBase();
~IPCChannelPerfTestBase() override;
static std::vector<PingPongTestParams> GetDefaultTestParams();
void RunTestChannelPingPong(
const std::vector<PingPongTestParams>& params_list);
void RunTestChannelProxyPingPong(
const std::vector<PingPongTestParams>& params_list);
scoped_refptr<base::TaskRunner> io_task_runner() {
if (io_thread_)
return io_thread_->task_runner();
return base::ThreadTaskRunnerHandle::Get();
}
private:
std::unique_ptr<base::TestIOThread> io_thread_;
};
class PingPongTestClient {
public:
PingPongTestClient();
virtual ~PingPongTestClient();
virtual std::unique_ptr<Channel> CreateChannel(Listener* listener) = 0;
int RunMain();
scoped_refptr<base::TaskRunner> task_runner();
private:
base::MessageLoopForIO main_message_loop_;
std::unique_ptr<ChannelReflectorListener> listener_;
std::unique_ptr<Channel> channel_;
};
// This class locks the current thread to a particular CPU core. This is
// important because otherwise the different threads and processes of these
// tests end up on different CPU cores which means that all of the cores are
// lightly loaded so the OS (Windows and Linux) fails to ramp up the CPU
// frequency, leading to unpredictable and often poor performance.
class LockThreadAffinity {
public:
explicit LockThreadAffinity(int cpu_number);
~LockThreadAffinity();
private:
bool affinity_set_ok_;
#if defined(OS_WIN)
DWORD_PTR old_affinity_;
#elif defined(OS_LINUX)
cpu_set_t old_cpuset_;
#endif
DISALLOW_COPY_AND_ASSIGN(LockThreadAffinity);
};
}
}
#endif // IPC_IPC_PERFTEST_SUPPORT_H_
......@@ -28,3 +28,8 @@ interface PingReceiver {
interface IndirectTestDriver {
GetPingReceiver(associated PingReceiver& request);
};
interface Reflector {
Ping(string value) => (string value);
Quit();
};
......@@ -6,12 +6,18 @@
#include "base/command_line.h"
#include "base/test/perf_test_suite.h"
#include "base/test/test_io_thread.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/test/scoped_ipc_support.h"
#include "mojo/edk/test/test_support_impl.h"
int main(int argc, char** argv) {
base::PerfTestSuite test(argc, argv);
mojo::edk::Init();
base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart);
mojo::edk::test::ScopedIPCSupport ipc_support(test_io_thread.task_runner());
mojo::test::TestSupport::Init(new mojo::edk::test::TestSupportImpl());
return test.Run();
}
......@@ -21,10 +21,7 @@ int main(int argc, char** argv) {
mojo::edk::Init();
base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart);
// Leak this because its destructor calls mojo::edk::ShutdownIPCSupport which
// really does nothing in the new EDK but does depend on the current message
// loop, which is destructed inside base::LaunchUnitTests.
new mojo::edk::test::ScopedIPCSupport(test_io_thread.task_runner());
mojo::edk::test::ScopedIPCSupport ipc_support(test_io_thread.task_runner());
mojo::test::TestSupport::Init(new mojo::edk::test::TestSupportImpl());
return test.Run();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment