blob: a3cd4956deae49c5103bcab14e6537620f91c7a6 [file] [log] [blame]
mtkleinf3723212014-06-25 14:08:00 -07001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
mtkleinbb6a0282014-07-01 08:43:42 -07008#include <ctype.h>
9
mtkleinf3723212014-06-25 14:08:00 -070010#include "Benchmark.h"
11#include "CrashHandler.h"
mtklein60317d0f2014-07-14 11:30:37 -070012#include "ResultsWriter.h"
mtkleinf3723212014-06-25 14:08:00 -070013#include "Stats.h"
14#include "Timer.h"
15
16#include "SkCanvas.h"
caryclark17f0b6d2014-07-22 10:15:34 -070017#include "SkCommonFlags.h"
mtkleinf3723212014-06-25 14:08:00 -070018#include "SkForceLinking.h"
19#include "SkGraphics.h"
20#include "SkString.h"
21#include "SkSurface.h"
22
mtkleinbb6a0282014-07-01 08:43:42 -070023#if SK_SUPPORT_GPU
jcgregoriobf5e5232014-07-17 13:14:16 -070024 #include "gl/GrGLDefines.h"
mtkleinbb6a0282014-07-01 08:43:42 -070025 #include "GrContextFactory.h"
26 GrContextFactory gGrFactory;
27#endif
28
mtkleinf3723212014-06-25 14:08:00 -070029__SK_FORCE_IMAGE_DECODER_LINKING;
30
mtkleina189ccd2014-07-14 12:28:47 -070031#if SK_DEBUG
32 DEFINE_bool(runOnce, true, "Run each benchmark just once?");
33#else
34 DEFINE_bool(runOnce, false, "Run each benchmark just once?");
35#endif
36
mtkleinf3723212014-06-25 14:08:00 -070037DEFINE_int32(samples, 10, "Number of samples to measure for each bench.");
38DEFINE_int32(overheadLoops, 100000, "Loops to estimate timer overhead.");
39DEFINE_double(overheadGoal, 0.0001,
40 "Loop until timer overhead is at most this fraction of our measurments.");
mtkleinbb6a0282014-07-01 08:43:42 -070041DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
42DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allows to lag.");
mtkleinf3723212014-06-25 14:08:00 -070043
mtklein60317d0f2014-07-14 11:30:37 -070044DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
mtklein55b0ffc2014-07-17 08:38:23 -070045DEFINE_int32(maxCalibrationAttempts, 3,
46 "Try up to this many times to guess loops for a bench, or skip the bench.");
47DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this.");
jcgregoriobf5e5232014-07-17 13:14:16 -070048DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON.");
49DEFINE_string(gitHash, "", "Git hash to add to JSON.");
mtklein60317d0f2014-07-14 11:30:37 -070050
mtkleinf3723212014-06-25 14:08:00 -070051static SkString humanize(double ms) {
52 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3);
53 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6);
mtklein62386882014-07-15 10:30:31 -070054#ifdef SK_BUILD_FOR_WIN
55 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3);
56#else
mtkleinf3723212014-06-25 14:08:00 -070057 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3);
mtklein62386882014-07-15 10:30:31 -070058#endif
mtkleinf3723212014-06-25 14:08:00 -070059 return SkStringPrintf("%.3gms", ms);
60}
mtklein55b0ffc2014-07-17 08:38:23 -070061#define HUMANIZE(ms) humanize(ms).c_str()
mtkleinf3723212014-06-25 14:08:00 -070062
mtkleinbb6a0282014-07-01 08:43:42 -070063static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContextHelper* gl) {
64 WallTimer timer;
65 timer.start();
66 if (bench) {
67 bench->draw(loops, canvas);
68 }
69 if (canvas) {
70 canvas->flush();
71 }
72#if SK_SUPPORT_GPU
73 if (gl) {
74 SK_GL(*gl, Flush());
75 gl->swapBuffers();
76 }
77#endif
78 timer.end();
79 return timer.fWall;
80}
81
mtkleinf3723212014-06-25 14:08:00 -070082static double estimate_timer_overhead() {
83 double overhead = 0;
mtkleinf3723212014-06-25 14:08:00 -070084 for (int i = 0; i < FLAGS_overheadLoops; i++) {
mtkleinbb6a0282014-07-01 08:43:42 -070085 overhead += time(1, NULL, NULL, NULL);
mtkleinf3723212014-06-25 14:08:00 -070086 }
87 return overhead / FLAGS_overheadLoops;
88}
89
mtklein55b0ffc2014-07-17 08:38:23 -070090static int clamp_loops(int loops) {
91 if (loops < 1) {
92 SkDebugf("ERROR: clamping loops from %d to 1.\n", loops);
93 return 1;
94 }
95 if (loops > FLAGS_maxLoops) {
96 SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loops, FLAGS_maxLoops);
97 return FLAGS_maxLoops;
98 }
99 return loops;
100}
101
mtkleinbb6a0282014-07-01 08:43:42 -0700102static int cpu_bench(const double overhead, Benchmark* bench, SkCanvas* canvas, double* samples) {
103 // First figure out approximately how many loops of bench it takes to make overhead negligible.
104 double bench_plus_overhead;
mtklein55b0ffc2014-07-17 08:38:23 -0700105 int round = 0;
mtkleinf3723212014-06-25 14:08:00 -0700106 do {
mtkleinbb6a0282014-07-01 08:43:42 -0700107 bench_plus_overhead = time(1, bench, canvas, NULL);
mtklein55b0ffc2014-07-17 08:38:23 -0700108 if (++round == FLAGS_maxCalibrationAttempts) {
109 SkDebugf("WARNING: Can't estimate loops for %s (%s vs. %s); skipping.\n",
110 bench->getName(), HUMANIZE(bench_plus_overhead), HUMANIZE(overhead));
111 return 0;
112 }
Mike Kleine3631362014-07-15 17:56:37 -0400113 } while (bench_plus_overhead < overhead);
mtkleinf3723212014-06-25 14:08:00 -0700114
mtkleinbb6a0282014-07-01 08:43:42 -0700115 // Later we'll just start and stop the timer once but loop N times.
mtkleinf3723212014-06-25 14:08:00 -0700116 // We'll pick N to make timer overhead negligible:
117 //
mtkleinbb6a0282014-07-01 08:43:42 -0700118 // overhead
119 // ------------------------- < FLAGS_overheadGoal
120 // overhead + N * Bench Time
mtkleinf3723212014-06-25 14:08:00 -0700121 //
mtkleinbb6a0282014-07-01 08:43:42 -0700122 // where bench_plus_overhead ≈ overhead + Bench Time.
mtkleinf3723212014-06-25 14:08:00 -0700123 //
124 // Doing some math, we get:
125 //
mtkleinbb6a0282014-07-01 08:43:42 -0700126 // (overhead / FLAGS_overheadGoal) - overhead
127 // ------------------------------------------ < N
128 // bench_plus_overhead - overhead)
mtkleinf3723212014-06-25 14:08:00 -0700129 //
130 // Luckily, this also works well in practice. :)
131 const double numer = overhead / FLAGS_overheadGoal - overhead;
mtkleinbb6a0282014-07-01 08:43:42 -0700132 const double denom = bench_plus_overhead - overhead;
mtklein55b0ffc2014-07-17 08:38:23 -0700133 const int loops = clamp_loops(FLAGS_runOnce ? 1 : (int)ceil(numer / denom));
mtkleinbb6a0282014-07-01 08:43:42 -0700134
135 for (int i = 0; i < FLAGS_samples; i++) {
136 samples[i] = time(loops, bench, canvas, NULL) / loops;
137 }
138 return loops;
mtkleinf3723212014-06-25 14:08:00 -0700139}
140
mtkleinbb6a0282014-07-01 08:43:42 -0700141#if SK_SUPPORT_GPU
142static int gpu_bench(SkGLContextHelper* gl,
143 Benchmark* bench,
144 SkCanvas* canvas,
145 double* samples) {
146 // Make sure we're done with whatever came before.
mtklein9bc86ed2014-07-01 10:02:42 -0700147 SK_GL(*gl, Finish());
mtkleinbb6a0282014-07-01 08:43:42 -0700148
149 // First, figure out how many loops it'll take to get a frame up to FLAGS_gpuMs.
150 int loops = 1;
mtkleina189ccd2014-07-14 12:28:47 -0700151 if (!FLAGS_runOnce) {
152 double elapsed = 0;
153 do {
154 loops *= 2;
155 // If the GPU lets frames lag at all, we need to make sure we're timing
156 // _this_ round, not still timing last round. We force this by looping
157 // more times than any reasonable GPU will allow frames to lag.
158 for (int i = 0; i < FLAGS_gpuFrameLag; i++) {
159 elapsed = time(loops, bench, canvas, gl);
160 }
161 } while (elapsed < FLAGS_gpuMs);
mtkleinbb6a0282014-07-01 08:43:42 -0700162
mtkleina189ccd2014-07-14 12:28:47 -0700163 // We've overshot at least a little. Scale back linearly.
164 loops = (int)ceil(loops * FLAGS_gpuMs / elapsed);
mtkleinbb6a0282014-07-01 08:43:42 -0700165
mtkleina189ccd2014-07-14 12:28:47 -0700166 // Might as well make sure we're not still timing our calibration.
167 SK_GL(*gl, Finish());
168 }
mtklein55b0ffc2014-07-17 08:38:23 -0700169 loops = clamp_loops(loops);
mtkleinbb6a0282014-07-01 08:43:42 -0700170
171 // Pretty much the same deal as the calibration: do some warmup to make
172 // sure we're timing steady-state pipelined frames.
173 for (int i = 0; i < FLAGS_gpuFrameLag; i++) {
174 time(loops, bench, canvas, gl);
mtkleinf3723212014-06-25 14:08:00 -0700175 }
mtkleinbb6a0282014-07-01 08:43:42 -0700176
177 // Now, actually do the timing!
178 for (int i = 0; i < FLAGS_samples; i++) {
179 samples[i] = time(loops, bench, canvas, gl) / loops;
180 }
181 return loops;
182}
183#endif
184
185static SkString to_lower(const char* str) {
186 SkString lower(str);
187 for (size_t i = 0; i < lower.size(); i++) {
188 lower[i] = tolower(lower[i]);
189 }
190 return lower;
mtkleinf3723212014-06-25 14:08:00 -0700191}
192
mtkleinbb6a0282014-07-01 08:43:42 -0700193struct Target {
194 const char* config;
195 Benchmark::Backend backend;
196 SkAutoTDelete<SkSurface> surface;
197#if SK_SUPPORT_GPU
198 SkGLContextHelper* gl;
199#endif
200};
mtkleinf3723212014-06-25 14:08:00 -0700201
mtkleinbb6a0282014-07-01 08:43:42 -0700202// If bench is enabled for backend/config, returns a Target* for them, otherwise NULL.
203static Target* is_enabled(Benchmark* bench, Benchmark::Backend backend, const char* config) {
204 if (!bench->isSuitableFor(backend)) {
205 return NULL;
mtkleinf3723212014-06-25 14:08:00 -0700206 }
207
mtkleinbb6a0282014-07-01 08:43:42 -0700208 for (int i = 0; i < FLAGS_config.count(); i++) {
209 if (to_lower(FLAGS_config[i]).equals(config)) {
210 Target* target = new Target;
211 target->config = config;
212 target->backend = backend;
213 return target;
mtkleinf3723212014-06-25 14:08:00 -0700214 }
215 }
mtkleinbb6a0282014-07-01 08:43:42 -0700216 return NULL;
217}
218
219// Append all targets that are suitable for bench.
220static void create_targets(Benchmark* bench, SkTDArray<Target*>* targets) {
221 const int w = bench->getSize().fX,
222 h = bench->getSize().fY;
223 const SkImageInfo _8888 = { w, h, kN32_SkColorType, kPremul_SkAlphaType },
224 _565 = { w, h, kRGB_565_SkColorType, kOpaque_SkAlphaType };
225
226 #define CPU_TARGET(config, backend, code) \
227 if (Target* t = is_enabled(bench, Benchmark::backend, #config)) { \
228 t->surface.reset(code); \
229 targets->push(t); \
230 }
mtklein40b32be2014-07-09 08:46:49 -0700231 if (FLAGS_cpu) {
232 CPU_TARGET(nonrendering, kNonRendering_Backend, NULL)
233 CPU_TARGET(8888, kRaster_Backend, SkSurface::NewRaster(_8888))
234 CPU_TARGET(565, kRaster_Backend, SkSurface::NewRaster(_565))
235 }
mtkleinbb6a0282014-07-01 08:43:42 -0700236
237#if SK_SUPPORT_GPU
mtklein1e319f72014-07-15 08:27:06 -0700238
mtkleinbb6a0282014-07-01 08:43:42 -0700239 #define GPU_TARGET(config, ctxType, info, samples) \
240 if (Target* t = is_enabled(bench, Benchmark::kGPU_Backend, #config)) { \
241 t->surface.reset(SkSurface::NewRenderTarget(gGrFactory.get(ctxType), info, samples)); \
242 t->gl = gGrFactory.getGLContext(ctxType); \
243 targets->push(t); \
244 }
mtklein40b32be2014-07-09 08:46:49 -0700245 if (FLAGS_gpu) {
246 GPU_TARGET(gpu, GrContextFactory::kNative_GLContextType, _8888, 0)
247 GPU_TARGET(msaa4, GrContextFactory::kNative_GLContextType, _8888, 4)
248 GPU_TARGET(msaa16, GrContextFactory::kNative_GLContextType, _8888, 16)
249 GPU_TARGET(nvprmsaa4, GrContextFactory::kNVPR_GLContextType, _8888, 4)
250 GPU_TARGET(nvprmsaa16, GrContextFactory::kNVPR_GLContextType, _8888, 16)
251 GPU_TARGET(debug, GrContextFactory::kDebug_GLContextType, _8888, 0)
252 GPU_TARGET(nullgpu, GrContextFactory::kNull_GLContextType, _8888, 0)
253 #if SK_ANGLE
254 GPU_TARGET(angle, GrContextFactory::kANGLE_GLContextType, _8888, 0)
255 #endif
256 }
mtkleinbb6a0282014-07-01 08:43:42 -0700257#endif
mtkleinf3723212014-06-25 14:08:00 -0700258}
259
mtklein60317d0f2014-07-14 11:30:37 -0700260static void fill_static_options(ResultsWriter* log) {
261#if defined(SK_BUILD_FOR_WIN32)
262 log->option("system", "WIN32");
263#elif defined(SK_BUILD_FOR_MAC)
264 log->option("system", "MAC");
265#elif defined(SK_BUILD_FOR_ANDROID)
266 log->option("system", "ANDROID");
267#elif defined(SK_BUILD_FOR_UNIX)
268 log->option("system", "UNIX");
269#else
270 log->option("system", "other");
271#endif
mtklein60317d0f2014-07-14 11:30:37 -0700272}
273
jcgregoriobf5e5232014-07-17 13:14:16 -0700274#if SK_SUPPORT_GPU
275static void fill_gpu_options(ResultsWriter* log, SkGLContextHelper* ctx) {
jcgregorio05c45602014-07-17 13:54:36 -0700276 const GrGLubyte* version;
jcgregoriobf5e5232014-07-17 13:14:16 -0700277 SK_GL_RET(*ctx, version, GetString(GR_GL_VERSION));
278 log->configOption("GL_VERSION", (const char*)(version));
279
280 SK_GL_RET(*ctx, version, GetString(GR_GL_RENDERER));
281 log->configOption("GL_RENDERER", (const char*) version);
282
283 SK_GL_RET(*ctx, version, GetString(GR_GL_VENDOR));
284 log->configOption("GL_VENDOR", (const char*) version);
285
286 SK_GL_RET(*ctx, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
287 log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
288}
289#endif
290
caryclark17f0b6d2014-07-22 10:15:34 -0700291int nanobench_main();
292int nanobench_main() {
mtkleinf3723212014-06-25 14:08:00 -0700293 SetupCrashHandler();
294 SkAutoGraphics ag;
mtkleinf3723212014-06-25 14:08:00 -0700295
mtkleina189ccd2014-07-14 12:28:47 -0700296 if (FLAGS_runOnce) {
297 FLAGS_samples = 1;
298 FLAGS_gpuFrameLag = 0;
299 }
300
mtklein60317d0f2014-07-14 11:30:37 -0700301 MultiResultsWriter log;
jcgregoriobf5e5232014-07-17 13:14:16 -0700302 SkAutoTDelete<NanoJSONResultsWriter> json;
mtklein60317d0f2014-07-14 11:30:37 -0700303 if (!FLAGS_outResultsFile.isEmpty()) {
jcgregoriobf5e5232014-07-17 13:14:16 -0700304 const char* gitHash = FLAGS_gitHash.isEmpty() ? "unknown-revision" : FLAGS_gitHash[0];
305 json.reset(SkNEW(NanoJSONResultsWriter(FLAGS_outResultsFile[0], gitHash)));
mtklein60317d0f2014-07-14 11:30:37 -0700306 log.add(json.get());
307 }
308 CallEnd<MultiResultsWriter> ender(log);
jcgregoriobf5e5232014-07-17 13:14:16 -0700309
310 if (1 == FLAGS_key.count() % 2) {
311 SkDebugf("ERROR: --key must be passed with an even number of arguments.\n");
312 return 1;
313 }
314 for (int i = 1; i < FLAGS_key.count(); i += 2) {
315 log.key(FLAGS_key[i-1], FLAGS_key[i]);
316 }
mtklein60317d0f2014-07-14 11:30:37 -0700317 fill_static_options(&log);
318
mtkleinf3723212014-06-25 14:08:00 -0700319 const double overhead = estimate_timer_overhead();
mtklein55b0ffc2014-07-17 08:38:23 -0700320 SkDebugf("Timer overhead: %s\n", HUMANIZE(overhead));
Mike Klein91294772014-07-16 19:59:32 -0400321
mtkleinbb6a0282014-07-01 08:43:42 -0700322 SkAutoTMalloc<double> samples(FLAGS_samples);
323
mtkleina189ccd2014-07-14 12:28:47 -0700324 if (FLAGS_runOnce) {
325 SkDebugf("--runOnce is true; times would only be misleading so we won't print them.\n");
326 } else if (FLAGS_verbose) {
mtkleinf3723212014-06-25 14:08:00 -0700327 // No header.
328 } else if (FLAGS_quiet) {
mtklein40b32be2014-07-09 08:46:49 -0700329 SkDebugf("median\tbench\tconfig\n");
mtkleinf3723212014-06-25 14:08:00 -0700330 } else {
mtklein5d9d10e2014-07-11 11:57:07 -0700331 SkDebugf("loops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tconfig\tbench\n");
mtkleinf3723212014-06-25 14:08:00 -0700332 }
333
334 for (const BenchRegistry* r = BenchRegistry::Head(); r != NULL; r = r->next()) {
335 SkAutoTDelete<Benchmark> bench(r->factory()(NULL));
336 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getName())) {
337 continue;
338 }
339
mtkleinbb6a0282014-07-01 08:43:42 -0700340 SkTDArray<Target*> targets;
341 create_targets(bench.get(), &targets);
mtkleinf3723212014-06-25 14:08:00 -0700342
jcgregoriobf5e5232014-07-17 13:14:16 -0700343 if (!targets.isEmpty()) {
344 log.bench(bench->getName(), bench->getSize().fX, bench->getSize().fY);
345 bench->preDraw();
346 }
mtkleinbb6a0282014-07-01 08:43:42 -0700347 for (int j = 0; j < targets.count(); j++) {
348 SkCanvas* canvas = targets[j]->surface.get() ? targets[j]->surface->getCanvas() : NULL;
Mike Kleine3631362014-07-15 17:56:37 -0400349 const char* config = targets[j]->config;
mtkleinf3723212014-06-25 14:08:00 -0700350
mtkleinbb6a0282014-07-01 08:43:42 -0700351 const int loops =
352#if SK_SUPPORT_GPU
353 Benchmark::kGPU_Backend == targets[j]->backend
354 ? gpu_bench(targets[j]->gl, bench.get(), canvas, samples.get())
355 :
356#endif
357 cpu_bench( overhead, bench.get(), canvas, samples.get());
mtkleinf3723212014-06-25 14:08:00 -0700358
Mike Kleine3631362014-07-15 17:56:37 -0400359 if (loops == 0) {
mtklein04d53a52014-07-17 11:23:07 -0700360 SkDebugf("Unable to time %s\t%s (overhead %s)\n",
361 bench->getName(), config, HUMANIZE(overhead));
Mike Kleine3631362014-07-15 17:56:37 -0400362 continue;
363 }
364
mtkleinf3723212014-06-25 14:08:00 -0700365 Stats stats(samples.get(), FLAGS_samples);
mtklein60317d0f2014-07-14 11:30:37 -0700366 log.config(config);
jcgregoriobf5e5232014-07-17 13:14:16 -0700367#if SK_SUPPORT_GPU
368 if (Benchmark::kGPU_Backend == targets[j]->backend) {
369 fill_gpu_options(&log, targets[j]->gl);
370 }
371#endif
mtklein60317d0f2014-07-14 11:30:37 -0700372 log.timer("min_ms", stats.min);
373 log.timer("median_ms", stats.median);
374 log.timer("mean_ms", stats.mean);
375 log.timer("max_ms", stats.max);
376 log.timer("stddev_ms", sqrt(stats.var));
377
mtkleina189ccd2014-07-14 12:28:47 -0700378 if (FLAGS_runOnce) {
379 if (targets.count() == 1) {
380 config = ""; // Only print the config if we run the same bench on more than one.
381 }
382 SkDebugf("%s\t%s\n", bench->getName(), config);
383 } else if (FLAGS_verbose) {
mtkleinf3723212014-06-25 14:08:00 -0700384 for (int i = 0; i < FLAGS_samples; i++) {
mtklein55b0ffc2014-07-17 08:38:23 -0700385 SkDebugf("%s ", HUMANIZE(samples[i]));
mtkleinf3723212014-06-25 14:08:00 -0700386 }
387 SkDebugf("%s\n", bench->getName());
388 } else if (FLAGS_quiet) {
mtkleinbb6a0282014-07-01 08:43:42 -0700389 if (targets.count() == 1) {
mtkleinf3723212014-06-25 14:08:00 -0700390 config = ""; // Only print the config if we run the same bench on more than one.
391 }
mtklein55b0ffc2014-07-17 08:38:23 -0700392 SkDebugf("%s\t%s\t%s\n", HUMANIZE(stats.median), bench->getName(), config);
mtkleinf3723212014-06-25 14:08:00 -0700393 } else {
394 const double stddev_percent = 100 * sqrt(stats.var) / stats.mean;
mtklein5d9d10e2014-07-11 11:57:07 -0700395 SkDebugf("%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n"
mtkleinf3723212014-06-25 14:08:00 -0700396 , loops
mtklein55b0ffc2014-07-17 08:38:23 -0700397 , HUMANIZE(stats.min)
398 , HUMANIZE(stats.median)
399 , HUMANIZE(stats.mean)
400 , HUMANIZE(stats.max)
mtkleinf3723212014-06-25 14:08:00 -0700401 , stddev_percent
mtklein5d9d10e2014-07-11 11:57:07 -0700402 , stats.plot.c_str()
mtkleinf3723212014-06-25 14:08:00 -0700403 , config
mtkleinbb6a0282014-07-01 08:43:42 -0700404 , bench->getName()
mtkleinf3723212014-06-25 14:08:00 -0700405 );
406 }
407 }
mtkleinbb6a0282014-07-01 08:43:42 -0700408 targets.deleteAll();
Mike Klein3944a1d2014-07-15 13:40:19 -0400409
410 #if SK_SUPPORT_GPU
411 if (FLAGS_resetGpuContext) {
412 gGrFactory.destroyContexts();
413 }
414 #endif
mtkleinf3723212014-06-25 14:08:00 -0700415 }
416
417 return 0;
418}
419
420#if !defined SK_BUILD_FOR_IOS
caryclark17f0b6d2014-07-22 10:15:34 -0700421int main(int argc, char** argv) {
422 SkCommandLineFlags::Parse(argc, argv);
423 return nanobench_main();
mtkleinf3723212014-06-25 14:08:00 -0700424}
425#endif