OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/scheduler/task_queue_manager.h" | 5 #include "content/renderer/scheduler/task_queue_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "content/renderer/scheduler/renderer_scheduler_message_loop_delegate.h" |
9 #include "content/renderer/scheduler/task_queue_selector.h" | 10 #include "content/renderer/scheduler/task_queue_selector.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "testing/perf/perf_test.h" | 12 #include "testing/perf/perf_test.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 class SelectorForTest : public TaskQueueSelector { | 18 class SelectorForTest : public TaskQueueSelector { |
18 public: | 19 public: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 max_tasks_in_flight_(0), | 59 max_tasks_in_flight_(0), |
59 num_tasks_in_flight_(0), | 60 num_tasks_in_flight_(0), |
60 num_tasks_to_post_(0), | 61 num_tasks_to_post_(0), |
61 num_tasks_to_run_(0) {} | 62 num_tasks_to_run_(0) {} |
62 | 63 |
63 void Initialize(size_t num_queues) { | 64 void Initialize(size_t num_queues) { |
64 num_queues_ = num_queues; | 65 num_queues_ = num_queues; |
65 message_loop_.reset(new base::MessageLoop()); | 66 message_loop_.reset(new base::MessageLoop()); |
66 selector_ = make_scoped_ptr(new SelectorForTest); | 67 selector_ = make_scoped_ptr(new SelectorForTest); |
67 manager_ = make_scoped_ptr(new TaskQueueManager( | 68 manager_ = make_scoped_ptr(new TaskQueueManager( |
68 num_queues, message_loop_->task_runner(), selector_.get())); | 69 num_queues, |
| 70 RendererSchedulerMessageLoopDelegate::Create(message_loop_.get()), |
| 71 selector_.get())); |
69 } | 72 } |
70 | 73 |
71 void TestDelayedTask() { | 74 void TestDelayedTask() { |
72 if (--num_tasks_to_run_ == 0) { | 75 if (--num_tasks_to_run_ == 0) { |
73 message_loop_->Quit(); | 76 message_loop_->Quit(); |
74 } | 77 } |
75 | 78 |
76 num_tasks_in_flight_--; | 79 num_tasks_in_flight_--; |
77 // NOTE there are only up to max_tasks_in_flight_ pending delayed tasks at | 80 // NOTE there are only up to max_tasks_in_flight_ pending delayed tasks at |
78 // any one time. Thanks to the lower_num_tasks_to_post going to zero if | 81 // any one time. Thanks to the lower_num_tasks_to_post going to zero if |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 max_tasks_in_flight_ = 200; | 165 max_tasks_in_flight_ = 200; |
163 Benchmark("run 10000 delayed tasks with eight queues", | 166 Benchmark("run 10000 delayed tasks with eight queues", |
164 base::Bind(&TaskQueueManagerPerfTest::ResetAndCallTestDelayedTask, | 167 base::Bind(&TaskQueueManagerPerfTest::ResetAndCallTestDelayedTask, |
165 base::Unretained(this), 10000)); | 168 base::Unretained(this), 10000)); |
166 } | 169 } |
167 | 170 |
168 // TODO(alexclarke): Add additional tests with different mixes of non-delayed vs | 171 // TODO(alexclarke): Add additional tests with different mixes of non-delayed vs |
169 // delayed tasks. | 172 // delayed tasks. |
170 | 173 |
171 } // namespace content | 174 } // namespace content |
OLD | NEW |