| 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 | 8 |
| 9 #include "VisualLightweightBenchModule.h" | 9 #include "VisualLightweightBenchModule.h" |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 fBenchmark.reset(fBenchmarkStream->next()); | 165 fBenchmark.reset(fBenchmarkStream->next()); |
| 166 if (!fBenchmark) { | 166 if (!fBenchmark) { |
| 167 return false; | 167 return false; |
| 168 } | 168 } |
| 169 | 169 |
| 170 fOwner->clear(canvas, SK_ColorWHITE, 2); | 170 fOwner->clear(canvas, SK_ColorWHITE, 2); |
| 171 | 171 |
| 172 fBenchmark->preDraw(); | 172 fBenchmark->delayedSetup(); |
| 173 fRecords.push_back(); | 173 fRecords.push_back(); |
| 174 | 174 |
| 175 // Log bench name | 175 // Log bench name |
| 176 fResults->bench(fBenchmark->getUniqueName(), fBenchmark->getSize().fX, | 176 fResults->bench(fBenchmark->getUniqueName(), fBenchmark->getSize().fX, |
| 177 fBenchmark->getSize().fY); | 177 fBenchmark->getSize().fY); |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 | 180 |
| 181 inline void VisualLightweightBenchModule::nextState(State nextState) { | 181 inline void VisualLightweightBenchModule::nextState(State nextState) { |
| 182 fState = nextState; | 182 fState = nextState; |
| 183 } | 183 } |
| 184 | 184 |
| 185 void VisualLightweightBenchModule::perCanvasPreDraw(SkCanvas* canvas, State next
State) { | 185 void VisualLightweightBenchModule::perCanvasPreDraw(SkCanvas* canvas, State next
State) { |
| 186 fBenchmark->perCanvasPreDraw(canvas); | 186 fBenchmark->perCanvasPreDraw(canvas); |
| 187 fBenchmark->preDraw(canvas); |
| 187 fCurrentFrame = 0; | 188 fCurrentFrame = 0; |
| 188 this->nextState(nextState); | 189 this->nextState(nextState); |
| 189 } | 190 } |
| 190 | 191 |
| 191 void VisualLightweightBenchModule::warmup(SkCanvas* canvas) { | 192 void VisualLightweightBenchModule::warmup(SkCanvas* canvas) { |
| 192 if (fCurrentFrame >= FLAGS_maxWarmupFrames) { | 193 if (fCurrentFrame >= FLAGS_maxWarmupFrames) { |
| 193 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State); | 194 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State); |
| 194 fBenchmark.reset(nullptr); | 195 fBenchmark.reset(nullptr); |
| 195 this->resetTimingState(); | 196 this->resetTimingState(); |
| 196 fLoops = 1; | 197 fLoops = 1; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 this->resetTimingState(); | 287 this->resetTimingState(); |
| 287 } | 288 } |
| 288 } | 289 } |
| 289 | 290 |
| 290 void VisualLightweightBenchModule::recordMeasurement() { | 291 void VisualLightweightBenchModule::recordMeasurement() { |
| 291 double measurement = this->elapsed() / (FLAGS_frames * fLoops); | 292 double measurement = this->elapsed() / (FLAGS_frames * fLoops); |
| 292 fRecords.back().fMeasurements.push_back(measurement); | 293 fRecords.back().fMeasurements.push_back(measurement); |
| 293 } | 294 } |
| 294 | 295 |
| 295 void VisualLightweightBenchModule::postDraw(SkCanvas* canvas) { | 296 void VisualLightweightBenchModule::postDraw(SkCanvas* canvas) { |
| 297 fBenchmark->postDraw(canvas); |
| 296 fBenchmark->perCanvasPostDraw(canvas); | 298 fBenchmark->perCanvasPostDraw(canvas); |
| 297 fBenchmark.reset(nullptr); | 299 fBenchmark.reset(nullptr); |
| 298 fCurrentSample = 0; | 300 fCurrentSample = 0; |
| 299 fLoops = 1; | 301 fLoops = 1; |
| 300 } | 302 } |
| 301 | 303 |
| 302 inline void VisualLightweightBenchModule::timing(SkCanvas* canvas) { | 304 inline void VisualLightweightBenchModule::timing(SkCanvas* canvas) { |
| 303 if (fCurrentFrame >= FLAGS_frames) { | 305 if (fCurrentFrame >= FLAGS_frames) { |
| 304 this->recordMeasurement(); | 306 this->recordMeasurement(); |
| 305 if (fCurrentSample++ >= FLAGS_samples) { | 307 if (fCurrentSample++ >= FLAGS_samples) { |
| 306 this->printStats(); | 308 this->printStats(); |
| 307 this->postDraw(canvas); | 309 this->postDraw(canvas); |
| 308 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State); | 310 this->nextState(kPreWarmLoopsPerCanvasPreDraw_State); |
| 309 } else { | 311 } else { |
| 310 this->nextState(kPreWarmTimingPerCanvasPreDraw_State); | 312 this->nextState(kPreWarmTimingPerCanvasPreDraw_State); |
| 311 } | 313 } |
| 312 this->resetTimingState(); | 314 this->resetTimingState(); |
| 313 } else { | 315 } else { |
| 314 fCurrentFrame++; | 316 fCurrentFrame++; |
| 315 } | 317 } |
| 316 } | 318 } |
| 317 | 319 |
| 318 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { | 320 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { |
| 319 return true; | 321 return true; |
| 320 } | 322 } |
| OLD | NEW |