#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_pump_type.h"
#include "base/strings/stringprintf.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/sequence_manager/sequence_manager_impl.h"
#include "base/task/single_thread_task_runner.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_ANDROID)
#include "base/android/java_handler_thread.h"
#endif
namespace base {
namespace {
constexpr char kMetricPrefixScheduleWork[] = …;
constexpr char kMetricMinBatchTime[] = …;
constexpr char kMetricMaxBatchTime[] = …;
constexpr char kMetricTotalTime[] = …;
constexpr char kMetricThreadTime[] = …;
perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) { … }
#if BUILDFLAG(IS_ANDROID)
class JavaHandlerThreadForTest : public android::JavaHandlerThread {
public:
explicit JavaHandlerThreadForTest(const char* name)
: android::JavaHandlerThread(name, base::ThreadType::kDefault) {}
using android::JavaHandlerThread::state;
using android::JavaHandlerThread::State;
};
#endif
}
class ScheduleWorkTest : public testing::Test { … };
TEST_F(ScheduleWorkTest, ThreadTimeToIOFromOneThread) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToIOFromTwoThreads) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToIOFromFourThreads) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToUIFromOneThread) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToUIFromTwoThreads) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToUIFromFourThreads) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToDefaultFromOneThread) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToDefaultFromTwoThreads) { … }
TEST_F(ScheduleWorkTest, ThreadTimeToDefaultFromFourThreads) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(ScheduleWorkTest, ThreadTimeToJavaFromOneThread) {
ScheduleWork(MessagePumpType::JAVA, 1);
}
TEST_F(ScheduleWorkTest, ThreadTimeToJavaFromTwoThreads) {
ScheduleWork(MessagePumpType::JAVA, 2);
}
TEST_F(ScheduleWorkTest, ThreadTimeToJavaFromFourThreads) {
ScheduleWork(MessagePumpType::JAVA, 4);
}
#endif
}