Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2484)

Side by Side Diff: tools/VisualBench/VisualLightweightBenchModule.cpp

Issue 1363663004: stop scaling loops and improve warmup bench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: transparent Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/VisualBench/VisualLightweightBenchModule.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 40
41 static SkString humanize(double ms) { 41 static SkString humanize(double ms) {
42 if (FLAGS_verbose) { 42 if (FLAGS_verbose) {
43 return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); 43 return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
44 } 44 }
45 return HumanizeMs(ms); 45 return HumanizeMs(ms);
46 } 46 }
47 47
48 #define HUMANIZE(time) humanize(time).c_str() 48 #define HUMANIZE(time) humanize(time).c_str()
49 49
50 // A trivial bench to warm up the gpu 50 // We draw a big nonAA path to warmup the gpu / cpu
51 class WarmupBench : public Benchmark { 51 class WarmupBench : public Benchmark {
52 public: 52 public:
53 WarmupBench() {
54 make_path(fPath);
55 }
53 private: 56 private:
57 static void make_path(SkPath& path) {
58 #include "BigPathBench.inc"
59 }
54 const char* onGetName() override { return "warmupbench"; } 60 const char* onGetName() override { return "warmupbench"; }
55 void onDraw(const int loops, SkCanvas* canvas) override { 61 void onDraw(const int loops, SkCanvas* canvas) override {
62 SkPaint paint;
63 paint.setStyle(SkPaint::kStroke_Style);
64 paint.setStrokeWidth(2);
56 for (int i = 0; i < loops; i++) { 65 for (int i = 0; i < loops; i++) {
57 sk_tool_utils::draw_checkerboard(canvas, 0xffffffff, 0xffc6c3c6, 10) ; 66 canvas->drawPath(fPath, paint);
58 } 67 }
59 } 68 }
69 SkPath fPath;
60 }; 70 };
61 71
62 VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner) 72 VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner)
63 : fCurrentSample(0) 73 : fCurrentSample(0)
64 , fCurrentFrame(0) 74 , fCurrentFrame(0)
65 , fLoops(1) 75 , fLoops(1)
66 , fState(kWarmup_State) 76 , fState(kWarmup_State)
67 , fBenchmark(nullptr) 77 , fBenchmark(nullptr)
68 , fOwner(SkRef(owner)) 78 , fOwner(SkRef(owner))
69 , fResults(new ResultsWriter) { 79 , fResults(new ResultsWriter) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 HUMANIZE(stats.mean), 146 HUMANIZE(stats.mean),
137 HUMANIZE(stats.max), 147 HUMANIZE(stats.max),
138 stdDevPercent, 148 stdDevPercent,
139 stats.plot.c_str(), 149 stats.plot.c_str(),
140 shortName); 150 shortName);
141 } 151 }
142 } 152 }
143 153
144 bool VisualLightweightBenchModule::advanceRecordIfNecessary(SkCanvas* canvas) { 154 bool VisualLightweightBenchModule::advanceRecordIfNecessary(SkCanvas* canvas) {
145 if (!fBenchmark && fState == kWarmup_State) { 155 if (!fBenchmark && fState == kWarmup_State) {
156 fOwner->clear(canvas, SK_ColorWHITE, 2);
146 fBenchmark.reset(new WarmupBench); 157 fBenchmark.reset(new WarmupBench);
147 return true; 158 return true;
148 } 159 }
149 160
150 if (fBenchmark) { 161 if (fBenchmark) {
151 return true; 162 return true;
152 } 163 }
153 164
154 fBenchmark.reset(fBenchmarkStream->next()); 165 fBenchmark.reset(fBenchmarkStream->next());
155 if (!fBenchmark) { 166 if (!fBenchmark) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 fTimer.end(); 263 fTimer.end();
253 return fTimer.fWall; 264 return fTimer.fWall;
254 } 265 }
255 266
256 void VisualLightweightBenchModule::resetTimingState() { 267 void VisualLightweightBenchModule::resetTimingState() {
257 fCurrentFrame = 0; 268 fCurrentFrame = 0;
258 fTimer = WallTimer(); 269 fTimer = WallTimer();
259 fOwner->reset(); 270 fOwner->reset();
260 } 271 }
261 272
262 void VisualLightweightBenchModule::scaleLoops(double elapsedMs) {
263 // Scale back the number of loops
264 fLoops = (int)ceil(fLoops * FLAGS_loopMs / elapsedMs);
265 }
266
267 inline void VisualLightweightBenchModule::tuneLoops() { 273 inline void VisualLightweightBenchModule::tuneLoops() {
268 if (1 << 30 == fLoops) { 274 if (1 << 30 == fLoops) {
269 // We're about to wrap. Something's wrong with the bench. 275 // We're about to wrap. Something's wrong with the bench.
270 SkDebugf("InnerLoops wrapped\n"); 276 SkDebugf("InnerLoops wrapped\n");
271 fLoops = 1; 277 fLoops = 1;
272 } else { 278 } else {
273 double elapsedMs = this->elapsed(); 279 double elapsedMs = this->elapsed();
274 if (elapsedMs > FLAGS_loopMs) { 280 if (elapsedMs > FLAGS_loopMs) {
275 this->scaleLoops(elapsedMs);
276 this->nextState(kPreWarmTimingPerCanvasPreDraw_State); 281 this->nextState(kPreWarmTimingPerCanvasPreDraw_State);
277 } else { 282 } else {
278 fLoops *= 2; 283 fLoops *= 2;
279 this->nextState(kPreWarmLoops_State); 284 this->nextState(kPreWarmLoops_State);
280 } 285 }
281 this->resetTimingState(); 286 this->resetTimingState();
282 } 287 }
283 } 288 }
284 289
285 void VisualLightweightBenchModule::recordMeasurement() { 290 void VisualLightweightBenchModule::recordMeasurement() {
(...skipping 20 matching lines...) Expand all
306 } 311 }
307 this->resetTimingState(); 312 this->resetTimingState();
308 } else { 313 } else {
309 fCurrentFrame++; 314 fCurrentFrame++;
310 } 315 }
311 } 316 }
312 317
313 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { 318 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) {
314 return true; 319 return true;
315 } 320 }
OLDNEW
« no previous file with comments | « tools/VisualBench/VisualLightweightBenchModule.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698