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

Side by Side Diff: bench/nanobench.cpp

Issue 345063004: Hey, maybe we should _call_ glFinish. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 | « 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 return loops; 106 return loops;
107 } 107 }
108 108
109 #if SK_SUPPORT_GPU 109 #if SK_SUPPORT_GPU
110 static int gpu_bench(SkGLContextHelper* gl, 110 static int gpu_bench(SkGLContextHelper* gl,
111 Benchmark* bench, 111 Benchmark* bench,
112 SkCanvas* canvas, 112 SkCanvas* canvas,
113 double* samples) { 113 double* samples) {
114 // Make sure we're done with whatever came before. 114 // Make sure we're done with whatever came before.
115 SK_GL(*gl, Finish); 115 SK_GL(*gl, Finish());
116 116
117 // First, figure out how many loops it'll take to get a frame up to FLAGS_gp uMs. 117 // First, figure out how many loops it'll take to get a frame up to FLAGS_gp uMs.
118 int loops = 1; 118 int loops = 1;
119 double elapsed = 0; 119 double elapsed = 0;
120 do { 120 do {
121 loops *= 2; 121 loops *= 2;
122 // If the GPU lets frames lag at all, we need to make sure we're timing 122 // If the GPU lets frames lag at all, we need to make sure we're timing
123 // _this_ round, not still timing last round. We force this by looping 123 // _this_ round, not still timing last round. We force this by looping
124 // more times than any reasonable GPU will allow frames to lag. 124 // more times than any reasonable GPU will allow frames to lag.
125 for (int i = 0; i < FLAGS_gpuFrameLag; i++) { 125 for (int i = 0; i < FLAGS_gpuFrameLag; i++) {
126 elapsed = time(loops, bench, canvas, gl); 126 elapsed = time(loops, bench, canvas, gl);
127 } 127 }
128 } while (elapsed < FLAGS_gpuMs); 128 } while (elapsed < FLAGS_gpuMs);
129 129
130 // We've overshot at least a little. Scale back linearly. 130 // We've overshot at least a little. Scale back linearly.
131 loops = (int)ceil(loops * FLAGS_gpuMs / elapsed); 131 loops = (int)ceil(loops * FLAGS_gpuMs / elapsed);
132 132
133 // Might as well make sure we're not still timing our calibration. 133 // Might as well make sure we're not still timing our calibration.
134 SK_GL(*gl, Finish); 134 SK_GL(*gl, Finish());
135 135
136 // Pretty much the same deal as the calibration: do some warmup to make 136 // Pretty much the same deal as the calibration: do some warmup to make
137 // sure we're timing steady-state pipelined frames. 137 // sure we're timing steady-state pipelined frames.
138 for (int i = 0; i < FLAGS_gpuFrameLag; i++) { 138 for (int i = 0; i < FLAGS_gpuFrameLag; i++) {
139 time(loops, bench, canvas, gl); 139 time(loops, bench, canvas, gl);
140 } 140 }
141 141
142 // Now, actually do the timing! 142 // Now, actually do the timing!
143 for (int i = 0; i < FLAGS_samples; i++) { 143 for (int i = 0; i < FLAGS_samples; i++) {
144 samples[i] = time(loops, bench, canvas, gl) / loops; 144 samples[i] = time(loops, bench, canvas, gl) / loops;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 288
289 return 0; 289 return 0;
290 } 290 }
291 291
292 #if !defined SK_BUILD_FOR_IOS 292 #if !defined SK_BUILD_FOR_IOS
293 int main(int argc, char * const argv[]) { 293 int main(int argc, char * const argv[]) {
294 return tool_main(argc, (char**) argv); 294 return tool_main(argc, (char**) argv);
295 } 295 }
296 #endif 296 #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