Commit 0e04e05c authored by Sean Gilhuly's avatar Sean Gilhuly Committed by Chromium LUCI CQ

Initialize LapTimer in SurfaceAggregator perf tests

The LapTimer in RendererPerfTest is initialized from a command line
flag, but the LapTimer in SurfaceAggregatorPerfTest is only default
constructed.

Move LapTimer initialization to a VizPerfTest superclass to unify the
setup logic.

Bug: 1154343
Change-Id: I6fd02b26396368b82d3f1360129ef5f38c1a2c7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567625
Commit-Queue: Sean Gilhuly <sgilhuly@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833303}
parent 64d4d630
......@@ -625,6 +625,8 @@ viz_source_set("perf_tests") {
"display/gl_renderer_copier_perftest.cc",
"display/renderer_perftest.cc",
"display/surface_aggregator_perftest.cc",
"display/viz_perf_test.cc",
"display/viz_perf_test.h",
]
deps = [
......
......@@ -15,7 +15,6 @@
// --use_virtualized_gl_contexts=1
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/metrics/histogram.h"
......@@ -27,7 +26,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/timer/lap_timer.h"
#include "build/build_config.h"
#include "components/viz/client/client_resource_provider.h"
#include "components/viz/common/display/renderer_settings.h"
#include "components/viz/common/quads/render_pass_io.h"
......@@ -38,6 +37,7 @@
#include "components/viz/service/display/output_surface_client.h"
#include "components/viz/service/display/overlay_processor_stub.h"
#include "components/viz/service/display/skia_renderer.h"
#include "components/viz/service/display/viz_perf_test.h"
#include "components/viz/service/display_embedder/gl_output_surface_offscreen.h"
#include "components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
......@@ -77,21 +77,6 @@ perf_test::PerfResultReporter SetUpRendererReporter(const std::string& story) {
return reporter;
}
base::TimeDelta TestTimeLimit() {
static const char kPerfTestTimeMillis[] = "perf-test-time-ms";
auto* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kPerfTestTimeMillis)) {
const std::string delay_millis_string(
command_line->GetSwitchValueASCII(kPerfTestTimeMillis));
int delay_millis;
if (base::StringToInt(delay_millis_string, &delay_millis) &&
delay_millis > 0) {
return base::TimeDelta::FromMilliseconds(delay_millis);
}
}
return base::TimeDelta::FromSeconds(3);
}
class WaitForSwapDisplayClient : public DisplayClient {
public:
WaitForSwapDisplayClient() = default;
......@@ -281,7 +266,7 @@ bool CompositorRenderPassListFromJSON(
} // namespace
template <typename RendererType>
class RendererPerfTest : public testing::Test {
class RendererPerfTest : public VizPerfTest {
public:
RendererPerfTest()
: manager_(&shared_bitmap_manager_),
......@@ -289,10 +274,7 @@ class RendererPerfTest : public testing::Test {
std::make_unique<CompositorFrameSinkSupport>(nullptr,
&manager_,
kArbitraryFrameSinkId,
true /* is_root */)),
timer_(/*warmup_laps=*/100,
/*time_limit=*/TestTimeLimit(),
/*check_interval=*/10) {}
true /* is_root */)) {}
// Overloaded for concrete RendererType below.
std::unique_ptr<OutputSurface> CreateOutputSurface(
......@@ -308,6 +290,11 @@ class RendererPerfTest : public testing::Test {
else
printf("Using GLRenderer\n");
#if defined(OS_ANDROID)
renderer_settings_.color_space = gfx::ColorSpace::CreateSRGB();
renderer_settings_.initial_screen_size = kSurfaceSize;
#endif
auto* gpu_service = TestGpuServiceHolder::GetInstance()->gpu_service();
gpu_memory_buffer_manager_ =
......@@ -715,7 +702,6 @@ class RendererPerfTest : public testing::Test {
scoped_refptr<ContextProvider> child_context_provider_;
std::unique_ptr<ClientResourceProvider> child_resource_provider_;
std::vector<TransferableResource> resource_list_;
base::LapTimer timer_;
std::unique_ptr<gl::DisableNullDrawGLBindings> enable_pixel_output_;
DISALLOW_COPY_AND_ASSIGN(RendererPerfTest);
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/timer/lap_timer.h"
#include "cc/test/fake_output_surface_client.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/quads/compositor_frame.h"
......@@ -11,6 +10,7 @@
#include "components/viz/service/display/aggregated_frame.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/surface_aggregator.h"
#include "components/viz/service/display/viz_perf_test.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
......@@ -53,7 +53,7 @@ class ExpectedOutput {
size_t expected_quads_;
};
class SurfaceAggregatorPerfTest : public testing::Test {
class SurfaceAggregatorPerfTest : public VizPerfTest {
public:
SurfaceAggregatorPerfTest() : manager_(&shared_bitmap_manager_) {
context_provider_ = TestContextProvider::Create();
......@@ -201,7 +201,6 @@ class SurfaceAggregatorPerfTest : public testing::Test {
scoped_refptr<TestContextProvider> context_provider_;
std::unique_ptr<DisplayResourceProvider> resource_provider_;
std::unique_ptr<SurfaceAggregator> aggregator_;
base::LapTimer timer_;
};
TEST_F(SurfaceAggregatorPerfTest, ManySurfacesOpaque) {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/service/display/viz_perf_test.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
namespace viz {
namespace {
constexpr char kPerfTestTimeMillis[] = "perf-test-time-ms";
base::TimeDelta TestTimeLimit() {
auto* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kPerfTestTimeMillis)) {
const std::string delay_millis_string(
command_line->GetSwitchValueASCII(kPerfTestTimeMillis));
int delay_millis;
if (base::StringToInt(delay_millis_string, &delay_millis) &&
delay_millis > 0) {
return base::TimeDelta::FromMilliseconds(delay_millis);
}
}
return base::TimeDelta::FromSeconds(3);
}
} // namespace
VizPerfTest::VizPerfTest()
: timer_(/*warmup_laps=*/100,
/*time_limit=*/TestTimeLimit(),
/*check_interval=*/10) {}
} // namespace viz
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_VIZ_PERF_TEST_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_VIZ_PERF_TEST_H_
#include "base/timer/lap_timer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace viz {
// Viz perf test base class that sets up a lap timer with a specified duration.
class VizPerfTest : public testing::Test {
public:
VizPerfTest();
protected:
// Duration is set by the flag --perf-test-time-ms, defaults to 3 seconds.
base::LapTimer timer_;
};
} // namespace viz
#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_VIZ_PERF_TEST_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment