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

Side by Side Diff: bench/nanobench.cpp

Issue 398483005: Add --resetGpuContext to both DM and nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 | dm/DMGpuSupport.h » ('j') | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 DEFINE_bool2(verbose, v, false, "Print all samples."); 42 DEFINE_bool2(verbose, v, false, "Print all samples.");
43 DEFINE_string(config, "nonrendering 8888 gpu", "Configs to measure. Options: " 43 DEFINE_string(config, "nonrendering 8888 gpu", "Configs to measure. Options: "
44 "565 8888 gpu nonrendering debug nullgpu msaa4 msaa16 nvprmsaa4 nv prmsaa16 angle"); 44 "565 8888 gpu nonrendering debug nullgpu msaa4 msaa16 nvprmsaa4 nv prmsaa16 angle");
45 DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU."); 45 DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
46 DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allow s to lag."); 46 DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allow s to lag.");
47 47
48 DEFINE_bool(cpu, true, "Master switch for CPU-bound work."); 48 DEFINE_bool(cpu, true, "Master switch for CPU-bound work.");
49 DEFINE_bool(gpu, true, "Master switch for GPU-bound work."); 49 DEFINE_bool(gpu, true, "Master switch for GPU-bound work.");
50 50
51 DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); 51 DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
52 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each benc h.");
52 53
53 54
54 static SkString humanize(double ms) { 55 static SkString humanize(double ms) {
55 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3); 56 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3);
56 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6); 57 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6);
57 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3); 58 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3);
58 return SkStringPrintf("%.3gms", ms); 59 return SkStringPrintf("%.3gms", ms);
59 } 60 }
60 61
61 static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContextHel per* gl) { 62 static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContextHel per* gl) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 t->surface.reset(code); \ 208 t->surface.reset(code); \
208 targets->push(t); \ 209 targets->push(t); \
209 } 210 }
210 if (FLAGS_cpu) { 211 if (FLAGS_cpu) {
211 CPU_TARGET(nonrendering, kNonRendering_Backend, NULL) 212 CPU_TARGET(nonrendering, kNonRendering_Backend, NULL)
212 CPU_TARGET(8888, kRaster_Backend, SkSurface::NewRaster(_8888)) 213 CPU_TARGET(8888, kRaster_Backend, SkSurface::NewRaster(_8888))
213 CPU_TARGET(565, kRaster_Backend, SkSurface::NewRaster(_565)) 214 CPU_TARGET(565, kRaster_Backend, SkSurface::NewRaster(_565))
214 } 215 }
215 216
216 #if SK_SUPPORT_GPU 217 #if SK_SUPPORT_GPU
218 if (FLAGS_resetGpuContext) {
219 gGrFactory.destroyContexts();
220 }
221
217 #define GPU_TARGET(config, ctxType, info, samples) \ 222 #define GPU_TARGET(config, ctxType, info, samples) \
218 if (Target* t = is_enabled(bench, Benchmark::kGPU_Backend, #config)) { \ 223 if (Target* t = is_enabled(bench, Benchmark::kGPU_Backend, #config)) { \
219 t->surface.reset(SkSurface::NewRenderTarget(gGrFactory.get(ctxType), info, samples)); \ 224 t->surface.reset(SkSurface::NewRenderTarget(gGrFactory.get(ctxType), info, samples)); \
220 t->gl = gGrFactory.getGLContext(ctxType); \ 225 t->gl = gGrFactory.getGLContext(ctxType); \
221 targets->push(t); \ 226 targets->push(t); \
222 } 227 }
223 if (FLAGS_gpu) { 228 if (FLAGS_gpu) {
224 GPU_TARGET(gpu, GrContextFactory::kNative_GLContextType, _8888, 0) 229 GPU_TARGET(gpu, GrContextFactory::kNative_GLContextType, _8888, 0)
225 GPU_TARGET(msaa4, GrContextFactory::kNative_GLContextType, _8888, 4) 230 GPU_TARGET(msaa4, GrContextFactory::kNative_GLContextType, _8888, 4)
226 GPU_TARGET(msaa16, GrContextFactory::kNative_GLContextType, _8888, 16) 231 GPU_TARGET(msaa16, GrContextFactory::kNative_GLContextType, _8888, 16)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 359 }
355 360
356 return 0; 361 return 0;
357 } 362 }
358 363
359 #if !defined SK_BUILD_FOR_IOS 364 #if !defined SK_BUILD_FOR_IOS
360 int main(int argc, char * const argv[]) { 365 int main(int argc, char * const argv[]) {
361 return tool_main(argc, (char**) argv); 366 return tool_main(argc, (char**) argv);
362 } 367 }
363 #endif 368 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMGpuSupport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698