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

Side by Side Diff: cc/resources/texture_compress/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: 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 unified diff | Download patch
« no previous file with comments | « cc/resources/texture_compress/texture_compressor_etc1.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "cc/debug/lap_timer.h"
7 #include "cc/resources/texture_compress/texture_compressor.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/perf/perf_test.h"
10
11 namespace cc {
12 namespace {
13
14 const int kTimeLimitMillis = 2000;
15 const int kWarmupRuns = 5;
16 const int kTimeCheckInterval = 10;
17
18 const int kImageWidth = 256;
19 const int kImageHeight = 256;
20 const int kImageSizeInBytes = kImageWidth * kImageHeight * 4;
21
22 const TextureCompressor::Quality kQualities[] = {
23 TextureCompressor::kQualityLow,
24 TextureCompressor::kQualityMedium,
25 TextureCompressor::kQualityHigh};
26
27 std::string FormatName(TextureCompressor::Format format) {
28 switch (format) {
29 case TextureCompressor::kFormatETC1:
30 return "ETC1";
31 }
32
33 NOTREACHED();
34 return "";
35 }
36
37 std::string QualityName(TextureCompressor::Quality quality) {
38 switch (quality) {
39 case TextureCompressor::kQualityLow:
40 return "Low";
41 case TextureCompressor::kQualityMedium:
42 return "Medium";
43 case TextureCompressor::kQualityHigh:
44 return "High";
45 }
46
47 NOTREACHED();
48 return "";
49 }
50
51 class TextureCompressorPerfTest
52 : public testing::TestWithParam<TextureCompressor::Format> {
53 public:
54 TextureCompressorPerfTest()
55 : timer_(kWarmupRuns,
56 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
57 kTimeCheckInterval) {}
58
59 void SetUp() override {
60 TextureCompressor::Format format = GetParam();
61 compressor_ = TextureCompressor::Create(format);
62 }
63
64 void RunTest(const std::string& name, TextureCompressor::Quality quality) {
65 if (!compressor_)
reveman 2015/03/20 15:15:55 nit: can you remove this check?
christiank 2015/03/23 07:36:56 Sure, now removed.
66 return;
67
68 timer_.Reset();
69 do {
70 compressor_->Compress(src_, dst_, kImageWidth, kImageHeight, quality);
71 timer_.NextLap();
72 } while (!timer_.HasTimeLimitExpired());
73
74 std::string str = FormatName(GetParam()) + " " + QualityName(quality);
75 perf_test::PrintResult("Compress256x256", name, str, timer_.MsPerLap(),
76 "us", true);
77 }
78
79 protected:
80 LapTimer timer_;
81 scoped_ptr<TextureCompressor> compressor_;
82 uint8_t src_[kImageSizeInBytes];
83 uint8_t dst_[kImageSizeInBytes];
84 };
85
86 TEST_P(TextureCompressorPerfTest, Compress256x256Image) {
87 for (int i = 0; i < kImageSizeInBytes; ++i)
88 src_[i] = i % 256;
89
90 for (auto& quality : kQualities)
91 RunTest("Image", quality);
92 }
93
94 TEST_P(TextureCompressorPerfTest, Compress256x256SolidImage) {
95 memset(src_, 0, kImageSizeInBytes);
96
97 for (auto& quality : kQualities)
98 RunTest("SolidImage", quality);
99 }
100
101 INSTANTIATE_TEST_CASE_P(TextureCompressorPerfTests,
102 TextureCompressorPerfTest,
103 ::testing::Values(TextureCompressor::kFormatETC1));
104
105 } // namespace
106 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/texture_compress/texture_compressor_etc1.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698