chromium/ipc/ipc_mojo_perftest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>

#include <memory>
#include <tuple>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/process/process_metrics.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/perf_time_logger.h"
#include "base/test/task_environment.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ipc/ipc_channel_mojo.h"
#include "ipc/ipc_perftest_messages.h"
#include "ipc/ipc_perftest_util.h"
#include "ipc/ipc_sync_channel.h"
#include "ipc/ipc_test.mojom.h"
#include "ipc/ipc_test_base.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/test/mojo_test_base.h"
#include "mojo/core/test/multiprocess_test_helper.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/message_pipe.h"

namespace IPC {
namespace {

class PerformanceChannelListener : public Listener {};

class PingPongTestParams {};

class InterfacePassingTestParams {};

#ifdef NDEBUG
const int kMultiplier = 100;
#else
  // Debug builds on Windows run these tests orders of magnitude more slowly.
const int kMultiplier =;
#endif

std::vector<PingPongTestParams> GetDefaultTestParams() {}

std::vector<InterfacePassingTestParams> GetDefaultInterfacePassingTestParams() {}

class MojoChannelPerfTest : public IPCChannelMojoTestBase {};

TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) {}

TEST_F(MojoChannelPerfTest, ChannelProxySyncPing) {}

MULTIPROCESS_TEST_MAIN(MojoPerfTestClientTestChildMain) {}

class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase {};

class InterfacePassingTestDriverImpl : public mojom::InterfacePassingTestDriver,
                                       public mojom::PingReceiver {};

class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {};

DEFINE_TEST_CLIENT_WITH_PIPE(InterfacePassingClient,
                             MojoInterfacePassingPerfTest,
                             h) {}

enum class InProcessMessageMode {};

template <class TestBase>
class InProcessPerfTest
    : public TestBase,
      public testing::WithParamInterface<InProcessMessageMode> {};

MojoInProcessInterfacePerfTest;
MojoInProcessInterfacePassingPerfTest;

DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoInterfacePerfTest, h) {}

// Similar to MojoChannelPerfTest above, but uses a Mojo interface instead of
// raw IPC::Messages.
TEST_F(MojoInterfacePerfTest, MultiprocessPingPong) {}

TEST_F(MojoInterfacePerfTest, MultiprocessSyncPing) {}

TEST_F(MojoInterfacePassingPerfTest, MultiprocessInterfacePassing) {}

TEST_F(MojoInterfacePassingPerfTest, MultiprocessAssociatedInterfacePassing) {}

// A single process version of the above test.
TEST_P(MojoInProcessInterfacePerfTest, MultiThreadPingPong) {}

TEST_P(MojoInProcessInterfacePerfTest, SingleThreadPingPong) {}

INSTANTIATE_TEST_SUITE_P();

TEST_P(MojoInProcessInterfacePassingPerfTest, MultiThreadInterfacePassing) {}

TEST_P(MojoInProcessInterfacePassingPerfTest,
       MultiThreadAssociatedInterfacePassing) {}

TEST_P(MojoInProcessInterfacePassingPerfTest, SingleThreadInterfacePassing) {}

TEST_P(MojoInProcessInterfacePassingPerfTest,
       SingleThreadAssociatedInterfacePassing) {}

INSTANTIATE_TEST_SUITE_P();

class CallbackPerfTest : public testing::Test {};

// Sends the same data as above using PostTask to a different thread instead of
// IPCs for comparison.
TEST_F(CallbackPerfTest, MultiThreadPingPong) {}

// Sends the same data as above using PostTask to the same thread.
TEST_F(CallbackPerfTest, SingleThreadPostTaskPingPong) {}

// Sends the same data as above without using PostTask to the same thread.
TEST_F(CallbackPerfTest, SingleThreadNoPostTaskPingPong) {}

}  // namespace
}  // namespace IPC