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 scoped_ptr<MicroBenchmark>( | 31 return make_scoped_ptr(new InvalidationBenchmark(value.Pass(), callback)); |
32 new InvalidationBenchmark(value.Pass(), callback)); | |
33 } else if (name == "picture_record_benchmark") { | 32 } else if (name == "picture_record_benchmark") { |
34 return scoped_ptr<MicroBenchmark>( | 33 return make_scoped_ptr(new PictureRecordBenchmark(value.Pass(), callback)); |
35 new PictureRecordBenchmark(value.Pass(), callback)); | |
36 } else if (name == "rasterize_and_record_benchmark") { | 34 } else if (name == "rasterize_and_record_benchmark") { |
37 return scoped_ptr<MicroBenchmark>( | 35 return make_scoped_ptr( |
38 new RasterizeAndRecordBenchmark(value.Pass(), callback)); | 36 new RasterizeAndRecordBenchmark(value.Pass(), callback)); |
39 } else if (name == "unittest_only_benchmark") { | 37 } else if (name == "unittest_only_benchmark") { |
40 return scoped_ptr<MicroBenchmark>( | 38 return make_scoped_ptr(new UnittestOnlyBenchmark(value.Pass(), callback)); |
41 new UnittestOnlyBenchmark(value.Pass(), callback)); | |
42 } | 39 } |
43 return scoped_ptr<MicroBenchmark>(); | 40 return nullptr; |
44 } | 41 } |
45 | 42 |
46 class IsDonePredicate { | 43 class IsDonePredicate { |
47 public: | 44 public: |
48 typedef const MicroBenchmark* argument_type; | 45 typedef const MicroBenchmark* argument_type; |
49 typedef bool result_type; | 46 typedef bool result_type; |
50 | 47 |
51 result_type operator()(argument_type benchmark) const { | 48 result_type operator()(argument_type benchmark) const { |
52 return benchmark->IsDone(); | 49 return benchmark->IsDone(); |
53 } | 50 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 CleanUpFinishedBenchmarks(); | 122 CleanUpFinishedBenchmarks(); |
126 } | 123 } |
127 | 124 |
128 void MicroBenchmarkController::CleanUpFinishedBenchmarks() { | 125 void MicroBenchmarkController::CleanUpFinishedBenchmarks() { |
129 benchmarks_.erase( | 126 benchmarks_.erase( |
130 benchmarks_.partition(std::not1(IsDonePredicate())), | 127 benchmarks_.partition(std::not1(IsDonePredicate())), |
131 benchmarks_.end()); | 128 benchmarks_.end()); |
132 } | 129 } |
133 | 130 |
134 } // namespace cc | 131 } // namespace cc |
OLD | NEW |