Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: cc/resources/texture_compressor_perftest.cc

Issue 1015373003: Add texture compression interface and ETC1 encoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move files from cc/resources/texture_compress to cc/resources/ Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resources/texture_compressor_perftest.cc
diff --git a/cc/resources/texture_compressor_perftest.cc b/cc/resources/texture_compressor_perftest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7d68bd6f5f3d9415e2d14de53de87fd4f860935f
--- /dev/null
+++ b/cc/resources/texture_compressor_perftest.cc
@@ -0,0 +1,103 @@
+// Copyright 2015 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/logging.h"
+#include "cc/debug/lap_timer.h"
+#include "cc/resources/texture_compressor.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/perf/perf_test.h"
+
+namespace cc {
+namespace {
+
+const int kTimeLimitMillis = 2000;
+const int kWarmupRuns = 5;
+const int kTimeCheckInterval = 10;
+
+const int kImageWidth = 256;
+const int kImageHeight = 256;
+const int kImageSizeInBytes = kImageWidth * kImageHeight * 4;
+
+const TextureCompressor::Quality kQualities[] = {
+ TextureCompressor::kQualityLow,
+ TextureCompressor::kQualityMedium,
+ TextureCompressor::kQualityHigh};
+
+std::string FormatName(TextureCompressor::Format format) {
+ switch (format) {
+ case TextureCompressor::kFormatETC1:
+ return "ETC1";
+ }
+
+ NOTREACHED();
+ return "";
+}
+
+std::string QualityName(TextureCompressor::Quality quality) {
+ switch (quality) {
+ case TextureCompressor::kQualityLow:
+ return "Low";
+ case TextureCompressor::kQualityMedium:
+ return "Medium";
+ case TextureCompressor::kQualityHigh:
+ return "High";
+ }
+
+ NOTREACHED();
+ return "";
+}
+
+class TextureCompressorPerfTest
+ : public testing::TestWithParam<TextureCompressor::Format> {
+ public:
+ TextureCompressorPerfTest()
+ : timer_(kWarmupRuns,
+ base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
+ kTimeCheckInterval) {}
+
+ void SetUp() override {
+ TextureCompressor::Format format = GetParam();
+ compressor_ = TextureCompressor::Create(format);
+ }
+
+ void RunTest(const std::string& name, TextureCompressor::Quality quality) {
+ timer_.Reset();
+ do {
+ compressor_->Compress(src_, dst_, kImageWidth, kImageHeight, quality);
+ timer_.NextLap();
+ } while (!timer_.HasTimeLimitExpired());
+
+ std::string str = FormatName(GetParam()) + " " + QualityName(quality);
+ perf_test::PrintResult("Compress256x256", name, str, timer_.MsPerLap(),
+ "us", true);
+ }
+
+ protected:
+ LapTimer timer_;
+ scoped_ptr<TextureCompressor> compressor_;
+ uint8_t src_[kImageSizeInBytes];
+ uint8_t dst_[kImageSizeInBytes];
+};
+
+TEST_P(TextureCompressorPerfTest, Compress256x256Image) {
+ for (int i = 0; i < kImageSizeInBytes; ++i)
+ src_[i] = i % 256;
+
+ for (auto& quality : kQualities)
+ RunTest("Image", quality);
+}
+
+TEST_P(TextureCompressorPerfTest, Compress256x256SolidImage) {
+ memset(src_, 0, kImageSizeInBytes);
+
+ for (auto& quality : kQualities)
+ RunTest("SolidImage", quality);
+}
+
+INSTANTIATE_TEST_CASE_P(TextureCompressorPerfTests,
+ TextureCompressorPerfTest,
+ ::testing::Values(TextureCompressor::kFormatETC1));
+
+} // namespace
+} // namespace cc
« cc/resources/texture_compressor_etc1.cc ('K') | « cc/resources/texture_compressor_etc1.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698