| 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/strings/stringprintf.h" |
| 10 #include "base/synchronization/condition_variable.h" | 10 #include "base/synchronization/condition_variable.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 std::vector<base::TimeTicks> thread_starts; | 69 std::vector<base::TimeTicks> thread_starts; |
| 70 while (threads_.size() < num_threads) { | 70 while (threads_.size() < num_threads) { |
| 71 threads_.push_back(new base::Thread("PingPonger")); | 71 threads_.push_back(new base::Thread("PingPonger")); |
| 72 threads_.back()->Start(); | 72 threads_.back()->Start(); |
| 73 if (base::TimeTicks::IsThreadNowSupported()) | 73 if (base::TimeTicks::IsThreadNowSupported()) |
| 74 thread_starts.push_back(ThreadNow(threads_.back())); | 74 thread_starts.push_back(ThreadNow(threads_.back())); |
| 75 } | 75 } |
| 76 | 76 |
| 77 Init(); | 77 Init(); |
| 78 | 78 |
| 79 base::TimeTicks start = base::TimeTicks::HighResNow(); | 79 base::TimeTicks start = base::TimeTicks::Now(); |
| 80 PingPong(kNumRuns); | 80 PingPong(kNumRuns); |
| 81 done_.Wait(); | 81 done_.Wait(); |
| 82 base::TimeTicks end = base::TimeTicks::HighResNow(); | 82 base::TimeTicks end = base::TimeTicks::Now(); |
| 83 | 83 |
| 84 // Gather the cpu-time spent on each thread. This does one extra tasks, | 84 // Gather the cpu-time spent on each thread. This does one extra tasks, |
| 85 // but that should be in the noise given enough runs. | 85 // but that should be in the noise given enough runs. |
| 86 base::TimeDelta thread_time; | 86 base::TimeDelta thread_time; |
| 87 while (threads_.size()) { | 87 while (threads_.size()) { |
| 88 if (base::TimeTicks::IsThreadNowSupported()) { | 88 if (base::TimeTicks::IsThreadNowSupported()) { |
| 89 thread_time += ThreadNow(threads_.back()) - thread_starts.back(); | 89 thread_time += ThreadNow(threads_.back()) - thread_starts.back(); |
| 90 thread_starts.pop_back(); | 90 thread_starts.pop_back(); |
| 91 } | 91 } |
| 92 threads_.pop_back(); | 92 threads_.pop_back(); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 typedef EventPerfTest<PthreadEvent> PthreadEventPerfTest; | 303 typedef EventPerfTest<PthreadEvent> PthreadEventPerfTest; |
| 304 TEST_F(PthreadEventPerfTest, EventPingPong) { | 304 TEST_F(PthreadEventPerfTest, EventPingPong) { |
| 305 RunPingPongTest("4_PthreadCondVar_Threads", 4); | 305 RunPingPongTest("4_PthreadCondVar_Threads", 4); |
| 306 } | 306 } |
| 307 | 307 |
| 308 #endif | 308 #endif |
| 309 | 309 |
| 310 } // namespace | 310 } // namespace |
| 311 | 311 |
| 312 } // namespace base | 312 } // namespace base |
| OLD | NEW |