Index: base/threading/thread_perftest.cc |
diff --git a/base/threading/thread_perftest.cc b/base/threading/thread_perftest.cc |
index 840a033226f3acb50de5de5f5461b0d226d73d8b..eaeddf9443507f4e73c8688f093628e797254bc9 100644 |
--- a/base/threading/thread_perftest.cc |
+++ b/base/threading/thread_perftest.cc |
@@ -144,6 +144,32 @@ TEST_F(TaskPerfTest, TaskPingPong) { |
RunPingPongTest("4_Task_Threads", 4); |
} |
+ |
+// Same as above, but add observers to test their perf impact. |
+class MessageLoopObserver : public base::MessageLoop::TaskObserver { |
+ public: |
+ virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE { |
+ } |
+ virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE { |
+ } |
+}; |
+MessageLoopObserver message_loop_observer; |
Nico
2014/04/24 02:52:20
Does this have to be a global? Can you make this a
epenner
2014/04/24 03:14:36
Good point. I wasn't thinking about it since it's
|
+ |
+class TaskObserverPerfTest : public TaskPerfTest { |
+ public: |
+ virtual void Init() OVERRIDE { |
+ TaskPerfTest::Init(); |
+ for (size_t i = 0; i < threads_.size(); i++) { |
+ threads_[i]->message_loop()->AddTaskObserver(&message_loop_observer); |
+ } |
+ } |
+}; |
+ |
+TEST_F(TaskObserverPerfTest, TaskPingPong) { |
+ RunPingPongTest("1_Task_Threads_With_Observer", 1); |
+ RunPingPongTest("4_Task_Threads_With_Observer", 4); |
+} |
+ |
// Class to test our WaitableEvent performance by signaling back and fort. |
// WaitableEvent is templated so we can also compare with other versions. |
template <typename WaitableEventType> |