chromium/base/task/sequence_manager/sequence_manager_perftest.cc

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

#include "base/task/sequence_manager/sequence_manager.h"

#include <stddef.h>

#include <memory>
#include <optional>

#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/message_loop/message_pump_default.h"
#include "base/message_loop/message_pump_type.h"
#include "base/run_loop.h"
#include "base/sequence_checker.h"
#include "base/synchronization/condition_variable.h"
#include "base/task/sequence_manager/task_queue.h"
#include "base/task/sequence_manager/test/mock_time_domain.h"
#include "base/task/sequence_manager/test/sequence_manager_for_test.h"
#include "base/task/sequence_manager/test/test_task_time_observer.h"
#include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/task/thread_pool/thread_pool_impl.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/threading/thread.h"
#include "base/time/default_tick_clock.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"

namespace base {
namespace sequence_manager {
namespace {
const int kNumTasks =;

constexpr char kMetricPrefixSequenceManager[] =;
constexpr char kMetricPostTimePerTask[] =;

perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) {}

}  // namespace

// To reduce noise related to the OS timer, we use a mock time domain to
// fast forward the timers.
class PerfTestTimeDomain : public MockTimeDomain {};

enum class PerfTestType {};

// Customization point for SequenceManagerPerfTest which allows us to test
// various implementations.
class PerfTestDelegate {};

class BaseSequenceManagerPerfTestDelegate : public PerfTestDelegate {};

class SequenceManagerWithMessagePumpPerfTestDelegate
    : public BaseSequenceManagerPerfTestDelegate {};

class SingleThreadInThreadPoolPerfTestDelegate : public PerfTestDelegate {};

class TestCase {};

class TaskSource {};

class SameThreadTaskSource : public TaskSource {};

class CrossThreadTaskSource : public TaskSource {};

class SingleThreadImmediateTestCase : public TestCase {};

class SingleThreadDelayedTestCase : public TestCase {};

class TwoThreadTestCase : public TestCase {};

class SequenceManagerPerfTest : public testing::TestWithParam<PerfTestType> {};

INSTANTIATE_TEST_SUITE_P();
TEST_P(SequenceManagerPerfTest, PostDelayedTasks_OneQueue) {}

TEST_P(SequenceManagerPerfTest, PostDelayedTasks_FourQueues) {}

TEST_P(SequenceManagerPerfTest, PostDelayedTasks_EightQueues) {}

TEST_P(SequenceManagerPerfTest, PostDelayedTasks_ThirtyTwoQueues) {}

TEST_P(SequenceManagerPerfTest, PostImmediateTasks_OneQueue) {}

TEST_P(SequenceManagerPerfTest, PostImmediateTasks_FourQueues) {}

TEST_P(SequenceManagerPerfTest, PostImmediateTasks_EightQueues) {}

TEST_P(SequenceManagerPerfTest, PostImmediateTasks_ThirtyTwoQueues) {}

TEST_P(SequenceManagerPerfTest, PostImmediateTasksFromTwoThreads_OneQueue) {}

TEST_P(SequenceManagerPerfTest, PostImmediateTasksFromTwoThreads_FourQueues) {}

TEST_P(SequenceManagerPerfTest, PostImmediateTasksFromTwoThreads_EightQueues) {}

TEST_P(SequenceManagerPerfTest,
       PostImmediateTasksFromTwoThreads_ThirtyTwoQueues) {}

// TODO(alexclarke): Add additional tests with different mixes of non-delayed vs
// delayed tasks.

}  // namespace sequence_manager
}  // namespace base