#include <stddef.h>
#include <memory>
#include <vector>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/current_thread.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_observer.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_result_reporter.h"
#if BUILDFLAG(IS_POSIX)
#include <pthread.h>
#endif
namespace base {
namespace {
const int kNumRuns = …;
constexpr char kMetricPrefixThread[] = …;
constexpr char kMetricClockTimePerHop[] = …;
constexpr char kMetricCpuTimePerHop[] = …;
constexpr char kStoryBaseTask[] = …;
constexpr char kStoryBaseTaskWithObserver[] = …;
constexpr char kStoryBaseWaitableEvent[] = …;
constexpr char kStoryBaseCondVar[] = …;
constexpr char kStorySuffixOneThread[] = …;
constexpr char kStorySuffixFourThreads[] = …;
#if BUILDFLAG(IS_POSIX)
constexpr char kStoryBasePthreadCondVar[] = …;
#endif
perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) { … }
class ThreadPerfTest : public testing::Test { … };
class TaskPerfTest : public ThreadPerfTest { … };
TEST_F(TaskPerfTest, TaskPingPong) { … }
class MessageLoopObserver : public base::TaskObserver { … };
MessageLoopObserver message_loop_observer;
class TaskObserverPerfTest : public TaskPerfTest { … };
TEST_F(TaskObserverPerfTest, TaskPingPong) { … }
template <typename WaitableEventType>
class EventPerfTest : public ThreadPerfTest { … };
WaitableEventThreadPerfTest;
TEST_F(WaitableEventThreadPerfTest, EventPingPong) { … }
class ConditionVariableEvent { … };
ConditionVariablePerfTest;
TEST_F(ConditionVariablePerfTest, EventPingPong) { … }
#if BUILDFLAG(IS_POSIX)
class PthreadEvent { … };
PthreadEventPerfTest;
TEST_F(PthreadEventPerfTest, EventPingPong) { … }
#endif
}
}