| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "cc/debug/lap_timer.h" | 8 #include "cc/debug/lap_timer.h" |
| 9 #include "cc/test/fake_impl_task_runner_provider.h" | 9 #include "cc/test/fake_impl_task_runner_provider.h" |
| 10 #include "cc/test/fake_layer_tree_host.h" | 10 #include "cc/test/fake_layer_tree_host.h" |
| 11 #include "cc/test/fake_layer_tree_host_client.h" | 11 #include "cc/test/fake_layer_tree_host_client.h" |
| 12 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" |
| 13 #include "cc/test/stub_layer_tree_host_single_thread_client.h" |
| 13 #include "cc/test/test_task_graph_runner.h" | 14 #include "cc/test/test_task_graph_runner.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "testing/perf/perf_test.h" | 16 #include "testing/perf/perf_test.h" |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 static const int kTimeLimitMillis = 3000; | 21 static const int kTimeLimitMillis = 3000; |
| 21 static const int kWarmupRuns = 5; | 22 static const int kWarmupRuns = 5; |
| 22 static const int kTimeCheckInterval = 10; | 23 static const int kTimeCheckInterval = 10; |
| 23 | 24 |
| 24 class LayerPerfTest : public testing::Test { | 25 class LayerPerfTest : public testing::Test { |
| 25 public: | 26 public: |
| 26 LayerPerfTest() | 27 LayerPerfTest() |
| 27 : host_impl_(&task_runner_provider_, | 28 : host_impl_(&task_runner_provider_, |
| 28 &shared_bitmap_manager_, | 29 &shared_bitmap_manager_, |
| 29 &task_graph_runner_), | 30 &task_graph_runner_), |
| 30 timer_(kWarmupRuns, | 31 timer_(kWarmupRuns, |
| 31 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 32 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 32 kTimeCheckInterval) {} | 33 kTimeCheckInterval) {} |
| 33 | 34 |
| 34 protected: | 35 protected: |
| 35 void SetUp() override { | 36 void SetUp() override { |
| 36 layer_tree_host_ = | 37 layer_tree_host_ = |
| 37 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); | 38 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); |
| 38 layer_tree_host_->InitializeSingleThreaded( | 39 layer_tree_host_->InitializeSingleThreaded( |
| 39 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); | 40 &single_thread_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void TearDown() override { | 43 void TearDown() override { |
| 43 layer_tree_host_->SetRootLayer(nullptr); | 44 layer_tree_host_->SetRootLayer(nullptr); |
| 44 layer_tree_host_ = nullptr; | 45 layer_tree_host_ = nullptr; |
| 45 } | 46 } |
| 46 | 47 |
| 47 FakeImplTaskRunnerProvider task_runner_provider_; | 48 FakeImplTaskRunnerProvider task_runner_provider_; |
| 48 TestSharedBitmapManager shared_bitmap_manager_; | 49 TestSharedBitmapManager shared_bitmap_manager_; |
| 49 TestTaskGraphRunner task_graph_runner_; | 50 TestTaskGraphRunner task_graph_runner_; |
| 50 FakeLayerTreeHostImpl host_impl_; | 51 FakeLayerTreeHostImpl host_impl_; |
| 51 | 52 |
| 53 StubLayerTreeHostSingleThreadClient single_thread_client_; |
| 52 FakeLayerTreeHostClient fake_client_; | 54 FakeLayerTreeHostClient fake_client_; |
| 53 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; | 55 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
| 54 LapTimer timer_; | 56 LapTimer timer_; |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 TEST_F(LayerPerfTest, PushPropertiesTo) { | 59 TEST_F(LayerPerfTest, PushPropertiesTo) { |
| 58 scoped_refptr<Layer> test_layer = Layer::Create(); | 60 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 59 std::unique_ptr<LayerImpl> impl_layer = | 61 std::unique_ptr<LayerImpl> impl_layer = |
| 60 LayerImpl::Create(host_impl_.active_tree(), 1); | 62 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 61 | 63 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 test_layer->PushPropertiesTo(impl_layer.get()); | 158 test_layer->PushPropertiesTo(impl_layer.get()); |
| 157 timer_.NextLap(); | 159 timer_.NextLap(); |
| 158 } while (!timer_.HasTimeLimitExpired()); | 160 } while (!timer_.HasTimeLimitExpired()); |
| 159 | 161 |
| 160 perf_test::PrintResult("impl_push_properties_to", "", "props_didnt_change", | 162 perf_test::PrintResult("impl_push_properties_to", "", "props_didnt_change", |
| 161 timer_.LapsPerSecond(), "runs/s", true); | 163 timer_.LapsPerSecond(), "runs/s", true); |
| 162 } | 164 } |
| 163 | 165 |
| 164 } // namespace | 166 } // namespace |
| 165 } // namespace cc | 167 } // namespace cc |
| OLD | NEW |