OLD | NEW |
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/base_switches.h" | 5 #include "base/base_switches.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/strings/stringprintf.h" |
9 #include "base/synchronization/condition_variable.h" | 10 #include "base/synchronization/condition_variable.h" |
10 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
11 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/perf/perf_test.h" | 17 #include "testing/perf/perf_test.h" |
17 | 18 |
18 #if defined(OS_POSIX) | 19 #if defined(OS_POSIX) |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 base::ConditionVariable cond_; | 253 base::ConditionVariable cond_; |
253 bool signaled_; | 254 bool signaled_; |
254 }; | 255 }; |
255 | 256 |
256 // This is meant to test the absolute minimal context switching time | 257 // This is meant to test the absolute minimal context switching time |
257 // using our own base synchronization code. | 258 // using our own base synchronization code. |
258 typedef EventPerfTest<ConditionVariableEvent> ConditionVariablePerfTest; | 259 typedef EventPerfTest<ConditionVariableEvent> ConditionVariablePerfTest; |
259 TEST_F(ConditionVariablePerfTest, EventPingPong) { | 260 TEST_F(ConditionVariablePerfTest, EventPingPong) { |
260 RunPingPongTest("4_ConditionVariable_Threads", 4); | 261 RunPingPongTest("4_ConditionVariable_Threads", 4); |
261 } | 262 } |
262 | |
263 #if defined(OS_POSIX) | 263 #if defined(OS_POSIX) |
264 | 264 |
265 // Absolutely 100% minimal posix waitable event. If there is a better/faster | 265 // Absolutely 100% minimal posix waitable event. If there is a better/faster |
266 // way to force a context switch, we should use that instead. | 266 // way to force a context switch, we should use that instead. |
267 class PthreadEvent { | 267 class PthreadEvent { |
268 public: | 268 public: |
269 PthreadEvent(bool manual_reset, bool initially_signaled) { | 269 PthreadEvent(bool manual_reset, bool initially_signaled) { |
270 DCHECK(!manual_reset); | 270 DCHECK(!manual_reset); |
271 DCHECK(!initially_signaled); | 271 DCHECK(!initially_signaled); |
272 pthread_mutex_init(&mutex_, 0); | 272 pthread_mutex_init(&mutex_, 0); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 typedef EventPerfTest<PthreadEvent> PthreadEventPerfTest; | 305 typedef EventPerfTest<PthreadEvent> PthreadEventPerfTest; |
306 TEST_F(PthreadEventPerfTest, EventPingPong) { | 306 TEST_F(PthreadEventPerfTest, EventPingPong) { |
307 RunPingPongTest("4_PthreadCondVar_Threads", 4); | 307 RunPingPongTest("4_PthreadCondVar_Threads", 4); |
308 } | 308 } |
309 | 309 |
310 #endif | 310 #endif |
311 | 311 |
312 } // namespace | 312 } // namespace |
313 | 313 |
314 } // namespace base | 314 } // namespace base |
OLD | NEW |