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

Side by Side Diff: bench/nanobench.cpp

Issue 709473002: Detect loops overflow for gpu benches. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 30 Created 6 years, 1 month 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 | « no previous file | 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 2014 Google Inc. 2 * Copyright 2014 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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "Benchmark.h" 10 #include "Benchmark.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 static int detect_forever_loops(int loops) { 118 static int detect_forever_loops(int loops) {
119 // look for a magic run-forever value 119 // look for a magic run-forever value
120 if (loops < 0) { 120 if (loops < 0) {
121 loops = SK_MaxS32; 121 loops = SK_MaxS32;
122 } 122 }
123 return loops; 123 return loops;
124 } 124 }
125 125
126 static int clamp_loops(int loops) { 126 static int clamp_loops(int loops) {
127 if (loops < 1) { 127 if (loops < 1) {
128 SkDebugf("ERROR: clamping loops from %d to 1.\n", loops); 128 SkDebugf("ERROR: clamping loops from %d to 1. "
129 "There's probably something wrong with the bench.\n", loops);
129 return 1; 130 return 1;
130 } 131 }
131 if (loops > FLAGS_maxLoops) { 132 if (loops > FLAGS_maxLoops) {
132 SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loo ps, FLAGS_maxLoops); 133 SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loo ps, FLAGS_maxLoops);
133 return FLAGS_maxLoops; 134 return FLAGS_maxLoops;
134 } 135 }
135 return loops; 136 return loops;
136 } 137 }
137 138
138 static bool write_canvas_png(SkCanvas* canvas, const SkString& filename) { 139 static bool write_canvas_png(SkCanvas* canvas, const SkString& filename) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 gl->makeCurrent(); 222 gl->makeCurrent();
222 // Make sure we're done with whatever came before. 223 // Make sure we're done with whatever came before.
223 SK_GL(*gl, Finish()); 224 SK_GL(*gl, Finish());
224 225
225 // First, figure out how many loops it'll take to get a frame up to FLAGS_gp uMs. 226 // First, figure out how many loops it'll take to get a frame up to FLAGS_gp uMs.
226 int loops = FLAGS_loops; 227 int loops = FLAGS_loops;
227 if (kAutoTuneLoops == loops) { 228 if (kAutoTuneLoops == loops) {
228 loops = 1; 229 loops = 1;
229 double elapsed = 0; 230 double elapsed = 0;
230 do { 231 do {
232 if (1<<30 == loops) {
233 // We're about to wrap. Something's wrong with the bench.
234 loops = 0;
235 break;
236 }
231 loops *= 2; 237 loops *= 2;
232 // If the GPU lets frames lag at all, we need to make sure we're tim ing 238 // If the GPU lets frames lag at all, we need to make sure we're tim ing
233 // _this_ round, not still timing last round. We force this by loop ing 239 // _this_ round, not still timing last round. We force this by loop ing
234 // more times than any reasonable GPU will allow frames to lag. 240 // more times than any reasonable GPU will allow frames to lag.
235 for (int i = 0; i < FLAGS_gpuFrameLag; i++) { 241 for (int i = 0; i < FLAGS_gpuFrameLag; i++) {
236 elapsed = time(loops, bench, canvas, gl); 242 elapsed = time(loops, bench, canvas, gl);
237 } 243 }
238 } while (elapsed < FLAGS_gpuMs); 244 } while (elapsed < FLAGS_gpuMs);
239 245
240 // We've overshot at least a little. Scale back linearly. 246 // We've overshot at least a little. Scale back linearly.
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 744
739 return 0; 745 return 0;
740 } 746 }
741 747
742 #if !defined SK_BUILD_FOR_IOS 748 #if !defined SK_BUILD_FOR_IOS
743 int main(int argc, char** argv) { 749 int main(int argc, char** argv) {
744 SkCommandLineFlags::Parse(argc, argv); 750 SkCommandLineFlags::Parse(argc, argv);
745 return nanobench_main(); 751 return nanobench_main();
746 } 752 }
747 #endif 753 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698