| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 "cc/playback/picture_pile_impl.h" | |
| 6 | |
| 7 #include "cc/debug/lap_timer.h" | |
| 8 #include "cc/test/fake_picture_pile_impl.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 #include "testing/perf/perf_test.h" | |
| 11 | |
| 12 namespace cc { | |
| 13 namespace { | |
| 14 | |
| 15 const int kTimeLimitMillis = 2000; | |
| 16 const int kWarmupRuns = 5; | |
| 17 const int kTimeCheckInterval = 10; | |
| 18 | |
| 19 const int kTileSize = 100; | |
| 20 const int kLayerSize = 1000; | |
| 21 | |
| 22 class PicturePileImplPerfTest : public testing::Test { | |
| 23 public: | |
| 24 PicturePileImplPerfTest() | |
| 25 : timer_(kWarmupRuns, | |
| 26 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | |
| 27 kTimeCheckInterval) {} | |
| 28 | |
| 29 void RunAnalyzeTest(const std::string& test_name, float contents_scale) { | |
| 30 scoped_refptr<PicturePileImpl> pile = FakePicturePileImpl::CreateFilledPile( | |
| 31 gfx::Size(kTileSize, kTileSize), gfx::Size(kLayerSize, kLayerSize)); | |
| 32 // Content rect that will align with top-left tile at scale 1.0. | |
| 33 gfx::Rect content_rect(0, 0, kTileSize, kTileSize); | |
| 34 | |
| 35 RasterSource::SolidColorAnalysis analysis; | |
| 36 timer_.Reset(); | |
| 37 do { | |
| 38 pile->PerformSolidColorAnalysis(content_rect, contents_scale, &analysis); | |
| 39 timer_.NextLap(); | |
| 40 } while (!timer_.HasTimeLimitExpired()); | |
| 41 | |
| 42 perf_test::PrintResult( | |
| 43 "analyze", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | |
| 44 } | |
| 45 | |
| 46 void RunRasterTest(const std::string& test_name, float contents_scale) { | |
| 47 scoped_refptr<PicturePileImpl> pile = FakePicturePileImpl::CreateFilledPile( | |
| 48 gfx::Size(kTileSize, kTileSize), gfx::Size(kLayerSize, kLayerSize)); | |
| 49 // Content rect that will align with top-left tile at scale 1.0. | |
| 50 gfx::Rect content_rect(0, 0, kTileSize, kTileSize); | |
| 51 | |
| 52 SkBitmap bitmap; | |
| 53 bitmap.allocN32Pixels(1, 1); | |
| 54 SkCanvas canvas(bitmap); | |
| 55 | |
| 56 timer_.Reset(); | |
| 57 do { | |
| 58 pile->PlaybackToCanvas(&canvas, content_rect, content_rect, | |
| 59 contents_scale); | |
| 60 timer_.NextLap(); | |
| 61 } while (!timer_.HasTimeLimitExpired()); | |
| 62 | |
| 63 perf_test::PrintResult( | |
| 64 "raster", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | |
| 65 } | |
| 66 | |
| 67 private: | |
| 68 LapTimer timer_; | |
| 69 }; | |
| 70 | |
| 71 TEST_F(PicturePileImplPerfTest, Analyze) { | |
| 72 RunAnalyzeTest("1", 1.0f); | |
| 73 RunAnalyzeTest("4", 0.5f); | |
| 74 RunAnalyzeTest("100", 0.1f); | |
| 75 } | |
| 76 | |
| 77 TEST_F(PicturePileImplPerfTest, Raster) { | |
| 78 RunRasterTest("1", 1.0f); | |
| 79 RunRasterTest("4", 0.5f); | |
| 80 RunRasterTest("100", 0.1f); | |
| 81 } | |
| 82 | |
| 83 } // namespace | |
| 84 } // namespace cc | |
| OLD | NEW |