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

Unified Diff: cc/resources/picture_layer_tiling_perftest.cc

Issue 392413002: cc: Add tiling eviction iterator perftests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture_layer_tiling_perftest.cc
diff --git a/cc/resources/picture_layer_tiling_perftest.cc b/cc/resources/picture_layer_tiling_perftest.cc
index 00d991a86023f569b1bfa5ccc7f5d1d069915689..575e13e5d6984ac67394ffddd461bc2f6b165fb3 100644
--- a/cc/resources/picture_layer_tiling_perftest.cc
+++ b/cc/resources/picture_layer_tiling_perftest.cc
@@ -4,7 +4,13 @@
#include "cc/debug/lap_timer.h"
#include "cc/resources/picture_layer_tiling.h"
+#include "cc/resources/resource_provider.h"
+#include "cc/resources/scoped_resource.h"
+#include "cc/test/fake_output_surface.h"
+#include "cc/test/fake_output_surface_client.h"
#include "cc/test/fake_picture_layer_tiling_client.h"
+#include "cc/test/test_context_provider.h"
+#include "cc/test/test_shared_bitmap_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h"
@@ -22,7 +28,19 @@ class PictureLayerTilingPerfTest : public testing::Test {
PictureLayerTilingPerfTest()
: timer_(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
- kTimeCheckInterval) {}
+ kTimeCheckInterval),
+ context_provider_(TestContextProvider::Create()) {
+ output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass();
+ CHECK(output_surface_->BindToClient(&output_surface_client_));
+
+ shared_bitmap_manager_.reset(new TestSharedBitmapManager());
+ resource_provider_ = ResourceProvider::Create(output_surface_.get(),
+ shared_bitmap_manager_.get(),
+ 0,
+ false,
+ 1,
+ false).Pass();
+ }
virtual void SetUp() OVERRIDE {
picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256));
@@ -165,11 +183,105 @@ class PictureLayerTilingPerfTest : public testing::Test {
true);
}
+ void RunEvictionIteratorConstructTest(const std::string& test_name,
+ const gfx::Rect& viewport) {
+ gfx::Size bounds(viewport.size());
+ picture_layer_tiling_ =
+ PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_);
+ picture_layer_tiling_->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
+
+ timer_.Reset();
+ TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
+ SMOOTHNESS_TAKES_PRIORITY,
+ NEW_CONTENT_TAKES_PRIORITY};
+ int priority_count = 0;
+ do {
+ PictureLayerTiling::TilingEvictionTileIterator it(
+ picture_layer_tiling_.get(), priorities[priority_count]);
+ priority_count = (priority_count + 1) % arraysize(priorities);
+ timer_.NextLap();
+ } while (!timer_.HasTimeLimitExpired());
+
+ perf_test::PrintResult("tiling_eviction_tile_iterator_construct",
+ "",
+ test_name,
+ timer_.LapsPerSecond(),
+ "runs/s",
+ true);
+ }
+
+ void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name,
+ int num_tiles,
+ const gfx::Rect& viewport) {
+ gfx::Size bounds(10000, 10000);
+ picture_layer_tiling_ =
+ PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_);
+ picture_layer_tiling_->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
+
+ TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES,
+ SMOOTHNESS_TAKES_PRIORITY,
+ NEW_CONTENT_TAKES_PRIORITY};
+
+ // Ensure all tiles have resources.
+ std::vector<Tile*> all_tiles = picture_layer_tiling_->AllTilesForTesting();
+ for (std::vector<Tile*>::iterator tile_it = all_tiles.begin();
+ tile_it != all_tiles.end();
+ ++tile_it) {
+ Tile* tile = *tile_it;
+ ManagedTileState::TileVersion& tile_version =
+ tile->GetTileVersionForTesting(tile->GetRasterModeForTesting());
+ tile_version.SetResourceForTesting(
+ ScopedResource::Create(resource_provider_.get()).Pass());
+ }
+
+ int priority_count = 0;
+ timer_.Reset();
+ do {
+ int count = num_tiles;
+ PictureLayerTiling::TilingEvictionTileIterator it(
+ picture_layer_tiling_.get(), priorities[priority_count]);
+ while (count--) {
+ ASSERT_TRUE(it) << "count: " << count;
+ ASSERT_TRUE(*it != NULL) << "count: " << count;
+ ++it;
+ }
+ priority_count = (priority_count + 1) % arraysize(priorities);
+ timer_.NextLap();
+ } while (!timer_.HasTimeLimitExpired());
+
+ // Remove all resources from tiles to make sure the tile version destructor
+ // doesn't complain.
+ for (std::vector<Tile*>::iterator tile_it = all_tiles.begin();
+ tile_it != all_tiles.end();
+ ++tile_it) {
+ Tile* tile = *tile_it;
+ ManagedTileState::TileVersion& tile_version =
+ tile->GetTileVersionForTesting(tile->GetRasterModeForTesting());
+ tile_version.SetResourceForTesting(scoped_ptr<ScopedResource>());
+ }
+
+ perf_test::PrintResult(
+ "tiling_eviction_tile_iterator_construct_and_iterate",
+ "",
+ test_name,
+ timer_.LapsPerSecond(),
+ "runs/s",
+ true);
+ }
+
private:
FakePictureLayerTilingClient picture_layer_tiling_client_;
scoped_ptr<PictureLayerTiling> picture_layer_tiling_;
LapTimer timer_;
+
+ scoped_refptr<ContextProvider> context_provider_;
+ FakeOutputSurfaceClient output_surface_client_;
+ scoped_ptr<FakeOutputSurface> output_surface_;
+ scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
+ scoped_ptr<ResourceProvider> resource_provider_;
};
TEST_F(PictureLayerTilingPerfTest, Invalidate) {
@@ -222,6 +334,27 @@ TEST_F(PictureLayerTilingPerfTest,
"64_500x500", 64, gfx::Rect(0, 0, 500, 500));
}
+TEST_F(PictureLayerTilingPerfTest, TilingEvictionTileIteratorConstruct) {
+ RunEvictionIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
+ RunEvictionIteratorConstructTest("50_0_100x100", gfx::Rect(50, 0, 100, 100));
+ RunEvictionIteratorConstructTest("100_0_100x100",
+ gfx::Rect(100, 0, 100, 100));
+ RunEvictionIteratorConstructTest("150_0_100x100",
+ gfx::Rect(150, 0, 100, 100));
+}
+
+TEST_F(PictureLayerTilingPerfTest,
+ TilingEvictionTileIteratorConstructAndIterate) {
+ RunEvictionIteratorConstructAndIterateTest(
+ "32_100x100", 32, gfx::Rect(0, 0, 100, 100));
+ RunEvictionIteratorConstructAndIterateTest(
+ "32_500x500", 32, gfx::Rect(0, 0, 500, 500));
+ RunEvictionIteratorConstructAndIterateTest(
+ "64_100x100", 64, gfx::Rect(0, 0, 100, 100));
+ RunEvictionIteratorConstructAndIterateTest(
+ "64_500x500", 64, gfx::Rect(0, 0, 500, 500));
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698