Commit d4ce3da7 authored by Ian Vollick's avatar Ian Vollick Committed by Commit Bot

[vr] Add a perftest for UI cpu work

This adds a perftest which moves the reticle around and measures the
UI costs.

Bug: None
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I688ad47adb6e3ba4f6cf5fd19410d348ba154e30
Reviewed-on: https://chromium-review.googlesource.com/993760
Commit-Queue: Ian Vollick <vollick@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548068}
parent d0138da3
......@@ -341,7 +341,14 @@ test("vr_pixeltests") {
test("vr_common_perftests") {
sources = [
"test/fake_ui_element_renderer.cc",
"test/fake_ui_element_renderer.h",
"test/perf_test_utils.cc",
"test/perf_test_utils.h",
"test/run_all_perftests.cc",
"test/ui_perftest.cc",
"test/ui_test.cc",
"test/ui_test.h",
"text_perftest.cc",
]
deps = [
......
// Copyright 2018 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 "chrome/browser/vr/test/perf_test_utils.h"
#include "testing/perf/perf_test.h"
namespace vr {
void PrintResults(const std::string& suite_name,
const std::string& test_name,
cc::LapTimer* timer) {
perf_test::PrintResult(suite_name, ".render_time_avg", test_name,
timer->MsPerLap(), "ms", true);
perf_test::PrintResult(suite_name, ".number_of_runs", test_name,
static_cast<size_t>(timer->NumLaps()), "runs", true);
}
} // namespace vr
// Copyright 2018 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 CHROME_BROWSER_VR_TEST_PERF_TEST_UTILS_H_
#define CHROME_BROWSER_VR_TEST_PERF_TEST_UTILS_H_
#include <string>
#include "cc/base/lap_timer.h"
namespace vr {
void PrintResults(const std::string& suite_name,
const std::string& test_name,
cc::LapTimer* timer);
} // namespace vr
#endif // CHROME_BROWSER_VR_TEST_PERF_TEST_UTILS_H_
// Copyright 2018 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 "base/strings/utf_string_conversions.h"
#include "cc/base/lap_timer.h"
#include "chrome/browser/vr/model/controller_model.h"
#include "chrome/browser/vr/test/constants.h"
#include "chrome/browser/vr/test/perf_test_utils.h"
#include "chrome/browser/vr/test/ui_test.h"
#include "chrome/browser/vr/ui_input_manager.h"
#include "chrome/browser/vr/ui_renderer.h"
#include "chrome/browser/vr/ui_scene.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h"
#include "ui/gfx/geometry/quaternion.h"
namespace vr {
namespace {
constexpr size_t kNumCycles = 500;
constexpr size_t kNumSteps = 20;
constexpr size_t kTimeLimitMs = 3000;
constexpr size_t kNumWarmupLaps = 20;
constexpr char kSuiteName[] = "UiPerfTest";
} // namespace
class UiPerfTest : public UiTest {
public:
UiPerfTest()
: timer_(kNumWarmupLaps,
base::TimeDelta::FromMilliseconds(kTimeLimitMs),
kNumSteps) {}
~UiPerfTest() override {}
protected:
cc::LapTimer timer_;
};
TEST_F(UiPerfTest, MoveController) {
CreateScene(kNotInCct, kNotInWebVr);
std::vector<UiElementName> names = {kContentQuad, kUrlBarBackButton,
kUrlBarUrlText};
gfx::Vector3dF direction = kForwardVector;
timer_.Reset();
for (size_t i = 0; i < kNumCycles; ++i) {
for (auto name : names) {
// Start interpolation toward next target.
auto* element = scene_->GetUiElementByName(name);
gfx::Vector3dF target = element->GetCenter() - gfx::Point3F();
gfx::Quaternion q(direction, target);
for (size_t k = 0; k < kNumSteps; ++k) {
ControllerModel controller_model;
controller_model.laser_direction = direction;
ReticleModel reticle_model;
GestureList gesture_list;
double t = k / (static_cast<double>(kNumSteps) - 1);
gfx::Transform(gfx::Quaternion().Slerp(q, t))
.TransformVector(&controller_model.laser_direction);
ui_->input_manager()->HandleInput(current_time_, RenderInfo(),
controller_model, &reticle_model,
&gesture_list);
ui_->OnControllerUpdated(controller_model, reticle_model);
OnDelayedFrame(base::TimeDelta::FromMilliseconds(16));
scene_->UpdateTextures();
timer_.NextLap();
}
direction = target;
}
}
PrintResults(kSuiteName, "move_controller", &timer_);
}
} // namespace vr
......@@ -111,7 +111,6 @@ class UiTest : public testing::Test {
Model* model_ = nullptr;
UiScene* scene_ = nullptr;
private:
base::TimeTicks current_time_;
};
......
......@@ -9,6 +9,7 @@
#include "chrome/browser/vr/ganesh_surface_provider.h"
#include "chrome/browser/vr/test/constants.h"
#include "chrome/browser/vr/test/gl_test_environment.h"
#include "chrome/browser/vr/test/perf_test_utils.h"
#include "skia/ext/texture_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h"
......@@ -21,6 +22,7 @@ namespace {
constexpr size_t kNumberOfRuns = 35;
constexpr float kFontHeightMeters = 0.05f;
constexpr float kTextWidthMeters = 1.0f;
constexpr char kSuiteName[] = "TextPerfTest";
} // namespace
......@@ -42,13 +44,6 @@ class TextPerfTest : public testing::Test {
}
protected:
void PrintResults(const std::string& name) {
perf_test::PrintResult("TextPerfTest", ".render_time_avg", name,
timer_.MsPerLap(), "ms", true);
perf_test::PrintResult("TextPerfTest", ".number_of_runs", name,
static_cast<size_t>(timer_.NumLaps()), "runs", true);
}
void RenderAndLapTimer() {
static_cast<UiElement*>(text_element_.get())->PrepareToDraw();
// Make sure all GL commands are applied before we measure the time.
......@@ -72,7 +67,7 @@ TEST_F(TextPerfTest, RenderLoremIpsum100Chars) {
text_element_->SetText(text);
RenderAndLapTimer();
}
PrintResults("render_lorem_ipsum_100_chars");
PrintResults(kSuiteName, "render_lorem_ipsum_100_chars", &timer_);
}
TEST_F(TextPerfTest, RenderLoremIpsum700Chars) {
......@@ -83,7 +78,7 @@ TEST_F(TextPerfTest, RenderLoremIpsum700Chars) {
text_element_->SetText(text);
RenderAndLapTimer();
}
PrintResults("render_lorem_ipsum_700_chars");
PrintResults(kSuiteName, "render_lorem_ipsum_700_chars", &timer_);
}
TEST_F(TextPerfTest, RenderLoremIpsum100Chars_NoTextChange) {
......@@ -94,7 +89,8 @@ TEST_F(TextPerfTest, RenderLoremIpsum100Chars_NoTextChange) {
for (size_t i = 0; i < kNumberOfRuns; i++) {
RenderAndLapTimer();
}
PrintResults("render_lorem_ipsum_100_chars_no_text_change");
PrintResults(kSuiteName, "render_lorem_ipsum_100_chars_no_text_change",
&timer_);
}
TEST_F(TextPerfTest, RenderLoremIpsum700Chars_NoTextChange) {
......@@ -105,7 +101,8 @@ TEST_F(TextPerfTest, RenderLoremIpsum700Chars_NoTextChange) {
for (size_t i = 0; i < kNumberOfRuns; i++) {
RenderAndLapTimer();
}
PrintResults("render_lorem_ipsum_700_chars_no_text_change");
PrintResults(kSuiteName, "render_lorem_ipsum_700_chars_no_text_change",
&timer_);
}
} // namespace vr
......@@ -135,6 +135,7 @@ bool UiScene::OnBeginFrame(const base::TimeTicks& current_time,
}
bool UiScene::UpdateTextures() {
TRACE_EVENT0("gpu", "UiScene::UpdateTextures");
bool needs_redraw = false;
// Update textures and sizes.
for (auto& element : *root_element_) {
......
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