| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/raster/task_graph_runner.h" | |
| 6 | |
| 7 #include <vector> | 5 #include <vector> |
| 8 | 6 |
| 9 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 11 #include "cc/base/completion_event.h" | 9 #include "cc/base/completion_event.h" |
| 12 #include "cc/debug/lap_timer.h" | 10 #include "cc/debug/lap_timer.h" |
| 11 #include "cc/raster/synchronous_task_graph_runner.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "testing/perf/perf_test.h" | 13 #include "testing/perf/perf_test.h" |
| 15 | 14 |
| 16 namespace cc { | 15 namespace cc { |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 static const int kTimeLimitMillis = 2000; | 18 static const int kTimeLimitMillis = 2000; |
| 20 static const int kWarmupRuns = 5; | 19 static const int kWarmupRuns = 5; |
| 21 static const int kTimeCheckInterval = 10; | 20 static const int kTimeCheckInterval = 10; |
| 22 | 21 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 | 38 |
| 40 class TaskGraphRunnerPerfTest : public testing::Test { | 39 class TaskGraphRunnerPerfTest : public testing::Test { |
| 41 public: | 40 public: |
| 42 TaskGraphRunnerPerfTest() | 41 TaskGraphRunnerPerfTest() |
| 43 : timer_(kWarmupRuns, | 42 : timer_(kWarmupRuns, |
| 44 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 43 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 45 kTimeCheckInterval) {} | 44 kTimeCheckInterval) {} |
| 46 | 45 |
| 47 // Overridden from testing::Test: | 46 // Overridden from testing::Test: |
| 48 void SetUp() override { | 47 void SetUp() override { |
| 49 task_graph_runner_ = make_scoped_ptr(new TaskGraphRunner); | 48 task_graph_runner_ = make_scoped_ptr(new SynchronousTaskGraphRunner); |
| 50 namespace_token_ = task_graph_runner_->GetNamespaceToken(); | 49 namespace_token_ = task_graph_runner_->GetNamespaceToken(); |
| 51 } | 50 } |
| 52 void TearDown() override { task_graph_runner_ = nullptr; } | 51 void TearDown() override { task_graph_runner_ = nullptr; } |
| 53 | 52 |
| 54 void RunBuildTaskGraphTest(const std::string& test_name, | 53 void RunBuildTaskGraphTest(const std::string& test_name, |
| 55 int num_top_level_tasks, | 54 int num_top_level_tasks, |
| 56 int num_tasks, | 55 int num_tasks, |
| 57 int num_leaf_tasks) { | 56 int num_leaf_tasks) { |
| 58 PerfTaskImpl::Vector top_level_tasks; | 57 PerfTaskImpl::Vector top_level_tasks; |
| 59 PerfTaskImpl::Vector tasks; | 58 PerfTaskImpl::Vector tasks; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 259 } |
| 261 } | 260 } |
| 262 | 261 |
| 263 size_t CollectCompletedTasks(Task::Vector* completed_tasks) { | 262 size_t CollectCompletedTasks(Task::Vector* completed_tasks) { |
| 264 DCHECK(completed_tasks->empty()); | 263 DCHECK(completed_tasks->empty()); |
| 265 task_graph_runner_->CollectCompletedTasks(namespace_token_, | 264 task_graph_runner_->CollectCompletedTasks(namespace_token_, |
| 266 completed_tasks); | 265 completed_tasks); |
| 267 return completed_tasks->size(); | 266 return completed_tasks->size(); |
| 268 } | 267 } |
| 269 | 268 |
| 270 scoped_ptr<TaskGraphRunner> task_graph_runner_; | 269 // Test uses SynchronousTaskGraphRunner, as this implementation introduces |
| 270 // minimal additional complexity over the TaskGraphWorkQueue helpers. |
| 271 scoped_ptr<SynchronousTaskGraphRunner> task_graph_runner_; |
| 271 NamespaceToken namespace_token_; | 272 NamespaceToken namespace_token_; |
| 272 LapTimer timer_; | 273 LapTimer timer_; |
| 273 }; | 274 }; |
| 274 | 275 |
| 275 TEST_F(TaskGraphRunnerPerfTest, BuildTaskGraph) { | 276 TEST_F(TaskGraphRunnerPerfTest, BuildTaskGraph) { |
| 276 RunBuildTaskGraphTest("0_1_0", 0, 1, 0); | 277 RunBuildTaskGraphTest("0_1_0", 0, 1, 0); |
| 277 RunBuildTaskGraphTest("0_32_0", 0, 32, 0); | 278 RunBuildTaskGraphTest("0_32_0", 0, 32, 0); |
| 278 RunBuildTaskGraphTest("2_1_0", 2, 1, 0); | 279 RunBuildTaskGraphTest("2_1_0", 2, 1, 0); |
| 279 RunBuildTaskGraphTest("2_32_0", 2, 32, 0); | 280 RunBuildTaskGraphTest("2_32_0", 2, 32, 0); |
| 280 RunBuildTaskGraphTest("2_1_1", 2, 1, 1); | 281 RunBuildTaskGraphTest("2_1_1", 2, 1, 1); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 303 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); | 304 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); |
| 304 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); | 305 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); |
| 305 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); | 306 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); |
| 306 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); | 307 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); |
| 307 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); | 308 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); |
| 308 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); | 309 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); |
| 309 } | 310 } |
| 310 | 311 |
| 311 } // namespace | 312 } // namespace |
| 312 } // namespace cc | 313 } // namespace cc |
| OLD | NEW |