OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/debug/micro_benchmark_controller.h" | 5 #include "cc/debug/micro_benchmark_controller.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 int MicroBenchmarkController::next_id_ = 1; | 22 int MicroBenchmarkController::next_id_ = 1; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 scoped_ptr<MicroBenchmark> CreateBenchmark( | 26 scoped_ptr<MicroBenchmark> CreateBenchmark( |
27 const std::string& name, | 27 const std::string& name, |
28 scoped_ptr<base::Value> value, | 28 scoped_ptr<base::Value> value, |
29 const MicroBenchmark::DoneCallback& callback) { | 29 const MicroBenchmark::DoneCallback& callback) { |
30 if (name == "invalidation_benchmark") { | 30 if (name == "invalidation_benchmark") { |
31 return make_scoped_ptr(new InvalidationBenchmark(value.Pass(), callback)); | 31 return scoped_ptr<MicroBenchmark>( |
| 32 new InvalidationBenchmark(value.Pass(), callback)); |
32 } else if (name == "picture_record_benchmark") { | 33 } else if (name == "picture_record_benchmark") { |
33 return make_scoped_ptr(new PictureRecordBenchmark(value.Pass(), callback)); | 34 return scoped_ptr<MicroBenchmark>( |
| 35 new PictureRecordBenchmark(value.Pass(), callback)); |
34 } else if (name == "rasterize_and_record_benchmark") { | 36 } else if (name == "rasterize_and_record_benchmark") { |
35 return make_scoped_ptr( | 37 return scoped_ptr<MicroBenchmark>( |
36 new RasterizeAndRecordBenchmark(value.Pass(), callback)); | 38 new RasterizeAndRecordBenchmark(value.Pass(), callback)); |
37 } else if (name == "unittest_only_benchmark") { | 39 } else if (name == "unittest_only_benchmark") { |
38 return make_scoped_ptr(new UnittestOnlyBenchmark(value.Pass(), callback)); | 40 return scoped_ptr<MicroBenchmark>( |
| 41 new UnittestOnlyBenchmark(value.Pass(), callback)); |
39 } | 42 } |
40 return nullptr; | 43 return scoped_ptr<MicroBenchmark>(); |
41 } | 44 } |
42 | 45 |
43 class IsDonePredicate { | 46 class IsDonePredicate { |
44 public: | 47 public: |
45 typedef const MicroBenchmark* argument_type; | 48 typedef const MicroBenchmark* argument_type; |
46 typedef bool result_type; | 49 typedef bool result_type; |
47 | 50 |
48 result_type operator()(argument_type benchmark) const { | 51 result_type operator()(argument_type benchmark) const { |
49 return benchmark->IsDone(); | 52 return benchmark->IsDone(); |
50 } | 53 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 CleanUpFinishedBenchmarks(); | 125 CleanUpFinishedBenchmarks(); |
123 } | 126 } |
124 | 127 |
125 void MicroBenchmarkController::CleanUpFinishedBenchmarks() { | 128 void MicroBenchmarkController::CleanUpFinishedBenchmarks() { |
126 benchmarks_.erase( | 129 benchmarks_.erase( |
127 benchmarks_.partition(std::not1(IsDonePredicate())), | 130 benchmarks_.partition(std::not1(IsDonePredicate())), |
128 benchmarks_.end()); | 131 benchmarks_.end()); |
129 } | 132 } |
130 | 133 |
131 } // namespace cc | 134 } // namespace cc |
OLD | NEW |