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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 for (int j = 0; j < tasks_per_reload; ++j) { | 265 for (int j = 0; j < tasks_per_reload; ++j) { |
266 queue->AddToIncomingQueue( | 266 queue->AddToIncomingQueue( |
267 FROM_HERE, base::Bind(&DoNothing), base::TimeDelta(), false); | 267 FROM_HERE, base::Bind(&DoNothing), base::TimeDelta(), false); |
268 num_posted++; | 268 num_posted++; |
269 } | 269 } |
270 TaskQueue loop_local_queue; | 270 TaskQueue loop_local_queue; |
271 queue->ReloadWorkQueue(&loop_local_queue); | 271 queue->ReloadWorkQueue(&loop_local_queue); |
272 while (!loop_local_queue.empty()) { | 272 while (!loop_local_queue.empty()) { |
273 PendingTask t = std::move(loop_local_queue.front()); | 273 PendingTask t = std::move(loop_local_queue.front()); |
274 loop_local_queue.pop(); | 274 loop_local_queue.pop(); |
275 loop.RunTask(t); | 275 loop.RunTask(&t); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 now = base::TimeTicks::Now(); | 279 now = base::TimeTicks::Now(); |
280 } while (now - start < base::TimeDelta::FromSeconds(5)); | 280 } while (now - start < base::TimeDelta::FromSeconds(5)); |
281 std::string trace = StringPrintf("%d_tasks_per_reload", tasks_per_reload); | 281 std::string trace = StringPrintf("%d_tasks_per_reload", tasks_per_reload); |
282 perf_test::PrintResult( | 282 perf_test::PrintResult( |
283 "task", | 283 "task", |
284 "", | 284 "", |
285 trace, | 285 trace, |
286 (now - start).InMicroseconds() / static_cast<double>(num_posted), | 286 (now - start).InMicroseconds() / static_cast<double>(num_posted), |
287 "us/task", | 287 "us/task", |
288 true); | 288 true); |
289 } | 289 } |
290 }; | 290 }; |
291 | 291 |
292 TEST_F(PostTaskTest, OneTaskPerReload) { | 292 TEST_F(PostTaskTest, OneTaskPerReload) { |
293 Run(10000, 1); | 293 Run(10000, 1); |
294 } | 294 } |
295 | 295 |
296 TEST_F(PostTaskTest, TenTasksPerReload) { | 296 TEST_F(PostTaskTest, TenTasksPerReload) { |
297 Run(10000, 10); | 297 Run(10000, 10); |
298 } | 298 } |
299 | 299 |
300 TEST_F(PostTaskTest, OneHundredTasksPerReload) { | 300 TEST_F(PostTaskTest, OneHundredTasksPerReload) { |
301 Run(1000, 100); | 301 Run(1000, 100); |
302 } | 302 } |
303 | 303 |
304 } // namespace base | 304 } // namespace base |
OLD | NEW |