Microbenchmark for the cost of posting tasks to different pump types
This adds microbenchmarks to measure the cost of posting a task to
a message loop running different pump types. This measures the wall and
(where supported) thread time that elapses from different numbers of
threads posting to one target. This is not designed to measure the time
taken by the target thread or fairness of posting threads.
Each test is set up with one target thread and 1-4 posting threads. The
posting threads each run one task that posts batches of tasks to the
target thread until they have been working for at least 5 seconds of
wall time. The tasks on the target thread simply increment a counter.
The test runner starts each posting thread, posts a start task to each
then joins them and then joins the target thread and aggregates stats.
BUG=412137
Review URL: https://codereview.chromium.org/551183002
Cr-Commit-Position: refs/heads/master@{#297264}
CrOS-Libchrome-Original-Commit: 2e146d74f78041f91bd43562bd1a0210374a41eb
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 8db1e77..3cec37e 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -391,12 +391,22 @@
// Returns true if the message loop is "idle". Provided for testing.
bool IsIdleForTesting();
+ // Wakes up the message pump. Can be called on any thread. The caller is
+ // responsible for synchronizing ScheduleWork() calls.
+ void ScheduleWork(bool was_empty);
+
+ // Returns the TaskAnnotator which is used to add debug information to posted
+ // tasks.
+ debug::TaskAnnotator* task_annotator() { return &task_annotator_; }
+
+ // Runs the specified PendingTask.
+ void RunTask(const PendingTask& pending_task);
+
//----------------------------------------------------------------------------
protected:
scoped_ptr<MessagePump> pump_;
private:
- friend class internal::IncomingTaskQueue;
friend class RunLoop;
// Configures various members for the two constructors.
@@ -408,9 +418,6 @@
// Called to process any delayed non-nestable tasks.
bool ProcessNextDelayedNonNestableTask();
- // Runs the specified PendingTask.
- void RunTask(const PendingTask& pending_task);
-
// Calls RunTask or queues the pending_task on the deferred task list if it
// cannot be run right now. Returns true if the task was run.
bool DeferOrRunPendingTask(const PendingTask& pending_task);
@@ -423,18 +430,10 @@
// true if some work was done.
bool DeletePendingTasks();
- // Returns the TaskAnnotator which is used to add debug information to posted
- // tasks.
- debug::TaskAnnotator* task_annotator() { return &task_annotator_; }
-
// Loads tasks from the incoming queue to |work_queue_| if the latter is
// empty.
void ReloadWorkQueue();
- // Wakes up the message pump. Can be called on any thread. The caller is
- // responsible for synchronizing ScheduleWork() calls.
- void ScheduleWork(bool was_empty);
-
// Start recording histogram info about events and action IF it was enabled
// and IF the statistics recorder can accept a registration of our histogram.
void StartHistogrammer();