forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland "[vr] Measure text render speed in GTest"
This is a reland of 3bc3b8b Original change's description: > [vr] Measure text render speed in GTest > > This change also adds a new target for performance tests in VR > and a target for dependencies shared among vr test targets. > > Bug: 772551, 774636 > Change-Id: I7de0cd8a5fcba3e71358625c1f3ebfb9bab49fba > Reviewed-on: https://chromium-review.googlesource.com/703690 > Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org> > Reviewed-by: Scott Violet <sky@chromium.org> > Reviewed-by: Ian Vollick <vollick@chromium.org> > Cr-Commit-Position: refs/heads/master@{#509419} TBR=vollick@chromium.org,sky@chromium.org,leilei@chromium.org,cjgrant@chromium.org,tiborg@chromium.org Bug: 772551, 774636 Change-Id: I833e6dba30885fb7a902ac222614e8ab97f9f874 Reviewed-on: https://chromium-review.googlesource.com/723726 Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org> Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org> Cr-Commit-Position: refs/heads/master@{#509500}
- Loading branch information
Tibor Goldschwendt
authored and
Commit Bot
committed
Oct 17, 2017
1 parent
38bb988
commit 213a422
Showing
13 changed files
with
207 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2017 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/memory/ptr_util.h" | ||
#include "base/strings/utf_string_conversions.h" | ||
#include "cc/base/lap_timer.h" | ||
#include "chrome/browser/vr/elements/text.h" | ||
#include "chrome/browser/vr/test/constants.h" | ||
#include "chrome/browser/vr/test/gl_test_environment.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "testing/perf/perf_test.h" | ||
|
||
namespace vr { | ||
|
||
namespace { | ||
|
||
constexpr int kMaximumTextWidthPixels = 512; | ||
constexpr size_t kNumberOfRuns = 35; | ||
constexpr float kFontHeightMeters = 0.05f; | ||
constexpr float kTextWidthMeters = 1.0f; | ||
|
||
} // namespace | ||
|
||
class TextPerfTest : public testing::Test { | ||
public: | ||
void SetUp() override { | ||
gl_test_environment_ = | ||
base::MakeUnique<GlTestEnvironment>(kPixelHalfScreen); | ||
text_element_ = base::MakeUnique<Text>(kMaximumTextWidthPixels, | ||
kFontHeightMeters, kTextWidthMeters); | ||
text_element_->Initialize(); | ||
} | ||
|
||
void TearDown() override { | ||
text_element_.reset(); | ||
gl_test_environment_.reset(); | ||
} | ||
|
||
protected: | ||
void PrintResults(const std::string& name) { | ||
perf_test::PrintResult(name, "", "render_time_avg", timer_.MsPerLap(), "ms", | ||
true); | ||
perf_test::PrintResult(name, "", "number_of_runs", | ||
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. | ||
glFinish(); | ||
timer_.NextLap(); | ||
} | ||
|
||
std::unique_ptr<Text> text_element_; | ||
cc::LapTimer timer_; | ||
|
||
private: | ||
std::unique_ptr<GlTestEnvironment> gl_test_environment_; | ||
}; | ||
|
||
TEST_F(TextPerfTest, RenderLoremIpsum100Chars) { | ||
base::string16 text = base::UTF8ToUTF16(kLoremIpsum100Chars); | ||
timer_.Reset(); | ||
for (size_t i = 0; i < kNumberOfRuns; i++) { | ||
text[0] = 'a' + (i % 26); | ||
text_element_->SetText(text); | ||
RenderAndLapTimer(); | ||
} | ||
PrintResults("render_lorem_ipsum_100_chars"); | ||
} | ||
|
||
TEST_F(TextPerfTest, RenderLoremIpsum700Chars) { | ||
base::string16 text = base::UTF8ToUTF16(kLoremIpsum700Chars); | ||
timer_.Reset(); | ||
for (size_t i = 0; i < kNumberOfRuns; i++) { | ||
text[0] = 'a' + (i % 26); | ||
text_element_->SetText(text); | ||
RenderAndLapTimer(); | ||
} | ||
PrintResults("render_lorem_ipsum_700_chars"); | ||
} | ||
|
||
} // namespace vr |
Oops, something went wrong.