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

Side by Side Diff: base/message_loop/message_pump_perftest.cc

Issue 1140363002: Revert of Reland: Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « base/message_loop/message_loop_proxy_impl.cc ('k') | base/threading/platform_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/synchronization/condition_variable.h" 9 #include "base/synchronization/condition_variable.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/perf/perf_test.h" 16 #include "testing/perf/perf_test.h"
17 17
18 #if defined(OS_ANDROID) 18 #if defined(OS_ANDROID)
19 #include "base/android/java_handler_thread.h" 19 #include "base/android/java_handler_thread.h"
20 #endif 20 #endif
21 21
22 namespace base { 22 namespace base {
23 namespace {
23 24
24 class ScheduleWorkTest : public testing::Test { 25 class ScheduleWorkTest : public testing::Test {
25 public: 26 public:
26 ScheduleWorkTest() : counter_(0) {} 27 ScheduleWorkTest() : counter_(0) {}
27 28
28 void Increment(uint64_t amount) { counter_ += amount; } 29 void Increment(uint64_t amount) { counter_ += amount; }
29 30
30 void Schedule(int index) { 31 void Schedule(int index) {
31 base::TimeTicks start = base::TimeTicks::Now(); 32 base::TimeTicks start = base::TimeTicks::Now();
32 base::TimeTicks thread_start; 33 base::TimeTicks thread_start;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 217
217 TEST_F(ScheduleWorkTest, ThreadTimeToJavaFromTwoThreads) { 218 TEST_F(ScheduleWorkTest, ThreadTimeToJavaFromTwoThreads) {
218 ScheduleWork(MessageLoop::TYPE_JAVA, 2); 219 ScheduleWork(MessageLoop::TYPE_JAVA, 2);
219 } 220 }
220 221
221 TEST_F(ScheduleWorkTest, ThreadTimeToJavaFromFourThreads) { 222 TEST_F(ScheduleWorkTest, ThreadTimeToJavaFromFourThreads) {
222 ScheduleWork(MessageLoop::TYPE_JAVA, 4); 223 ScheduleWork(MessageLoop::TYPE_JAVA, 4);
223 } 224 }
224 #endif 225 #endif
225 226
227 static void DoNothing() {
228 }
229
226 class FakeMessagePump : public MessagePump { 230 class FakeMessagePump : public MessagePump {
227 public: 231 public:
228 FakeMessagePump() {} 232 FakeMessagePump() {}
229 ~FakeMessagePump() override {} 233 ~FakeMessagePump() override {}
230 234
231 void Run(Delegate* delegate) override {} 235 void Run(Delegate* delegate) override {}
232 236
233 void Quit() override {} 237 void Quit() override {}
234 void ScheduleWork() override {} 238 void ScheduleWork() override {}
235 void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override {} 239 void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override {}
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 282 }
279 283
280 TEST_F(PostTaskTest, TenTasksPerReload) { 284 TEST_F(PostTaskTest, TenTasksPerReload) {
281 Run(10000, 10); 285 Run(10000, 10);
282 } 286 }
283 287
284 TEST_F(PostTaskTest, OneHundredTasksPerReload) { 288 TEST_F(PostTaskTest, OneHundredTasksPerReload) {
285 Run(1000, 100); 289 Run(1000, 100);
286 } 290 }
287 291
292 } // namespace
288 } // namespace base 293 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_proxy_impl.cc ('k') | base/threading/platform_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698