| 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 26 matching lines...) Expand all Loading... |
| 37 if (FLAGS_verbose) { | 37 if (FLAGS_verbose) { |
| 38 return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 38 return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
| 39 } | 39 } |
| 40 return HumanizeMs(ms); | 40 return HumanizeMs(ms); |
| 41 } | 41 } |
| 42 | 42 |
| 43 #define HUMANIZE(time) humanize(time).c_str() | 43 #define HUMANIZE(time) humanize(time).c_str() |
| 44 | 44 |
| 45 VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner) | 45 VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner) |
| 46 : fCurrentSample(0) | 46 : fCurrentSample(0) |
| 47 , fHasBeenReset(false) |
| 47 , fOwner(SkRef(owner)) | 48 , fOwner(SkRef(owner)) |
| 48 , fResults(new ResultsWriter) { | 49 , fResults(new ResultsWriter) { |
| 49 fBenchmarkStream.reset(new VisualBenchmarkStream); | 50 fBenchmarkStream.reset(new VisualBenchmarkStream); |
| 50 | 51 |
| 51 // Print header | 52 // Print header |
| 52 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tbench\n"
, FLAGS_samples, | 53 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tbench\n"
, FLAGS_samples, |
| 53 "samples"); | 54 "samples"); |
| 54 | 55 |
| 55 // setup json logging if required | 56 // setup json logging if required |
| 56 if (!FLAGS_outResultsFile.isEmpty()) { | 57 if (!FLAGS_outResultsFile.isEmpty()) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return true; | 126 return true; |
| 126 } | 127 } |
| 127 | 128 |
| 128 fBenchmark.reset(fBenchmarkStream->next()); | 129 fBenchmark.reset(fBenchmarkStream->next()); |
| 129 if (!fBenchmark) { | 130 if (!fBenchmark) { |
| 130 return false; | 131 return false; |
| 131 } | 132 } |
| 132 | 133 |
| 133 fOwner->clear(canvas, SK_ColorWHITE, 2); | 134 fOwner->clear(canvas, SK_ColorWHITE, 2); |
| 134 | 135 |
| 135 fBenchmark->delayedSetup(); | |
| 136 fRecords.push_back(); | 136 fRecords.push_back(); |
| 137 | 137 |
| 138 // Log bench name | 138 // Log bench name |
| 139 fResults->bench(fBenchmark->getUniqueName(), fBenchmark->getSize().fX, | 139 fResults->bench(fBenchmark->getUniqueName(), fBenchmark->getSize().fX, |
| 140 fBenchmark->getSize().fY); | 140 fBenchmark->getSize().fY); |
| 141 |
| 142 fBenchmark->delayedSetup(); |
| 143 fBenchmark->preTimingHooks(canvas); |
| 141 return true; | 144 return true; |
| 142 } | 145 } |
| 143 | 146 |
| 144 void VisualLightweightBenchModule::draw(SkCanvas* canvas) { | 147 void VisualLightweightBenchModule::draw(SkCanvas* canvas) { |
| 145 if (!this->advanceRecordIfNecessary(canvas)) { | 148 if (!this->advanceRecordIfNecessary(canvas)) { |
| 146 SkDebugf("Exiting VisualBench successfully\n"); | 149 SkDebugf("Exiting VisualBench successfully\n"); |
| 147 fOwner->closeWindow(); | 150 fOwner->closeWindow(); |
| 148 return; | 151 return; |
| 149 } | 152 } |
| 153 |
| 154 if (fHasBeenReset) { |
| 155 fHasBeenReset = false; |
| 156 fBenchmark->preTimingHooks(canvas); |
| 157 } |
| 158 |
| 150 this->renderFrame(canvas); | 159 this->renderFrame(canvas); |
| 151 TimingStateMachine::ParentEvents event = fTSM.nextFrame(canvas, fBenchmark); | 160 TimingStateMachine::ParentEvents event = fTSM.nextFrame(true); |
| 152 switch (event) { | 161 switch (event) { |
| 153 case TimingStateMachine::kReset_ParentEvents: | 162 case TimingStateMachine::kReset_ParentEvents: |
| 163 fBenchmark->postTimingHooks(canvas); |
| 154 fOwner->reset(); | 164 fOwner->reset(); |
| 165 fHasBeenReset = true; |
| 155 break; | 166 break; |
| 156 case TimingStateMachine::kTiming_ParentEvents: | 167 case TimingStateMachine::kTiming_ParentEvents: |
| 157 break; | 168 break; |
| 158 case TimingStateMachine::kTimingFinished_ParentEvents: | 169 case TimingStateMachine::kTimingFinished_ParentEvents: |
| 170 fBenchmark->postTimingHooks(canvas); |
| 159 fOwner->reset(); | 171 fOwner->reset(); |
| 160 fRecords.back().fMeasurements.push_back(fTSM.lastMeasurement()); | 172 fRecords.back().fMeasurements.push_back(fTSM.lastMeasurement()); |
| 161 if (++fCurrentSample > FLAGS_samples) { | 173 if (++fCurrentSample > FLAGS_samples) { |
| 162 this->printStats(); | 174 this->printStats(); |
| 163 fTSM.nextBenchmark(canvas, fBenchmark); | 175 fTSM.nextBenchmark(canvas, fBenchmark); |
| 164 fCurrentSample = 0; | 176 fCurrentSample = 0; |
| 165 fBenchmark.reset(nullptr); | 177 fBenchmark.reset(nullptr); |
| 166 } else { | 178 } else { |
| 167 fTSM.nextSampleWithPrewarm(); | 179 fHasBeenReset = true; |
| 168 } | 180 } |
| 169 break; | 181 break; |
| 170 } | 182 } |
| 171 } | 183 } |
| 172 | 184 |
| 173 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { | 185 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { |
| 174 return true; | 186 return true; |
| 175 } | 187 } |
| OLD | NEW |