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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/animation_host.h" 5 #include "cc/animation/animation_host.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/animation/animation_id_provider.h" 8 #include "cc/animation/animation_id_provider.h"
9 #include "cc/animation/animation_player.h" 9 #include "cc/animation/animation_player.h"
10 #include "cc/animation/animation_timeline.h" 10 #include "cc/animation/animation_timeline.h"
11 #include "cc/debug/lap_timer.h" 11 #include "cc/debug/lap_timer.h"
12 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
13 #include "cc/test/fake_impl_task_runner_provider.h" 13 #include "cc/test/fake_impl_task_runner_provider.h"
14 #include "cc/test/fake_layer_tree_host.h" 14 #include "cc/test/fake_layer_tree_host.h"
15 #include "cc/test/fake_layer_tree_host_client.h" 15 #include "cc/test/fake_layer_tree_host_client.h"
16 #include "cc/test/fake_layer_tree_host_impl.h" 16 #include "cc/test/fake_layer_tree_host_impl.h"
17 #include "cc/test/test_task_graph_runner.h" 17 #include "cc/test/test_task_graph_runner.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "testing/perf/perf_test.h" 19 #include "testing/perf/perf_test.h"
20 20
21 namespace cc { 21 namespace cc {
22 22
23 static const int kNumberOfAnimationPlayers = 1000;
24
25 class AnimationHostPerfTest : public testing::Test { 23 class AnimationHostPerfTest : public testing::Test {
26 public: 24 public:
27 AnimationHostPerfTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} 25 AnimationHostPerfTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
28 26
29 protected: 27 protected:
30 void SetUp() override { 28 void SetUp() override {
31 LayerTreeSettings settings; 29 LayerTreeSettings settings;
32 layer_tree_host_ = 30 layer_tree_host_ =
33 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, settings); 31 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, settings);
34 layer_tree_host_->InitializeSingleThreaded( 32 layer_tree_host_->InitializeSingleThreaded(
35 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); 33 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr);
36 } 34 }
37 35
38 void TearDown() override { 36 void TearDown() override {
39 layer_tree_host_->SetRootLayer(nullptr); 37 layer_tree_host_->SetRootLayer(nullptr);
40 layer_tree_host_ = nullptr; 38 layer_tree_host_ = nullptr;
41 } 39 }
42 40
43 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; 41 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
44 LapTimer timer_; 42 LapTimer timer_;
45 43
46 TestTaskGraphRunner task_graph_runner_; 44 TestTaskGraphRunner task_graph_runner_;
47 FakeLayerTreeHostClient fake_client_; 45 FakeLayerTreeHostClient fake_client_;
48 }; 46 };
49 47
50 TEST_F(AnimationHostPerfTest, PushPropertiesTo) { 48 TEST_F(AnimationHostPerfTest, PushPlayersPropertiesTo) {
49 static const int kNumberOfAnimationPlayers = 1000;
50
51 AnimationHost* host = layer_tree_host_->animation_host(); 51 AnimationHost* host = layer_tree_host_->animation_host();
52 AnimationHost* host_impl = layer_tree_host_->host_impl()->animation_host(); 52 AnimationHost* host_impl = layer_tree_host_->host_impl()->animation_host();
53 53
54 scoped_refptr<Layer> root_layer = Layer::Create(); 54 scoped_refptr<Layer> root_layer = Layer::Create();
55 layer_tree_host_->SetRootLayer(root_layer); 55 layer_tree_host_->SetRootLayer(root_layer);
56 56
57 scoped_ptr<LayerImpl> root_layer_impl = LayerImpl::Create( 57 scoped_ptr<LayerImpl> root_layer_impl = LayerImpl::Create(
58 layer_tree_host_->host_impl()->active_tree(), root_layer->id()); 58 layer_tree_host_->host_impl()->active_tree(), root_layer->id());
59 59
60 scoped_refptr<AnimationTimeline> timeline = 60 scoped_refptr<AnimationTimeline> timeline =
(...skipping 29 matching lines...) Expand all
90 timer_.Reset(); 90 timer_.Reset();
91 do { 91 do {
92 host->PushPropertiesTo(host_impl); 92 host->PushPropertiesTo(host_impl);
93 timer_.NextLap(); 93 timer_.NextLap();
94 } while (!timer_.HasTimeLimitExpired()); 94 } while (!timer_.HasTimeLimitExpired());
95 95
96 perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(), 96 perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(),
97 "runs/s", true); 97 "runs/s", true);
98 } 98 }
99 99
100 TEST_F(AnimationHostPerfTest, PushSeveralTimelinesPropertiesTo) {
101 static const int kNumberOfAnimationTimelines = 10;
102
103 AnimationHost* host = layer_tree_host_->animation_host();
104 AnimationHost* host_impl = layer_tree_host_->host_impl()->animation_host();
105
106 for (int i = 0; i < kNumberOfAnimationTimelines; ++i) {
107 scoped_refptr<AnimationTimeline> timeline =
108 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
109 host->AddAnimationTimeline(timeline);
110
111 scoped_refptr<AnimationTimeline> timeline_impl =
112 timeline->CreateImplInstance();
113 host_impl->AddAnimationTimeline(timeline_impl);
114 }
115
116 timer_.Reset();
117 do {
118 host->PushPropertiesTo(host_impl);
119 timer_.NextLap();
120 } while (!timer_.HasTimeLimitExpired());
121
122 perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(),
123 "runs/s", true);
124 }
125
126 TEST_F(AnimationHostPerfTest, PushManyTimelinesPropertiesTo) {
127 static const int kNumberOfAnimationTimelines = 1000;
128
129 AnimationHost* host = layer_tree_host_->animation_host();
130 AnimationHost* host_impl = layer_tree_host_->host_impl()->animation_host();
131
132 for (int i = 0; i < kNumberOfAnimationTimelines; ++i) {
133 scoped_refptr<AnimationTimeline> timeline =
134 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
135 host->AddAnimationTimeline(timeline);
136
137 scoped_refptr<AnimationTimeline> timeline_impl =
138 timeline->CreateImplInstance();
139 host_impl->AddAnimationTimeline(timeline_impl);
140 }
141
142 timer_.Reset();
143 do {
144 host->PushPropertiesTo(host_impl);
145 timer_.NextLap();
146 } while (!timer_.HasTimeLimitExpired());
147
148 perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(),
149 "runs/s", true);
ajuma 2016/03/22 13:28:27 A couple nits: 1) These two tests have the same lo
150 }
151
100 } // namespace cc 152 } // namespace cc
OLDNEW
« 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