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

Side by Side Diff: cc/tiles/software_image_decode_cache_perftest.cc

Issue 2669933002: cc: Optimize ImageDecodeCacheKey::FromDrawImage. (Closed)
Patch Set: 8k->4k Created 3 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2017 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 <vector>
6
7 #include "cc/debug/lap_timer.h"
8 #include "cc/playback/draw_image.h"
9 #include "cc/raster/tile_task.h"
10 #include "cc/tiles/software_image_decode_cache.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/perf/perf_test.h"
13
14 namespace cc {
15 namespace {
16
17 static const int kTimeLimitMillis = 2000;
18 static const int kWarmupRuns = 5;
19 static const int kTimeCheckInterval = 10;
20
21 sk_sp<SkImage> CreateImage(int width, int height) {
22 SkBitmap bitmap;
23 bitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height));
24 return SkImage::MakeFromBitmap(bitmap);
25 }
26
27 SkMatrix CreateMatrix(const SkSize& scale) {
28 SkMatrix matrix;
29 matrix.setScale(scale.width(), scale.height());
30 return matrix;
31 }
32
33 class SoftwareImageDecodeCachePerfTest : public testing::Test {
34 public:
35 SoftwareImageDecodeCachePerfTest()
36 : timer_(kWarmupRuns,
37 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
38 kTimeCheckInterval) {}
39
40 void RunFromImage() {
41 SkFilterQuality qualities[] = {kNone_SkFilterQuality, kLow_SkFilterQuality,
42 kMedium_SkFilterQuality,
43 kHigh_SkFilterQuality};
44 std::pair<SkIRect, SkIRect> image_rect_subrect[] = {
45 std::make_pair(SkIRect::MakeWH(100, 100), SkIRect::MakeWH(100, 100)),
46 std::make_pair(SkIRect::MakeWH(100, 100), SkIRect::MakeWH(50, 50)),
47 std::make_pair(SkIRect::MakeWH(100, 100), SkIRect::MakeWH(1000, 1000))};
48 std::pair<float, float> scales[] = {
49 std::make_pair(1.f, 1.f), std::make_pair(0.5f, 0.5f),
50 std::make_pair(2.f, 2.f), std::make_pair(0.5f, 1.5f)};
51
52 std::vector<DrawImage> images;
53 for (auto& quality : qualities) {
54 for (auto& rect_subrect : image_rect_subrect) {
55 auto& rect = rect_subrect.first;
56 auto& subrect = rect_subrect.second;
57 for (auto& scale : scales) {
58 images.emplace_back(
59 CreateImage(rect.width(), rect.height()), subrect, quality,
60 CreateMatrix(SkSize::Make(scale.first, scale.second)));
61 }
62 }
63 }
64
65 timer_.Reset();
66 do {
67 for (auto& image : images)
68 ImageDecodeCacheKey::FromDrawImage(image);
69 timer_.NextLap();
70 } while (!timer_.HasTimeLimitExpired());
71
72 perf_test::PrintResult("software_image_decode_cache_fromdrawimage", "",
73 "result", timer_.LapsPerSecond(), "runs/s", true);
74 }
75
76 private:
77 LapTimer timer_;
78 };
79
80 TEST_F(SoftwareImageDecodeCachePerfTest, RefUnref) {
81 RunFromImage();
82 }
83
84 } // namespace
85 } // namespace cc
OLDNEW
« cc/tiles/software_image_decode_cache.cc ('K') | « cc/tiles/software_image_decode_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698