Make LibvpxVp8Encoder::GetCpuSpeed() to always read from CpuSpeedExperiment for arm.

CpuSpeedExperiment: Add option to have a separate config for cores below a configurable threshold.

Bug: none
Change-Id: I51562979f3a89a949d014a1ee6fc0802f3c1dae5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/184926
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32154}
This commit is contained in:
Åsa Persson
2020-09-21 14:57:04 +02:00
committed by Commit Bot
parent edd7f9e94d
commit ceab7547f0
4 changed files with 89 additions and 29 deletions

View File

@ -18,17 +18,17 @@ namespace webrtc {
TEST(CpuSpeedExperimentTest, NoValueIfNotEnabled) {
CpuSpeedExperiment cpu_speed_config;
EXPECT_FALSE(cpu_speed_config.GetValue(1));
EXPECT_FALSE(cpu_speed_config.GetValue(1, /*num_cores=*/1));
}
TEST(CpuSpeedExperimentTest, GetValue) {
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-VP8-CpuSpeed-Arm/pixels:1000,cpu_speed:-12/");
"WebRTC-VP8-CpuSpeed-Arm/pixels:1000,cpu_speed:-12,cores:4/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_EQ(-12, cpu_speed_config.GetValue(1));
EXPECT_EQ(-12, cpu_speed_config.GetValue(1000));
EXPECT_EQ(-16, cpu_speed_config.GetValue(1001));
EXPECT_EQ(-12, cpu_speed_config.GetValue(1, /*num_cores=*/1));
EXPECT_EQ(-12, cpu_speed_config.GetValue(1000, /*num_cores=*/1));
EXPECT_EQ(-16, cpu_speed_config.GetValue(1001, /*num_cores=*/1));
}
TEST(CpuSpeedExperimentTest, GetValueWithList) {
@ -36,13 +36,37 @@ TEST(CpuSpeedExperimentTest, GetValueWithList) {
"WebRTC-VP8-CpuSpeed-Arm/pixels:1000|2000|3000,cpu_speed:-1|-10|-16/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_EQ(-1, cpu_speed_config.GetValue(1));
EXPECT_EQ(-1, cpu_speed_config.GetValue(1000));
EXPECT_EQ(-10, cpu_speed_config.GetValue(1001));
EXPECT_EQ(-10, cpu_speed_config.GetValue(2000));
EXPECT_EQ(-16, cpu_speed_config.GetValue(2001));
EXPECT_EQ(-16, cpu_speed_config.GetValue(3000));
EXPECT_EQ(-16, cpu_speed_config.GetValue(3001));
EXPECT_EQ(-1, cpu_speed_config.GetValue(1, /*num_cores=*/1));
EXPECT_EQ(-1, cpu_speed_config.GetValue(1000, /*num_cores=*/1));
EXPECT_EQ(-10, cpu_speed_config.GetValue(1001, /*num_cores=*/1));
EXPECT_EQ(-10, cpu_speed_config.GetValue(2000, /*num_cores=*/1));
EXPECT_EQ(-16, cpu_speed_config.GetValue(2001, /*num_cores=*/1));
EXPECT_EQ(-16, cpu_speed_config.GetValue(3000, /*num_cores=*/1));
EXPECT_EQ(-16, cpu_speed_config.GetValue(3001, /*num_cores=*/1));
}
TEST(CpuSpeedExperimentTest, GetValueWithCores) {
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-VP8-CpuSpeed-Arm/"
"pixels:1000|2000|3000,cpu_speed:-1|-10|-16,"
"cpu_speed_le_cores:-5|-11|-16,cores:2/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_EQ(-5, cpu_speed_config.GetValue(1000, /*num_cores=*/1));
EXPECT_EQ(-11, cpu_speed_config.GetValue(2000, /*num_cores=*/2));
EXPECT_EQ(-1, cpu_speed_config.GetValue(1000, /*num_cores=*/3));
EXPECT_EQ(-10, cpu_speed_config.GetValue(2000, /*num_cores=*/4));
}
TEST(CpuSpeedExperimentTest, GetValueWithCoresUnconfigured) {
webrtc::test::ScopedFieldTrials field_trials(
"WebRTC-VP8-CpuSpeed-Arm/"
"pixels:1000|2000|3000,cpu_speed:-1|-10|-16,"
"cpu_speed_le_cores:-5|-11|-16/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_EQ(-1, cpu_speed_config.GetValue(1000, /*num_cores=*/1));
EXPECT_EQ(-10, cpu_speed_config.GetValue(2000, /*num_cores=*/2));
}
TEST(CpuSpeedExperimentTest, GetValueFailsForTooSmallValue) {
@ -51,7 +75,7 @@ TEST(CpuSpeedExperimentTest, GetValueFailsForTooSmallValue) {
"WebRTC-VP8-CpuSpeed-Arm/pixels:1000|2000|3000,cpu_speed:-1|-10|-17/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_FALSE(cpu_speed_config.GetValue(1));
EXPECT_FALSE(cpu_speed_config.GetValue(1, /*num_cores=*/1));
}
TEST(CpuSpeedExperimentTest, GetValueFailsForTooLargeValue) {
@ -60,7 +84,7 @@ TEST(CpuSpeedExperimentTest, GetValueFailsForTooLargeValue) {
"WebRTC-VP8-CpuSpeed-Arm/pixels:1000|2000|3000,cpu_speed:0|-10|-16/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_FALSE(cpu_speed_config.GetValue(1));
EXPECT_FALSE(cpu_speed_config.GetValue(1, /*num_cores=*/1));
}
TEST(CpuSpeedExperimentTest, GetValueFailsIfPixelsDecreases) {
@ -68,7 +92,7 @@ TEST(CpuSpeedExperimentTest, GetValueFailsIfPixelsDecreases) {
"WebRTC-VP8-CpuSpeed-Arm/pixels:1000|999|3000,cpu_speed:-5|-10|-16/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_FALSE(cpu_speed_config.GetValue(1));
EXPECT_FALSE(cpu_speed_config.GetValue(1, /*num_cores=*/1));
}
TEST(CpuSpeedExperimentTest, GetValueFailsIfCpuSpeedIncreases) {
@ -76,7 +100,7 @@ TEST(CpuSpeedExperimentTest, GetValueFailsIfCpuSpeedIncreases) {
"WebRTC-VP8-CpuSpeed-Arm/pixels:1000|2000|3000,cpu_speed:-5|-4|-16/");
CpuSpeedExperiment cpu_speed_config;
EXPECT_FALSE(cpu_speed_config.GetValue(1));
EXPECT_FALSE(cpu_speed_config.GetValue(1, /*num_cores=*/1));
}
} // namespace webrtc