| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "TimingStateMachine.h" | 8 #include "TimingStateMachine.h" |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 this->resetTimingState(); | 94 this->resetTimingState(); |
| 95 return kReset_ParentEvents; | 95 return kReset_ParentEvents; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 void TimingStateMachine::recordMeasurement() { | 99 void TimingStateMachine::recordMeasurement() { |
| 100 fLastMeasurement = this->elapsed() / (FLAGS_frames * fLoops); | 100 fLastMeasurement = this->elapsed() / (FLAGS_frames * fLoops); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void TimingStateMachine::nextBenchmark(SkCanvas* canvas, Benchmark* benchmark) { | |
| 104 benchmark->postDraw(canvas); | |
| 105 benchmark->perCanvasPostDraw(canvas); | |
| 106 fLoops = 1; | |
| 107 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State); | |
| 108 } | |
| 109 | |
| 110 inline TimingStateMachine::ParentEvents TimingStateMachine::timing(SkCanvas* can
vas, | 103 inline TimingStateMachine::ParentEvents TimingStateMachine::timing(SkCanvas* can
vas, |
| 111 Benchmark* be
nchmark) { | 104 Benchmark* be
nchmark) { |
| 112 if (fCurrentFrame >= FLAGS_frames) { | 105 if (fCurrentFrame >= FLAGS_frames) { |
| 113 this->recordMeasurement(); | 106 this->recordMeasurement(); |
| 114 this->resetTimingState(); | 107 this->resetTimingState(); |
| 115 this->nextState(kPreWarmTimingPerCanvasPreDraw_State); | |
| 116 return kTimingFinished_ParentEvents; | 108 return kTimingFinished_ParentEvents; |
| 117 } else { | 109 } else { |
| 118 fCurrentFrame++; | 110 fCurrentFrame++; |
| 119 return kTiming_ParentEvents; | 111 return kTiming_ParentEvents; |
| 120 } | 112 } |
| 121 } | 113 } |
| 122 | 114 |
| 115 void TimingStateMachine::nextBenchmark(SkCanvas* canvas, Benchmark* benchmark) { |
| 116 benchmark->postDraw(canvas); |
| 117 benchmark->perCanvasPostDraw(canvas); |
| 118 fLoops = 1; |
| 119 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State); |
| 120 } |
| 121 |
| 122 void TimingStateMachine::nextSampleWithPrewarm() { |
| 123 this->nextState(kPreWarmTimingPerCanvasPreDraw_State); |
| 124 } |
| 125 |
| 126 void TimingStateMachine::nextSample() { |
| 127 fTimer.start(); |
| 128 } |
| OLD | NEW |