Chromium Code Reviews| 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/resources/task_graph_runner.h" | 5 #include "cc/resources/task_graph_runner.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "cc/base/completion_event.h" | 10 #include "cc/base/completion_event.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 internal::TaskGraph graph; | 73 internal::TaskGraph graph; |
| 74 | 74 |
| 75 timer_.Reset(); | 75 timer_.Reset(); |
| 76 do { | 76 do { |
| 77 graph.Reset(); | 77 graph.Reset(); |
| 78 BuildTaskGraph(top_level_tasks, tasks, leaf_tasks, &graph); | 78 BuildTaskGraph(top_level_tasks, tasks, leaf_tasks, &graph); |
| 79 timer_.NextLap(); | 79 timer_.NextLap(); |
| 80 } while (!timer_.HasTimeLimitExpired()); | 80 } while (!timer_.HasTimeLimitExpired()); |
| 81 | 81 |
| 82 perf_test::PrintResult("build_task_graph", | 82 perf_test::PrintResult("build_task_graph", |
| 83 "", | 83 TestModifierString(), |
| 84 test_name, | 84 test_name, |
| 85 timer_.LapsPerSecond(), | 85 timer_.LapsPerSecond(), |
| 86 "runs/s", | 86 "runs/s", |
| 87 true); | 87 true); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void RunScheduleTasksTest(const std::string& test_name, | 90 void RunScheduleTasksTest(const std::string& test_name, |
| 91 int num_top_level_tasks, | 91 int num_top_level_tasks, |
| 92 int num_tasks, | 92 int num_tasks, |
| 93 int num_leaf_tasks) { | 93 int num_leaf_tasks) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 112 // of tasks. | 112 // of tasks. |
| 113 DCHECK_EQ(0u, CollectCompletedTasks(&completed_tasks)); | 113 DCHECK_EQ(0u, CollectCompletedTasks(&completed_tasks)); |
| 114 timer_.NextLap(); | 114 timer_.NextLap(); |
| 115 } while (!timer_.HasTimeLimitExpired()); | 115 } while (!timer_.HasTimeLimitExpired()); |
| 116 | 116 |
| 117 internal::TaskGraph empty; | 117 internal::TaskGraph empty; |
| 118 task_graph_runner_->SetTaskGraph(namespace_token_, &empty); | 118 task_graph_runner_->SetTaskGraph(namespace_token_, &empty); |
| 119 CollectCompletedTasks(&completed_tasks); | 119 CollectCompletedTasks(&completed_tasks); |
| 120 | 120 |
| 121 perf_test::PrintResult("schedule_tasks", | 121 perf_test::PrintResult("schedule_tasks", |
| 122 "", | 122 TestModifierString(), |
| 123 test_name, | 123 test_name, |
| 124 timer_.LapsPerSecond(), | 124 timer_.LapsPerSecond(), |
| 125 "runs/s", | 125 "runs/s", |
| 126 true); | 126 true); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void RunScheduleAlternateTasksTest(const std::string& test_name, | 129 void RunScheduleAlternateTasksTest(const std::string& test_name, |
| 130 int num_top_level_tasks, | 130 int num_top_level_tasks, |
| 131 int num_tasks, | 131 int num_tasks, |
| 132 int num_leaf_tasks) { | 132 int num_leaf_tasks) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 158 completed_tasks.clear(); | 158 completed_tasks.clear(); |
| 159 ++count; | 159 ++count; |
| 160 timer_.NextLap(); | 160 timer_.NextLap(); |
| 161 } while (!timer_.HasTimeLimitExpired()); | 161 } while (!timer_.HasTimeLimitExpired()); |
| 162 | 162 |
| 163 internal::TaskGraph empty; | 163 internal::TaskGraph empty; |
| 164 task_graph_runner_->SetTaskGraph(namespace_token_, &empty); | 164 task_graph_runner_->SetTaskGraph(namespace_token_, &empty); |
| 165 CollectCompletedTasks(&completed_tasks); | 165 CollectCompletedTasks(&completed_tasks); |
| 166 | 166 |
| 167 perf_test::PrintResult("schedule_alternate_tasks", | 167 perf_test::PrintResult("schedule_alternate_tasks", |
| 168 "", | 168 TestModifierString(), |
| 169 test_name, | 169 test_name, |
| 170 timer_.LapsPerSecond(), | 170 timer_.LapsPerSecond(), |
| 171 "runs/s", | 171 "runs/s", |
| 172 true); | 172 true); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void RunScheduleAndExecuteTasksTest(const std::string& test_name, | 175 void RunScheduleAndExecuteTasksTest(const std::string& test_name, |
| 176 int num_top_level_tasks, | 176 int num_top_level_tasks, |
| 177 int num_tasks, | 177 int num_tasks, |
| 178 int num_leaf_tasks) { | 178 int num_leaf_tasks) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 196 while (task_graph_runner_->RunTaskForTesting()) | 196 while (task_graph_runner_->RunTaskForTesting()) |
| 197 continue; | 197 continue; |
| 198 CollectCompletedTasks(&completed_tasks); | 198 CollectCompletedTasks(&completed_tasks); |
| 199 completed_tasks.clear(); | 199 completed_tasks.clear(); |
| 200 ResetTasks(&top_level_tasks); | 200 ResetTasks(&top_level_tasks); |
| 201 ResetTasks(&tasks); | 201 ResetTasks(&tasks); |
| 202 ResetTasks(&leaf_tasks); | 202 ResetTasks(&leaf_tasks); |
| 203 timer_.NextLap(); | 203 timer_.NextLap(); |
| 204 } while (!timer_.HasTimeLimitExpired()); | 204 } while (!timer_.HasTimeLimitExpired()); |
| 205 | 205 |
| 206 perf_test::PrintResult( | 206 perf_test::PrintResult("execute_tasks", |
| 207 "execute_tasks", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | 207 TestModifierString(), |
| 208 test_name, | |
| 209 timer_.LapsPerSecond(), | |
| 210 "runs/s", | |
| 211 true); | |
| 208 } | 212 } |
| 209 | 213 |
| 210 private: | 214 private: |
| 215 static std::string TestModifierString() { | |
| 216 return std::string("_task_graph_runner"); | |
| 217 } | |
|
reveman
2014/02/14 23:40:16
nit: blank line after function
alokp
2014/02/15 00:26:11
Done.
| |
| 211 void CreateTasks(int num_tasks, PerfTaskImpl::Vector* tasks) { | 218 void CreateTasks(int num_tasks, PerfTaskImpl::Vector* tasks) { |
| 212 for (int i = 0; i < num_tasks; ++i) | 219 for (int i = 0; i < num_tasks; ++i) |
| 213 tasks->push_back(make_scoped_refptr(new PerfTaskImpl)); | 220 tasks->push_back(make_scoped_refptr(new PerfTaskImpl)); |
| 214 } | 221 } |
| 215 | 222 |
| 216 void ResetTasks(PerfTaskImpl::Vector* tasks) { | 223 void ResetTasks(PerfTaskImpl::Vector* tasks) { |
| 217 for (PerfTaskImpl::Vector::iterator it = tasks->begin(); it != tasks->end(); | 224 for (PerfTaskImpl::Vector::iterator it = tasks->begin(); it != tasks->end(); |
| 218 ++it) { | 225 ++it) { |
| 219 PerfTaskImpl* task = it->get(); | 226 PerfTaskImpl* task = it->get(); |
| 220 task->Reset(); | 227 task->Reset(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); | 314 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); |
| 308 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); | 315 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); |
| 309 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); | 316 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); |
| 310 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); | 317 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); |
| 311 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); | 318 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); |
| 312 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); | 319 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); |
| 313 } | 320 } |
| 314 | 321 |
| 315 } // namespace | 322 } // namespace |
| 316 } // namespace cc | 323 } // namespace cc |
| OLD | NEW |