chromium/base/task/job_perftest.cc

// Copyright 2020 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 <atomic>
#include <optional>
#include <utility>
#include <vector>

#include "base/containers/queue.h"
#include "base/containers/stack.h"
#include "base/functional/callback_helpers.h"
#include "base/synchronization/lock.h"
#include "base/task/post_job.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"

namespace base {

namespace {

// The perftest implements the following assignment strategy:
// - Naive: See RunJobWithNaiveAssignment().
// - Dynamic: See RunJobWithDynamicAssignment().
// - Loop around: See RunJobWithLoopAround().
// The following test setups exists for different strategies, although
// not every combination is performed:
// - No-op: Work items are no-op tasks.
// - No-op + disrupted: 10 disruptive tasks are posted every 1ms.
// - Busy wait: Work items are busy wait for 5us.
// - Busy wait + disrupted

constexpr char kMetricPrefixJob[] =;
constexpr char kMetricWorkThroughput[] =;
constexpr char kStoryNoOpNaive[] =;
constexpr char kStoryBusyWaitNaive[] =;
constexpr char kStoryNoOpAtomic[] =;
constexpr char kStoryNoOpAtomicDisrupted[] =;
constexpr char kStoryBusyWaitAtomic[] =;
constexpr char kStoryBusyWaitAtomicDisrupted[] =;
constexpr char kStoryNoOpDynamic[] =;
constexpr char kStoryNoOpDynamicDisrupted[] =;
constexpr char kStoryBusyWaitDynamic[] =;
constexpr char kStoryBusyWaitDynamicDisrupted[] =;
constexpr char kStoryNoOpLoopAround[] =;
constexpr char kStoryNoOpLoopAroundDisrupted[] =;
constexpr char kStoryBusyWaitLoopAround[] =;
constexpr char kStoryBusyWaitLoopAroundDisrupted[] =;

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

// A thread-safe data structure that generates heuristic starting points in a
// range to process items in parallel.
// Note: we could expose this atomic-binary-search-index-generator in
// //base/util if it's useful for real-world use cases.
class IndexGenerator {};

struct WorkItem {};

class WorkList {};

RepeatingCallback<void(size_t)> BusyWaitCallback(TimeDelta delta) {}

// Posts |task_count| no-op tasks every |delay|.
void DisruptivePostTasks(size_t task_count, TimeDelta delay) {}

class JobPerfTest : public testing::Test {};

}  // namespace

TEST_F(JobPerfTest, NoOpWorkNaiveAssignment) {}

TEST_F(JobPerfTest, BusyWaitNaiveAssignment) {}

TEST_F(JobPerfTest, NoOpWorkAtomicAssignment) {}

TEST_F(JobPerfTest, NoOpDisruptedWorkAtomicAssignment) {}

TEST_F(JobPerfTest, BusyWaitAtomicAssignment) {}

TEST_F(JobPerfTest, BusyWaitDisruptedWorkAtomicAssignment) {}

TEST_F(JobPerfTest, NoOpWorkDynamicAssignment) {}

TEST_F(JobPerfTest, NoOpDisruptedWorkDynamicAssignment) {}

TEST_F(JobPerfTest, BusyWaitWorkDynamicAssignment) {}

TEST_F(JobPerfTest, BusyWaitDisruptedWorkDynamicAssignment) {}

TEST_F(JobPerfTest, NoOpWorkLoopAround) {}

TEST_F(JobPerfTest, NoOpDisruptedWorkLoopAround) {}

TEST_F(JobPerfTest, BusyWaitWorkLoopAround) {}

TEST_F(JobPerfTest, BusyWaitDisruptedWorkLoopAround) {}

}  // namespace base