| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 class PerfTaskImpl : public Task { | 27 class PerfTaskImpl : public Task { |
| 28 public: | 28 public: |
| 29 typedef std::vector<scoped_refptr<PerfTaskImpl>> Vector; | 29 typedef std::vector<scoped_refptr<PerfTaskImpl>> Vector; |
| 30 | 30 |
| 31 PerfTaskImpl() {} | 31 PerfTaskImpl() {} |
| 32 | 32 |
| 33 // Overridden from Task: | 33 // Overridden from Task: |
| 34 void RunOnWorkerThread() override {} | 34 void RunOnWorkerThread() override {} |
| 35 | 35 |
| 36 void Reset() { did_run_ = false; } | 36 void Reset() { state().Reset(); } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 ~PerfTaskImpl() override {} | 39 ~PerfTaskImpl() override {} |
| 40 | 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(PerfTaskImpl); | 41 DISALLOW_COPY_AND_ASSIGN(PerfTaskImpl); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 class TaskGraphRunnerPerfTest : public testing::Test { | 44 class TaskGraphRunnerPerfTest : public testing::Test { |
| 45 public: | 45 public: |
| 46 TaskGraphRunnerPerfTest() | 46 TaskGraphRunnerPerfTest() |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Avoid unnecessary heap allocations by reusing the same graph and | 140 // Avoid unnecessary heap allocations by reusing the same graph and |
| 141 // completed tasks vector. | 141 // completed tasks vector. |
| 142 TaskGraph graph; | 142 TaskGraph graph; |
| 143 Task::Vector completed_tasks; | 143 Task::Vector completed_tasks; |
| 144 | 144 |
| 145 size_t count = 0; | 145 size_t count = 0; |
| 146 timer_.Reset(); | 146 timer_.Reset(); |
| 147 do { | 147 do { |
| 148 size_t current_version = count % kNumVersions; |
| 148 graph.Reset(); | 149 graph.Reset(); |
| 149 BuildTaskGraph(top_level_tasks[count % kNumVersions], | 150 // Reset tasks as we are not letting them execute, they get cancelled |
| 150 tasks[count % kNumVersions], | 151 // when next ScheduleTasks() happens. |
| 151 leaf_tasks[count % kNumVersions], | 152 ResetTasks(&top_level_tasks[current_version]); |
| 152 &graph); | 153 ResetTasks(&tasks[current_version]); |
| 154 ResetTasks(&leaf_tasks[current_version]); |
| 155 BuildTaskGraph(top_level_tasks[current_version], tasks[current_version], |
| 156 leaf_tasks[current_version], &graph); |
| 153 task_graph_runner_->ScheduleTasks(namespace_token_, &graph); | 157 task_graph_runner_->ScheduleTasks(namespace_token_, &graph); |
| 154 CollectCompletedTasks(&completed_tasks); | 158 CollectCompletedTasks(&completed_tasks); |
| 155 completed_tasks.clear(); | 159 completed_tasks.clear(); |
| 156 ++count; | 160 ++count; |
| 157 timer_.NextLap(); | 161 timer_.NextLap(); |
| 158 } while (!timer_.HasTimeLimitExpired()); | 162 } while (!timer_.HasTimeLimitExpired()); |
| 159 | 163 |
| 160 TaskGraph empty; | 164 TaskGraph empty; |
| 161 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 165 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
| 162 CollectCompletedTasks(&completed_tasks); | 166 CollectCompletedTasks(&completed_tasks); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); | 313 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); |
| 310 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); | 314 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); |
| 311 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); | 315 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); |
| 312 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); | 316 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); |
| 313 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); | 317 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); |
| 314 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); | 318 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); |
| 315 } | 319 } |
| 316 | 320 |
| 317 } // namespace | 321 } // namespace |
| 318 } // namespace cc | 322 } // namespace cc |
| OLD | NEW |