summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorloyso <loyso@chromium.org>2016-02-09 22:49:26 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-10 06:50:11 +0000
commita4a59a4a9ef7857b4c29106d155bf36edaf0918b (patch)
tree0cef2b025172617aeeeec4298ee157f0d175c201 /cc
parentd29d2b239e637e70f287a9924f2b8894f4c5d916 (diff)
downloadchromium_src-a4a59a4a9ef7857b4c29106d155bf36edaf0918b.zip
chromium_src-a4a59a4a9ef7857b4c29106d155bf36edaf0918b.tar.gz
chromium_src-a4a59a4a9ef7857b4c29106d155bf36edaf0918b.tar.bz2
CC Animation: Add perf test for AnimationHost PushPropertiesTo.
This is a fine-grained rework of https://codereview.chromium.org/1679923004/ The diff: 1) We test more general AnimationHost::PushPropertiesTo 2) We spawn unique layer for each player instead of using just one root layer. BUG=574859 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1680373004 Cr-Commit-Position: refs/heads/master@{#374613}
Diffstat (limited to 'cc')
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/animation/animation_host_perftest.cc115
-rw-r--r--cc/cc_tests.gyp1
3 files changed, 117 insertions, 0 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 9e6b3e6..70f28d2 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -945,6 +945,7 @@ test("cc_unittests") {
test("cc_perftests") {
sources = [
+ "animation/animation_host_perftest.cc",
"layers/layer_perftest.cc",
"layers/picture_layer_impl_perftest.cc",
"quads/draw_quad_perftest.cc",
diff --git a/cc/animation/animation_host_perftest.cc b/cc/animation/animation_host_perftest.cc
new file mode 100644
index 0000000..3e1d184
--- /dev/null
+++ b/cc/animation/animation_host_perftest.cc
@@ -0,0 +1,115 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/animation/animation_host.h"
+
+#include "base/thread_task_runner_handle.h"
+#include "cc/animation/animation_id_provider.h"
+#include "cc/animation/animation_player.h"
+#include "cc/animation/animation_timeline.h"
+#include "cc/debug/lap_timer.h"
+#include "cc/layers/layer.h"
+#include "cc/layers/layer_settings.h"
+#include "cc/test/fake_impl_task_runner_provider.h"
+#include "cc/test/fake_layer_tree_host.h"
+#include "cc/test/fake_layer_tree_host_client.h"
+#include "cc/test/fake_layer_tree_host_impl.h"
+#include "cc/test/test_task_graph_runner.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/perf/perf_test.h"
+
+namespace cc {
+
+static const int kNumberOfAnimationPlayers = 1000;
+
+class AnimationHostPerfTest : public testing::Test {
+ public:
+ AnimationHostPerfTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
+
+ protected:
+ void SetUp() override {
+ LayerTreeSettings settings;
+ settings.use_compositor_animation_timelines = true;
+
+ layer_tree_host_ =
+ FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, settings);
+ layer_tree_host_->InitializeSingleThreaded(
+ &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr);
+ }
+
+ void TearDown() override {
+ layer_tree_host_->SetRootLayer(nullptr);
+ layer_tree_host_ = nullptr;
+ }
+
+ LayerSettings GetLayerSettings() const {
+ DCHECK(layer_tree_host_);
+
+ LayerSettings settings;
+ settings.use_compositor_animation_timelines =
+ layer_tree_host_->settings().use_compositor_animation_timelines;
+ return settings;
+ }
+
+ scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
+ LapTimer timer_;
+
+ TestTaskGraphRunner task_graph_runner_;
+ FakeLayerTreeHostClient fake_client_;
+};
+
+TEST_F(AnimationHostPerfTest, PushPropertiesTo) {
+ if (!layer_tree_host_->settings().use_compositor_animation_timelines)
+ return;
+
+ AnimationHost* host = layer_tree_host_->animation_host();
+ AnimationHost* host_impl = layer_tree_host_->host_impl()->animation_host();
+
+ scoped_refptr<Layer> root_layer = Layer::Create(GetLayerSettings());
+ layer_tree_host_->SetRootLayer(root_layer);
+
+ scoped_ptr<LayerImpl> root_layer_impl = LayerImpl::Create(
+ layer_tree_host_->host_impl()->active_tree(), root_layer->id());
+
+ scoped_refptr<AnimationTimeline> timeline =
+ AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
+ host->AddAnimationTimeline(timeline);
+
+ scoped_refptr<AnimationTimeline> timeline_impl =
+ timeline->CreateImplInstance();
+ host_impl->AddAnimationTimeline(timeline_impl);
+
+ for (int i = 0; i < kNumberOfAnimationPlayers; ++i) {
+ scoped_refptr<Layer> layer = Layer::Create(GetLayerSettings());
+ root_layer->AddChild(layer);
+
+ const int layer_id = layer->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));
+
+ scoped_refptr<AnimationPlayer> player =
+ AnimationPlayer::Create(AnimationIdProvider::NextPlayerId());
+ timeline->AttachPlayer(player);
+ player->AttachLayer(layer_id);
+ EXPECT_TRUE(player->element_animations());
+
+ scoped_refptr<AnimationPlayer> impl_player = player->CreateImplInstance();
+ timeline_impl->AttachPlayer(impl_player);
+ impl_player->AttachLayer(layer_id);
+ EXPECT_TRUE(impl_player->element_animations());
+ }
+
+ timer_.Reset();
+ do {
+ host->PushPropertiesTo(host_impl);
+ timer_.NextLap();
+ } while (!timer_.HasTimeLimitExpired());
+
+ perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(),
+ "runs/s", true);
+}
+
+} // namespace cc
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 7a11fd3..d9fe4b1 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -373,6 +373,7 @@
],
'sources': [
# Note: sources list duplicated in GN build.
+ 'animation/animation_host_perftest.cc',
'layers/layer_perftest.cc',
'layers/picture_layer_impl_perftest.cc',
'quads/draw_quad_perftest.cc',