Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: components/scheduler/base/task_queue_manager_perftest.cc

Issue 1402553002: Don't use base::MessageLoop::{Quit,QuitClosure} in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/scheduler/base/task_queue_manager.h" 5 #include "components/scheduler/base/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 "components/scheduler/base/nestable_task_runner_for_test.h" 9 #include "components/scheduler/base/nestable_task_runner_for_test.h"
10 #include "components/scheduler/base/task_queue_impl.h" 10 #include "components/scheduler/base/task_queue_impl.h"
(...skipping 18 matching lines...) Expand all
29 message_loop_.reset(new base::MessageLoop()); 29 message_loop_.reset(new base::MessageLoop());
30 manager_ = make_scoped_ptr(new TaskQueueManager( 30 manager_ = make_scoped_ptr(new TaskQueueManager(
31 NestableTaskRunnerForTest::Create(message_loop_->task_runner()), 31 NestableTaskRunnerForTest::Create(message_loop_->task_runner()),
32 "fake.category", "fake.category.debug")); 32 "fake.category", "fake.category.debug"));
33 for (size_t i = 0; i < num_queues; i++) 33 for (size_t i = 0; i < num_queues; i++)
34 queues_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test"))); 34 queues_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test")));
35 } 35 }
36 36
37 void TestDelayedTask() { 37 void TestDelayedTask() {
38 if (--num_tasks_to_run_ == 0) { 38 if (--num_tasks_to_run_ == 0) {
39 message_loop_->Quit(); 39 message_loop_->QuitWhenIdle();
40 } 40 }
41 41
42 num_tasks_in_flight_--; 42 num_tasks_in_flight_--;
43 // NOTE there are only up to max_tasks_in_flight_ pending delayed tasks at 43 // NOTE there are only up to max_tasks_in_flight_ pending delayed tasks at
44 // any one time. Thanks to the lower_num_tasks_to_post going to zero if 44 // any one time. Thanks to the lower_num_tasks_to_post going to zero if
45 // there are a lot of tasks in flight, the total number of task in flight at 45 // there are a lot of tasks in flight, the total number of task in flight at
46 // any one time is very variable. 46 // any one time is very variable.
47 unsigned int lower_num_tasks_to_post = 47 unsigned int lower_num_tasks_to_post =
48 num_tasks_in_flight_ < (max_tasks_in_flight_ / 2) ? 1 : 0; 48 num_tasks_in_flight_ < (max_tasks_in_flight_ / 2) ? 1 : 0;
49 unsigned int max_tasks_to_post = 49 unsigned int max_tasks_to_post =
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 max_tasks_in_flight_ = 200; 132 max_tasks_in_flight_ = 200;
133 Benchmark("run 10000 delayed tasks with eight queues", 133 Benchmark("run 10000 delayed tasks with eight queues",
134 base::Bind(&TaskQueueManagerPerfTest::ResetAndCallTestDelayedTask, 134 base::Bind(&TaskQueueManagerPerfTest::ResetAndCallTestDelayedTask,
135 base::Unretained(this), 10000)); 135 base::Unretained(this), 10000));
136 } 136 }
137 137
138 // TODO(alexclarke): Add additional tests with different mixes of non-delayed vs 138 // TODO(alexclarke): Add additional tests with different mixes of non-delayed vs
139 // delayed tasks. 139 // delayed tasks.
140 140
141 } // namespace scheduler 141 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698