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

Side by Side Diff: base/threading/thread_perftest.cc

Issue 1094903006: Update {virtual,override} to follow C++11 style in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/test/test_suite.cc ('k') | base/trace_event/trace_event.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/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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 TEST_F(TaskObserverPerfTest, TaskPingPong) { 167 TEST_F(TaskObserverPerfTest, TaskPingPong) {
168 RunPingPongTest("1_Task_Threads_With_Observer", 1); 168 RunPingPongTest("1_Task_Threads_With_Observer", 1);
169 RunPingPongTest("4_Task_Threads_With_Observer", 4); 169 RunPingPongTest("4_Task_Threads_With_Observer", 4);
170 } 170 }
171 171
172 // Class to test our WaitableEvent performance by signaling back and fort. 172 // Class to test our WaitableEvent performance by signaling back and fort.
173 // WaitableEvent is templated so we can also compare with other versions. 173 // WaitableEvent is templated so we can also compare with other versions.
174 template <typename WaitableEventType> 174 template <typename WaitableEventType>
175 class EventPerfTest : public ThreadPerfTest { 175 class EventPerfTest : public ThreadPerfTest {
176 public: 176 public:
177 virtual void Init() override { 177 void Init() override {
178 for (size_t i = 0; i < threads_.size(); i++) 178 for (size_t i = 0; i < threads_.size(); i++)
179 events_.push_back(new WaitableEventType(false, false)); 179 events_.push_back(new WaitableEventType(false, false));
180 } 180 }
181 181
182 virtual void Reset() override { events_.clear(); } 182 void Reset() override { events_.clear(); }
183 183
184 void WaitAndSignalOnThread(size_t event) { 184 void WaitAndSignalOnThread(size_t event) {
185 size_t next_event = (event + 1) % events_.size(); 185 size_t next_event = (event + 1) % events_.size();
186 int my_hops = 0; 186 int my_hops = 0;
187 do { 187 do {
188 events_[event]->Wait(); 188 events_[event]->Wait();
189 my_hops = --remaining_hops_; // We own 'hops' between Wait and Signal. 189 my_hops = --remaining_hops_; // We own 'hops' between Wait and Signal.
190 events_[next_event]->Signal(); 190 events_[next_event]->Signal();
191 } while (my_hops > 0); 191 } while (my_hops > 0);
192 // Once we are done, all threads will signal as hops passes zero. 192 // Once we are done, all threads will signal as hops passes zero.
193 // We only signal completion once, on the thread that reaches zero. 193 // We only signal completion once, on the thread that reaches zero.
194 if (!my_hops) 194 if (!my_hops)
195 FinishMeasurement(); 195 FinishMeasurement();
196 } 196 }
197 197
198 virtual void PingPong(int hops) override { 198 void PingPong(int hops) override {
199 remaining_hops_ = hops; 199 remaining_hops_ = hops;
200 for (size_t i = 0; i < threads_.size(); i++) { 200 for (size_t i = 0; i < threads_.size(); i++) {
201 threads_[i]->message_loop_proxy()->PostTask( 201 threads_[i]->message_loop_proxy()->PostTask(
202 FROM_HERE, 202 FROM_HERE,
203 base::Bind(&EventPerfTest::WaitAndSignalOnThread, 203 base::Bind(&EventPerfTest::WaitAndSignalOnThread,
204 base::Unretained(this), 204 base::Unretained(this),
205 i)); 205 i));
206 } 206 }
207 207
208 // Kick off the Signal ping-ponging. 208 // Kick off the Signal ping-ponging.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « base/test/test_suite.cc ('k') | base/trace_event/trace_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698