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