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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/message_loop/message_loop_proxy.h" | |
10 #include "base/values.h" | 11 #include "base/values.h" |
11 #include "cc/debug/picture_record_benchmark.h" | 12 #include "cc/debug/picture_record_benchmark.h" |
12 #include "cc/debug/unittest_only_benchmark.h" | 13 #include "cc/debug/unittest_only_benchmark.h" |
13 #include "cc/trees/layer_tree_host.h" | 14 #include "cc/trees/layer_tree_host.h" |
15 #include "cc/trees/layer_tree_host_impl.h" | |
14 | 16 |
15 namespace cc { | 17 namespace cc { |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 scoped_ptr<MicroBenchmark> CreateBenchmark( | 21 scoped_ptr<MicroBenchmark> CreateBenchmark( |
20 const std::string& name, | 22 const std::string& name, |
21 scoped_ptr<base::Value> value, | 23 scoped_ptr<base::Value> value, |
22 const MicroBenchmark::DoneCallback& callback) { | 24 const MicroBenchmark::DoneCallback& callback) { |
23 if (name == "picture_record_benchmark") { | 25 if (name == "picture_record_benchmark") { |
(...skipping 12 matching lines...) Expand all Loading... | |
36 typedef bool result_type; | 38 typedef bool result_type; |
37 | 39 |
38 result_type operator()(argument_type benchmark) const { | 40 result_type operator()(argument_type benchmark) const { |
39 return benchmark->IsDone(); | 41 return benchmark->IsDone(); |
40 } | 42 } |
41 }; | 43 }; |
42 | 44 |
43 } // namespace | 45 } // namespace |
44 | 46 |
45 MicroBenchmarkController::MicroBenchmarkController(LayerTreeHost* host) | 47 MicroBenchmarkController::MicroBenchmarkController(LayerTreeHost* host) |
46 : host_(host) { | 48 : host_(host), |
49 main_controller_message_loop_(base::MessageLoopProxy::current().get()) { | |
47 DCHECK(host_); | 50 DCHECK(host_); |
48 } | 51 } |
49 | 52 |
50 MicroBenchmarkController::~MicroBenchmarkController() {} | 53 MicroBenchmarkController::~MicroBenchmarkController() {} |
51 | 54 |
52 bool MicroBenchmarkController::ScheduleRun( | 55 bool MicroBenchmarkController::ScheduleRun( |
53 const std::string& micro_benchmark_name, | 56 const std::string& micro_benchmark_name, |
54 scoped_ptr<base::Value> value, | 57 scoped_ptr<base::Value> value, |
55 const MicroBenchmark::DoneCallback& callback) { | 58 const MicroBenchmark::DoneCallback& callback) { |
56 scoped_ptr<MicroBenchmark> benchmark = | 59 scoped_ptr<MicroBenchmark> benchmark = |
57 CreateBenchmark(micro_benchmark_name, value.Pass(), callback); | 60 CreateBenchmark(micro_benchmark_name, value.Pass(), callback); |
58 if (benchmark.get()) { | 61 if (benchmark.get()) { |
59 benchmarks_.push_back(benchmark.Pass()); | 62 benchmarks_.push_back(benchmark.Pass()); |
60 host_->SetNeedsCommit(); | 63 host_->SetNeedsCommit(); |
61 return true; | 64 return true; |
62 } | 65 } |
63 return false; | 66 return false; |
64 } | 67 } |
65 | 68 |
69 void MicroBenchmarkController::ScheduleImplBenchmarks( | |
70 LayerTreeHostImpl* host_impl) { | |
71 for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); | |
72 it != benchmarks_.end(); | |
73 ++it) { | |
74 scoped_ptr<MicroBenchmarkImpl> benchmark_impl = | |
75 (*it)->CreateBenchmarkImpl(main_controller_message_loop_); | |
enne (OOO)
2013/11/12 01:09:36
So if you have a MicroBenchmarkImpl that doesn't c
vmpstr
2013/11/12 17:51:38
That's a good point. I mean it _could_ happen that
enne (OOO)
2013/11/12 19:22:56
Yeah, I'm not sure what the right thing to do here
vmpstr
2013/11/12 20:20:38
I went with just keeping the state in the microben
| |
76 if (benchmark_impl.get()) | |
77 host_impl->ScheduleMicroBenchmark(benchmark_impl.Pass()); | |
78 } | |
79 } | |
80 | |
66 void MicroBenchmarkController::DidUpdateLayers() { | 81 void MicroBenchmarkController::DidUpdateLayers() { |
67 for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); | 82 for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin(); |
68 it != benchmarks_.end(); | 83 it != benchmarks_.end(); |
69 ++it) { | 84 ++it) { |
70 DCHECK(!(*it)->IsDone()); | 85 if (!(*it)->IsDone()) |
vmpstr
2013/11/09 00:41:41
If the main thread benchmark was waiting for the i
| |
71 (*it)->DidUpdateLayers(host_); | 86 (*it)->DidUpdateLayers(host_); |
72 } | 87 } |
73 | 88 |
74 CleanUpFinishedBenchmarks(); | 89 CleanUpFinishedBenchmarks(); |
75 } | 90 } |
76 | 91 |
77 void MicroBenchmarkController::CleanUpFinishedBenchmarks() { | 92 void MicroBenchmarkController::CleanUpFinishedBenchmarks() { |
78 benchmarks_.erase( | 93 benchmarks_.erase( |
79 benchmarks_.partition(std::not1(IsDonePredicate())), | 94 benchmarks_.partition(std::not1(IsDonePredicate())), |
80 benchmarks_.end()); | 95 benchmarks_.end()); |
81 } | 96 } |
82 | 97 |
83 } // namespace cc | 98 } // namespace cc |
OLD | NEW |