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

Unified Diff: cc/animation/animation_host_perftest.cc

Issue 1823773003: CC Animation: Add perf tests for AnimationHost with AnimationTimelines (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rework. Created 4 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
« no previous file with comments | « no previous file | cc/test/fake_layer_tree_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/animation_host_perftest.cc
diff --git a/cc/animation/animation_host_perftest.cc b/cc/animation/animation_host_perftest.cc
index bd3cdeb5a1f1581c56624c3982f7282e6cc9d27f..bd183ed243d273431ef5ee28f9bcefadc3a4167e 100644
--- a/cc/animation/animation_host_perftest.cc
+++ b/cc/animation/animation_host_perftest.cc
@@ -20,8 +20,6 @@
namespace cc {
-static const int kNumberOfAnimationPlayers = 1000;
-
class AnimationHostPerfTest : public testing::Test {
public:
AnimationHostPerfTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
@@ -33,68 +31,111 @@ class AnimationHostPerfTest : public testing::Test {
FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, settings);
layer_tree_host_->InitializeSingleThreaded(
&fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr);
+
+ root_layer_ = Layer::Create();
+ layer_tree_host_->SetRootLayer(root_layer_);
+
+ root_layer_impl_ = layer_tree_host_->CommitAndCreateLayerImplTree();
}
void TearDown() override {
+ root_layer_ = nullptr;
+ root_layer_impl_ = nullptr;
+
layer_tree_host_->SetRootLayer(nullptr);
layer_tree_host_ = nullptr;
}
- scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
- LapTimer timer_;
+ AnimationHost* host() const { return layer_tree_host_->animation_host(); }
+ AnimationHost* host_impl() const {
+ return layer_tree_host_->host_impl()->animation_host();
+ }
- TestTaskGraphRunner task_graph_runner_;
- FakeLayerTreeHostClient fake_client_;
-};
+ void CreatePlayers(const int num_players) {
+ scoped_refptr<AnimationTimeline> timeline =
+ AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
+ host()->AddAnimationTimeline(timeline);
-TEST_F(AnimationHostPerfTest, PushPropertiesTo) {
- AnimationHost* host = layer_tree_host_->animation_host();
- AnimationHost* host_impl = layer_tree_host_->host_impl()->animation_host();
+ const int first_player_id = AnimationIdProvider::NextPlayerId();
+ int last_player_id = first_player_id;
- scoped_refptr<Layer> root_layer = Layer::Create();
- layer_tree_host_->SetRootLayer(root_layer);
+ for (int i = 0; i < num_players; ++i) {
+ scoped_refptr<Layer> layer = Layer::Create();
+ root_layer_->AddChild(layer);
- scoped_ptr<LayerImpl> root_layer_impl = LayerImpl::Create(
- layer_tree_host_->host_impl()->active_tree(), root_layer->id());
+ scoped_refptr<AnimationPlayer> player =
+ AnimationPlayer::Create(last_player_id);
+ last_player_id = AnimationIdProvider::NextPlayerId();
- scoped_refptr<AnimationTimeline> timeline =
- AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
- host->AddAnimationTimeline(timeline);
+ timeline->AttachPlayer(player);
+ player->AttachLayer(layer->id());
+ EXPECT_TRUE(player->element_animations());
+ }
- scoped_refptr<AnimationTimeline> timeline_impl =
- timeline->CreateImplInstance();
- host_impl->AddAnimationTimeline(timeline_impl);
+ // Create impl players.
+ layer_tree_host_->CommitAndCreateLayerImplTree();
- for (int i = 0; i < kNumberOfAnimationPlayers; ++i) {
- scoped_refptr<Layer> layer = Layer::Create();
- root_layer->AddChild(layer);
+ // Check impl instances created.
+ scoped_refptr<AnimationTimeline> timeline_impl =
+ host_impl()->GetTimelineById(timeline->id());
+ EXPECT_TRUE(timeline_impl);
+ for (int i = first_player_id; i < last_player_id; ++i)
+ EXPECT_TRUE(timeline_impl->GetPlayerById(i));
+ }
- const int layer_id = layer->id();
+ void CreateTimelines(const int num_timelines) {
+ const int first_timeline_id = AnimationIdProvider::NextTimelineId();
+ int last_timeline_id = first_timeline_id;
- scoped_ptr<LayerImpl> layer_impl = LayerImpl::Create(
- layer_tree_host_->host_impl()->active_tree(), layer_id);
- root_layer_impl->AddChild(std::move(layer_impl));
+ for (int i = 0; i < num_timelines; ++i) {
+ scoped_refptr<AnimationTimeline> timeline =
+ AnimationTimeline::Create(last_timeline_id);
+ last_timeline_id = AnimationIdProvider::NextTimelineId();
+ host()->AddAnimationTimeline(timeline);
+ }
- scoped_refptr<AnimationPlayer> player =
- AnimationPlayer::Create(AnimationIdProvider::NextPlayerId());
- timeline->AttachPlayer(player);
- player->AttachLayer(layer_id);
- EXPECT_TRUE(player->element_animations());
+ // Create impl timelines.
+ layer_tree_host_->CommitAndCreateLayerImplTree();
- scoped_refptr<AnimationPlayer> impl_player = player->CreateImplInstance();
- timeline_impl->AttachPlayer(impl_player);
- impl_player->AttachLayer(layer_id);
- EXPECT_TRUE(impl_player->element_animations());
+ // Check impl instances created.
+ for (int i = first_timeline_id; i < last_timeline_id; ++i)
+ EXPECT_TRUE(host_impl()->GetTimelineById(i));
}
- timer_.Reset();
- do {
- host->PushPropertiesTo(host_impl);
- timer_.NextLap();
- } while (!timer_.HasTimeLimitExpired());
+ void DoTest() {
+ timer_.Reset();
+ do {
+ host()->PushPropertiesTo(host_impl());
+ timer_.NextLap();
+ } while (!timer_.HasTimeLimitExpired());
+
+ perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(),
+ "runs/s", true);
+ }
+
+ protected:
+ scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
+ scoped_refptr<Layer> root_layer_;
+ LayerImpl* root_layer_impl_;
+
+ LapTimer timer_;
+ TestTaskGraphRunner task_graph_runner_;
+ FakeLayerTreeHostClient fake_client_;
+};
+
+TEST_F(AnimationHostPerfTest, Push1000PlayersPropertiesTo) {
+ CreatePlayers(1000);
+ DoTest();
+}
+
+TEST_F(AnimationHostPerfTest, Push10TimelinesPropertiesTo) {
+ CreateTimelines(10);
+ DoTest();
+}
- perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(),
- "runs/s", true);
+TEST_F(AnimationHostPerfTest, Push1000TimelinesPropertiesTo) {
+ CreateTimelines(1000);
+ DoTest();
}
} // namespace cc
« no previous file with comments | « no previous file | cc/test/fake_layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698