OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |