blob: b7603bf3bcd1925ad30bf7ba05cbdfc229372d67 [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"
mtkleine714e752014-07-31 12:13:48 -070012#include "GMBench.h"
mtkleinafb43792014-08-19 15:55:55 -070013#include "ProcStats.h"
mtklein60317d0f2014-07-14 11:30:37 -070014#include "ResultsWriter.h"
mtkleinfd731ce2014-09-10 12:19:30 -070015#include "RecordingBench.h"
mtklein92007582014-08-01 07:46:52 -070016#include "SKPBench.h"
mtkleinf3723212014-06-25 14:08:00 -070017#include "Stats.h"
18#include "Timer.h"
19
mtklein6838d852014-10-29 14:15:10 -070020#include "SkBBoxHierarchy.h"
mtkleinf3723212014-06-25 14:08:00 -070021#include "SkCanvas.h"
caryclark17f0b6d2014-07-22 10:15:34 -070022#include "SkCommonFlags.h"
mtkleinf3723212014-06-25 14:08:00 -070023#include "SkForceLinking.h"
24#include "SkGraphics.h"
mtklein20840502014-08-21 15:51:22 -070025#include "SkOSFile.h"
26#include "SkPictureRecorder.h"
mtkleinf3723212014-06-25 14:08:00 -070027#include "SkString.h"
28#include "SkSurface.h"
robertphillips5b693772014-11-21 06:19:36 -080029#include "SkTaskGroup.h"
mtkleinf3723212014-06-25 14:08:00 -070030
mtkleinbb6a0282014-07-01 08:43:42 -070031#if SK_SUPPORT_GPU
jcgregoriobf5e5232014-07-17 13:14:16 -070032 #include "gl/GrGLDefines.h"
mtkleinbb6a0282014-07-01 08:43:42 -070033 #include "GrContextFactory.h"
krajcevski69a55602014-08-13 10:46:31 -070034 SkAutoTDelete<GrContextFactory> gGrFactory;
mtkleinbb6a0282014-07-01 08:43:42 -070035#endif
36
mtkleinf3723212014-06-25 14:08:00 -070037__SK_FORCE_IMAGE_DECODER_LINKING;
38
reed53249782014-10-10 09:09:52 -070039static const int kAutoTuneLoops = 0;
bsalomon6eb03cc2014-08-07 14:28:50 -070040
mtkleinb5110422014-08-07 15:20:02 -070041static const int kDefaultLoops =
bsalomon6eb03cc2014-08-07 14:28:50 -070042#ifdef SK_DEBUG
43 1;
mtkleina189ccd2014-07-14 12:28:47 -070044#else
bsalomon6eb03cc2014-08-07 14:28:50 -070045 kAutoTuneLoops;
mtkleina189ccd2014-07-14 12:28:47 -070046#endif
47
bsalomon6eb03cc2014-08-07 14:28:50 -070048static SkString loops_help_txt() {
49 SkString help;
50 help.printf("Number of times to run each bench. Set this to %d to auto-"
51 "tune for each bench. Timings are only reported when auto-tuning.",
52 kAutoTuneLoops);
53 return help;
54}
55
56DEFINE_int32(loops, kDefaultLoops, loops_help_txt().c_str());
57
mtkleinf3723212014-06-25 14:08:00 -070058DEFINE_int32(samples, 10, "Number of samples to measure for each bench.");
59DEFINE_int32(overheadLoops, 100000, "Loops to estimate timer overhead.");
60DEFINE_double(overheadGoal, 0.0001,
61 "Loop until timer overhead is at most this fraction of our measurments.");
mtkleinbb6a0282014-07-01 08:43:42 -070062DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
63DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allows to lag.");
krajcevski12b35442014-08-13 12:06:26 -070064DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling back to "
65 "software path rendering.");
mtkleinf3723212014-06-25 14:08:00 -070066
mtklein60317d0f2014-07-14 11:30:37 -070067DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
mtklein55b0ffc2014-07-17 08:38:23 -070068DEFINE_int32(maxCalibrationAttempts, 3,
69 "Try up to this many times to guess loops for a bench, or skip the bench.");
70DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this.");
mtklein92007582014-08-01 07:46:52 -070071DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs.");
72DEFINE_string(scales, "1.0", "Space-separated scales for SKPs.");
mtklein20840502014-08-21 15:51:22 -070073DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
robertphillips5b693772014-11-21 06:19:36 -080074DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
mtkleine070c2b2014-10-14 08:40:43 -070075DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
mtklein92007582014-08-01 07:46:52 -070076
mtkleinf3723212014-06-25 14:08:00 -070077static SkString humanize(double ms) {
mtkleindc5bbab2014-09-24 06:34:09 -070078 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
79 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3);
80 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6);
mtklein62386882014-07-15 10:30:31 -070081#ifdef SK_BUILD_FOR_WIN
mtkleindc5bbab2014-09-24 06:34:09 -070082 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3);
mtklein62386882014-07-15 10:30:31 -070083#else
mtkleindc5bbab2014-09-24 06:34:09 -070084 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3);
mtklein62386882014-07-15 10:30:31 -070085#endif
mtkleinf3723212014-06-25 14:08:00 -070086 return SkStringPrintf("%.3gms", ms);
87}
mtklein55b0ffc2014-07-17 08:38:23 -070088#define HUMANIZE(ms) humanize(ms).c_str()
mtkleinf3723212014-06-25 14:08:00 -070089
kkinnunen9e61bb72014-10-09 05:24:15 -070090static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContext* gl) {
bsalomon6eb03cc2014-08-07 14:28:50 -070091 if (canvas) {
92 canvas->clear(SK_ColorWHITE);
93 }
mtkleinbb6a0282014-07-01 08:43:42 -070094 WallTimer timer;
95 timer.start();
96 if (bench) {
97 bench->draw(loops, canvas);
98 }
99 if (canvas) {
100 canvas->flush();
101 }
102#if SK_SUPPORT_GPU
103 if (gl) {
104 SK_GL(*gl, Flush());
105 gl->swapBuffers();
106 }
107#endif
108 timer.end();
109 return timer.fWall;
110}
111
mtkleinf3723212014-06-25 14:08:00 -0700112static double estimate_timer_overhead() {
113 double overhead = 0;
mtkleinf3723212014-06-25 14:08:00 -0700114 for (int i = 0; i < FLAGS_overheadLoops; i++) {
mtkleinbb6a0282014-07-01 08:43:42 -0700115 overhead += time(1, NULL, NULL, NULL);
mtkleinf3723212014-06-25 14:08:00 -0700116 }
117 return overhead / FLAGS_overheadLoops;
118}
119
reed53249782014-10-10 09:09:52 -0700120static int detect_forever_loops(int loops) {
121 // look for a magic run-forever value
122 if (loops < 0) {
123 loops = SK_MaxS32;
124 }
125 return loops;
126}
127
mtklein55b0ffc2014-07-17 08:38:23 -0700128static int clamp_loops(int loops) {
129 if (loops < 1) {
mtklein527930f2014-11-06 08:04:34 -0800130 SkDebugf("ERROR: clamping loops from %d to 1. "
131 "There's probably something wrong with the bench.\n", loops);
mtklein55b0ffc2014-07-17 08:38:23 -0700132 return 1;
133 }
134 if (loops > FLAGS_maxLoops) {
135 SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loops, FLAGS_maxLoops);
136 return FLAGS_maxLoops;
137 }
138 return loops;
139}
140
bsalomon6eb03cc2014-08-07 14:28:50 -0700141static bool write_canvas_png(SkCanvas* canvas, const SkString& filename) {
142 if (filename.isEmpty()) {
143 return false;
144 }
reede5ea5002014-09-03 11:54:58 -0700145 if (kUnknown_SkColorType == canvas->imageInfo().colorType()) {
bsalomon6eb03cc2014-08-07 14:28:50 -0700146 return false;
147 }
148 SkBitmap bmp;
149 bmp.setInfo(canvas->imageInfo());
150 if (!canvas->readPixels(&bmp, 0, 0)) {
151 SkDebugf("Can't read canvas pixels.\n");
152 return false;
153 }
154 SkString dir = SkOSPath::Dirname(filename.c_str());
155 if (!sk_mkdir(dir.c_str())) {
156 SkDebugf("Can't make dir %s.\n", dir.c_str());
157 return false;
158 }
159 SkFILEWStream stream(filename.c_str());
160 if (!stream.isValid()) {
161 SkDebugf("Can't write %s.\n", filename.c_str());
162 return false;
163 }
164 if (!SkImageEncoder::EncodeStream(&stream, bmp, SkImageEncoder::kPNG_Type, 100)) {
165 SkDebugf("Can't encode a PNG.\n");
166 return false;
167 }
168 return true;
169}
170
171static int kFailedLoops = -2;
mtkleinbb6a0282014-07-01 08:43:42 -0700172static int cpu_bench(const double overhead, Benchmark* bench, SkCanvas* canvas, double* samples) {
173 // First figure out approximately how many loops of bench it takes to make overhead negligible.
mtklein2069e222014-08-04 13:57:39 -0700174 double bench_plus_overhead = 0.0;
mtklein55b0ffc2014-07-17 08:38:23 -0700175 int round = 0;
bsalomon6eb03cc2014-08-07 14:28:50 -0700176 if (kAutoTuneLoops == FLAGS_loops) {
177 while (bench_plus_overhead < overhead) {
178 if (round++ == FLAGS_maxCalibrationAttempts) {
179 SkDebugf("WARNING: Can't estimate loops for %s (%s vs. %s); skipping.\n",
mtklein96289052014-09-10 12:05:59 -0700180 bench->getUniqueName(), HUMANIZE(bench_plus_overhead), HUMANIZE(overhead));
bsalomon6eb03cc2014-08-07 14:28:50 -0700181 return kFailedLoops;
182 }
183 bench_plus_overhead = time(1, bench, canvas, NULL);
mtklein55b0ffc2014-07-17 08:38:23 -0700184 }
mtklein2069e222014-08-04 13:57:39 -0700185 }
mtkleinf3723212014-06-25 14:08:00 -0700186
mtkleinbb6a0282014-07-01 08:43:42 -0700187 // Later we'll just start and stop the timer once but loop N times.
mtkleinf3723212014-06-25 14:08:00 -0700188 // We'll pick N to make timer overhead negligible:
189 //
mtkleinbb6a0282014-07-01 08:43:42 -0700190 // overhead
191 // ------------------------- < FLAGS_overheadGoal
192 // overhead + N * Bench Time
mtkleinf3723212014-06-25 14:08:00 -0700193 //
mtkleinbb6a0282014-07-01 08:43:42 -0700194 // where bench_plus_overhead ≈ overhead + Bench Time.
mtkleinf3723212014-06-25 14:08:00 -0700195 //
196 // Doing some math, we get:
197 //
mtkleinbb6a0282014-07-01 08:43:42 -0700198 // (overhead / FLAGS_overheadGoal) - overhead
199 // ------------------------------------------ < N
200 // bench_plus_overhead - overhead)
mtkleinf3723212014-06-25 14:08:00 -0700201 //
202 // Luckily, this also works well in practice. :)
bsalomon6eb03cc2014-08-07 14:28:50 -0700203 int loops = FLAGS_loops;
204 if (kAutoTuneLoops == loops) {
205 const double numer = overhead / FLAGS_overheadGoal - overhead;
206 const double denom = bench_plus_overhead - overhead;
207 loops = (int)ceil(numer / denom);
reed53249782014-10-10 09:09:52 -0700208 loops = clamp_loops(loops);
209 } else {
210 loops = detect_forever_loops(loops);
bsalomon6eb03cc2014-08-07 14:28:50 -0700211 }
mtkleinbb6a0282014-07-01 08:43:42 -0700212
213 for (int i = 0; i < FLAGS_samples; i++) {
214 samples[i] = time(loops, bench, canvas, NULL) / loops;
215 }
216 return loops;
mtkleinf3723212014-06-25 14:08:00 -0700217}
218
mtkleinbb6a0282014-07-01 08:43:42 -0700219#if SK_SUPPORT_GPU
robertphillips5b693772014-11-21 06:19:36 -0800220static void setup_gl(SkGLContext* gl) {
221 gl->makeCurrent();
222 // Make sure we're done with whatever came before.
223 SK_GL(*gl, Finish());
224}
225
kkinnunen9e61bb72014-10-09 05:24:15 -0700226static int gpu_bench(SkGLContext* gl,
mtkleinbb6a0282014-07-01 08:43:42 -0700227 Benchmark* bench,
228 SkCanvas* canvas,
229 double* samples) {
mtkleinbb6a0282014-07-01 08:43:42 -0700230 // First, figure out how many loops it'll take to get a frame up to FLAGS_gpuMs.
bsalomon6eb03cc2014-08-07 14:28:50 -0700231 int loops = FLAGS_loops;
232 if (kAutoTuneLoops == loops) {
233 loops = 1;
mtkleina189ccd2014-07-14 12:28:47 -0700234 double elapsed = 0;
235 do {
mtklein527930f2014-11-06 08:04:34 -0800236 if (1<<30 == loops) {
237 // We're about to wrap. Something's wrong with the bench.
238 loops = 0;
239 break;
240 }
mtkleina189ccd2014-07-14 12:28:47 -0700241 loops *= 2;
242 // If the GPU lets frames lag at all, we need to make sure we're timing
243 // _this_ round, not still timing last round. We force this by looping
244 // more times than any reasonable GPU will allow frames to lag.
245 for (int i = 0; i < FLAGS_gpuFrameLag; i++) {
246 elapsed = time(loops, bench, canvas, gl);
247 }
248 } while (elapsed < FLAGS_gpuMs);
mtkleinbb6a0282014-07-01 08:43:42 -0700249
mtkleina189ccd2014-07-14 12:28:47 -0700250 // We've overshot at least a little. Scale back linearly.
251 loops = (int)ceil(loops * FLAGS_gpuMs / elapsed);
reed53249782014-10-10 09:09:52 -0700252 loops = clamp_loops(loops);
mtkleinbb6a0282014-07-01 08:43:42 -0700253
mtkleina189ccd2014-07-14 12:28:47 -0700254 // Might as well make sure we're not still timing our calibration.
255 SK_GL(*gl, Finish());
reed53249782014-10-10 09:09:52 -0700256 } else {
257 loops = detect_forever_loops(loops);
mtkleina189ccd2014-07-14 12:28:47 -0700258 }
mtkleinbb6a0282014-07-01 08:43:42 -0700259
260 // Pretty much the same deal as the calibration: do some warmup to make
261 // sure we're timing steady-state pipelined frames.
262 for (int i = 0; i < FLAGS_gpuFrameLag; i++) {
263 time(loops, bench, canvas, gl);
mtkleinf3723212014-06-25 14:08:00 -0700264 }
mtkleinbb6a0282014-07-01 08:43:42 -0700265
266 // Now, actually do the timing!
267 for (int i = 0; i < FLAGS_samples; i++) {
268 samples[i] = time(loops, bench, canvas, gl) / loops;
269 }
270 return loops;
271}
272#endif
273
274static SkString to_lower(const char* str) {
275 SkString lower(str);
276 for (size_t i = 0; i < lower.size(); i++) {
277 lower[i] = tolower(lower[i]);
278 }
279 return lower;
mtkleinf3723212014-06-25 14:08:00 -0700280}
281
bsalomonc2553372014-07-22 13:09:05 -0700282struct Config {
283 const char* name;
mtkleinbb6a0282014-07-01 08:43:42 -0700284 Benchmark::Backend backend;
bsalomonc2553372014-07-22 13:09:05 -0700285 SkColorType color;
286 SkAlphaType alpha;
287 int samples;
288#if SK_SUPPORT_GPU
289 GrContextFactory::GLContextType ctxType;
jvanverth4736e142014-11-07 07:12:46 -0800290 bool useDFText;
bsalomonc2553372014-07-22 13:09:05 -0700291#else
292 int bogusInt;
jvanverth4736e142014-11-07 07:12:46 -0800293 bool bogusBool;
bsalomonc2553372014-07-22 13:09:05 -0700294#endif
295};
296
297struct Target {
298 explicit Target(const Config& c) : config(c) {}
299 const Config config;
mtkleinbb6a0282014-07-01 08:43:42 -0700300 SkAutoTDelete<SkSurface> surface;
301#if SK_SUPPORT_GPU
kkinnunen9e61bb72014-10-09 05:24:15 -0700302 SkGLContext* gl;
mtkleinbb6a0282014-07-01 08:43:42 -0700303#endif
304};
mtkleinf3723212014-06-25 14:08:00 -0700305
bsalomonc2553372014-07-22 13:09:05 -0700306static bool is_cpu_config_allowed(const char* name) {
mtkleinbb6a0282014-07-01 08:43:42 -0700307 for (int i = 0; i < FLAGS_config.count(); i++) {
bsalomonc2553372014-07-22 13:09:05 -0700308 if (to_lower(FLAGS_config[i]).equals(name)) {
309 return true;
mtkleinf3723212014-06-25 14:08:00 -0700310 }
311 }
bsalomonc2553372014-07-22 13:09:05 -0700312 return false;
mtkleinbb6a0282014-07-01 08:43:42 -0700313}
314
bsalomonc2553372014-07-22 13:09:05 -0700315#if SK_SUPPORT_GPU
316static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextType ctxType,
317 int sampleCnt) {
318 if (!is_cpu_config_allowed(name)) {
319 return false;
320 }
krajcevski69a55602014-08-13 10:46:31 -0700321 if (const GrContext* ctx = gGrFactory->get(ctxType)) {
bsalomonc2553372014-07-22 13:09:05 -0700322 return sampleCnt <= ctx->getMaxSampleCount();
323 }
324 return false;
325}
326#endif
mtkleinbb6a0282014-07-01 08:43:42 -0700327
bsalomonc2553372014-07-22 13:09:05 -0700328#if SK_SUPPORT_GPU
329#define kBogusGLContextType GrContextFactory::kNative_GLContextType
330#else
331#define kBogusGLContextType 0
mtkleine714e752014-07-31 12:13:48 -0700332#endif
bsalomonc2553372014-07-22 13:09:05 -0700333
334// Append all configs that are enabled and supported.
335static void create_configs(SkTDArray<Config>* configs) {
jvanverth4736e142014-11-07 07:12:46 -0800336 #define CPU_CONFIG(name, backend, color, alpha) \
337 if (is_cpu_config_allowed(#name)) { \
338 Config config = { #name, Benchmark::backend, color, alpha, 0, \
339 kBogusGLContextType, false }; \
340 configs->push(config); \
mtkleinbb6a0282014-07-01 08:43:42 -0700341 }
mtkleine714e752014-07-31 12:13:48 -0700342
mtklein40b32be2014-07-09 08:46:49 -0700343 if (FLAGS_cpu) {
bsalomonc2553372014-07-22 13:09:05 -0700344 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kUnpremul_SkAlphaType)
345 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType)
346 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaType)
mtklein40b32be2014-07-09 08:46:49 -0700347 }
mtkleinbb6a0282014-07-01 08:43:42 -0700348
349#if SK_SUPPORT_GPU
jvanverth4736e142014-11-07 07:12:46 -0800350 #define GPU_CONFIG(name, ctxType, samples, useDFText) \
bsalomonc2553372014-07-22 13:09:05 -0700351 if (is_gpu_config_allowed(#name, GrContextFactory::ctxType, samples)) { \
352 Config config = { \
353 #name, \
354 Benchmark::kGPU_Backend, \
355 kN32_SkColorType, \
356 kPremul_SkAlphaType, \
357 samples, \
jvanverth4736e142014-11-07 07:12:46 -0800358 GrContextFactory::ctxType, \
359 useDFText }; \
bsalomonc2553372014-07-22 13:09:05 -0700360 configs->push(config); \
mtkleinbb6a0282014-07-01 08:43:42 -0700361 }
mtkleine714e752014-07-31 12:13:48 -0700362
mtklein40b32be2014-07-09 08:46:49 -0700363 if (FLAGS_gpu) {
jvanverth4736e142014-11-07 07:12:46 -0800364 GPU_CONFIG(gpu, kNative_GLContextType, 0, false)
365 GPU_CONFIG(msaa4, kNative_GLContextType, 4, false)
366 GPU_CONFIG(msaa16, kNative_GLContextType, 16, false)
367 GPU_CONFIG(nvprmsaa4, kNVPR_GLContextType, 4, false)
368 GPU_CONFIG(nvprmsaa16, kNVPR_GLContextType, 16, false)
369 GPU_CONFIG(gpudft, kNative_GLContextType, 0, true)
370 GPU_CONFIG(debug, kDebug_GLContextType, 0, false)
371 GPU_CONFIG(nullgpu, kNull_GLContextType, 0, false)
bsalomon3b4d0772014-08-06 10:52:33 -0700372#ifdef SK_ANGLE
jvanverth4736e142014-11-07 07:12:46 -0800373 GPU_CONFIG(angle, kANGLE_GLContextType, 0, false)
bsalomon3b4d0772014-08-06 10:52:33 -0700374#endif
mtklein40b32be2014-07-09 08:46:49 -0700375 }
mtkleinbb6a0282014-07-01 08:43:42 -0700376#endif
mtkleinf3723212014-06-25 14:08:00 -0700377}
378
bsalomonc2553372014-07-22 13:09:05 -0700379// If bench is enabled for config, returns a Target* for it, otherwise NULL.
380static Target* is_enabled(Benchmark* bench, const Config& config) {
381 if (!bench->isSuitableFor(config.backend)) {
382 return NULL;
383 }
384
reede5ea5002014-09-03 11:54:58 -0700385 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().fY,
386 config.color, config.alpha);
bsalomonc2553372014-07-22 13:09:05 -0700387
388 Target* target = new Target(config);
389
390 if (Benchmark::kRaster_Backend == config.backend) {
391 target->surface.reset(SkSurface::NewRaster(info));
392 }
393#if SK_SUPPORT_GPU
394 else if (Benchmark::kGPU_Backend == config.backend) {
jvanverth4736e142014-11-07 07:12:46 -0800395 uint32_t flags = config.useDFText ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0;
396 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
krajcevski69a55602014-08-13 10:46:31 -0700397 target->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(config.ctxType), info,
jvanverth4736e142014-11-07 07:12:46 -0800398 config.samples, &props));
krajcevski69a55602014-08-13 10:46:31 -0700399 target->gl = gGrFactory->getGLContext(config.ctxType);
bsalomonc2553372014-07-22 13:09:05 -0700400 }
401#endif
402
403 if (Benchmark::kNonRendering_Backend != config.backend && !target->surface.get()) {
404 delete target;
405 return NULL;
406 }
407 return target;
408}
409
410// Creates targets for a benchmark and a set of configs.
411static void create_targets(SkTDArray<Target*>* targets, Benchmark* b,
412 const SkTDArray<Config>& configs) {
413 for (int i = 0; i < configs.count(); ++i) {
414 if (Target* t = is_enabled(b, configs[i])) {
415 targets->push(t);
416 }
mtkleine714e752014-07-31 12:13:48 -0700417
bsalomonc2553372014-07-22 13:09:05 -0700418 }
419}
420
jcgregoriobf5e5232014-07-17 13:14:16 -0700421#if SK_SUPPORT_GPU
kkinnunen9e61bb72014-10-09 05:24:15 -0700422static void fill_gpu_options(ResultsWriter* log, SkGLContext* ctx) {
jcgregorio05c45602014-07-17 13:54:36 -0700423 const GrGLubyte* version;
jcgregoriobf5e5232014-07-17 13:14:16 -0700424 SK_GL_RET(*ctx, version, GetString(GR_GL_VERSION));
425 log->configOption("GL_VERSION", (const char*)(version));
426
427 SK_GL_RET(*ctx, version, GetString(GR_GL_RENDERER));
428 log->configOption("GL_RENDERER", (const char*) version);
429
430 SK_GL_RET(*ctx, version, GetString(GR_GL_VENDOR));
431 log->configOption("GL_VENDOR", (const char*) version);
432
433 SK_GL_RET(*ctx, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
434 log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
435}
436#endif
437
mtkleine714e752014-07-31 12:13:48 -0700438class BenchmarkStream {
439public:
mtklein92007582014-08-01 07:46:52 -0700440 BenchmarkStream() : fBenches(BenchRegistry::Head())
441 , fGMs(skiagm::GMRegistry::Head())
mtkleinfd731ce2014-09-10 12:19:30 -0700442 , fCurrentRecording(0)
mtklein92007582014-08-01 07:46:52 -0700443 , fCurrentScale(0)
robertphillips5b693772014-11-21 06:19:36 -0800444 , fCurrentSKP(0)
445 , fCurrentUseMPD(0) {
mtklein92007582014-08-01 07:46:52 -0700446 for (int i = 0; i < FLAGS_skps.count(); i++) {
447 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
448 fSKPs.push_back() = FLAGS_skps[i];
449 } else {
450 SkOSFile::Iter it(FLAGS_skps[i], ".skp");
451 SkString path;
452 while (it.next(&path)) {
453 fSKPs.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str());
454 }
455 }
456 }
mtkleine714e752014-07-31 12:13:48 -0700457
mtklein92007582014-08-01 07:46:52 -0700458 if (4 != sscanf(FLAGS_clip[0], "%d,%d,%d,%d",
459 &fClip.fLeft, &fClip.fTop, &fClip.fRight, &fClip.fBottom)) {
460 SkDebugf("Can't parse %s from --clip as an SkIRect.\n", FLAGS_clip[0]);
461 exit(1);
462 }
463
464 for (int i = 0; i < FLAGS_scales.count(); i++) {
465 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) {
466 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS_scales[i]);
467 exit(1);
468 }
469 }
robertphillips5b693772014-11-21 06:19:36 -0800470
471 fUseMPDs.push_back() = false;
472 if (FLAGS_mpd) {
473 fUseMPDs.push_back() = true;
474 }
mtklein92007582014-08-01 07:46:52 -0700475 }
476
mtkleinfd731ce2014-09-10 12:19:30 -0700477 static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
478 // Not strictly necessary, as it will be checked again later,
479 // but helps to avoid a lot of pointless work if we're going to skip it.
480 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
481 return false;
482 }
483
484 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
485 if (stream.get() == NULL) {
486 SkDebugf("Could not read %s.\n", path);
487 return false;
488 }
489
mtklein963504b2014-09-17 06:58:39 -0700490 pic->reset(SkPicture::CreateFromStream(stream.get()));
mtkleinfd731ce2014-09-10 12:19:30 -0700491 if (pic->get() == NULL) {
492 SkDebugf("Could not read %s as an SkPicture.\n", path);
493 return false;
494 }
495 return true;
496 }
497
mtklein92007582014-08-01 07:46:52 -0700498 Benchmark* next() {
mtkleine714e752014-07-31 12:13:48 -0700499 if (fBenches) {
500 Benchmark* bench = fBenches->factory()(NULL);
501 fBenches = fBenches->next();
mtklein92007582014-08-01 07:46:52 -0700502 fSourceType = "bench";
mtkleinfd731ce2014-09-10 12:19:30 -0700503 fBenchType = "micro";
mtkleine714e752014-07-31 12:13:48 -0700504 return bench;
505 }
mtklein92007582014-08-01 07:46:52 -0700506
mtkleine714e752014-07-31 12:13:48 -0700507 while (fGMs) {
508 SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(NULL));
509 fGMs = fGMs->next();
510 if (gm->getFlags() & skiagm::GM::kAsBench_Flag) {
mtklein92007582014-08-01 07:46:52 -0700511 fSourceType = "gm";
mtkleinfd731ce2014-09-10 12:19:30 -0700512 fBenchType = "micro";
mtkleine714e752014-07-31 12:13:48 -0700513 return SkNEW_ARGS(GMBench, (gm.detach()));
514 }
515 }
mtklein92007582014-08-01 07:46:52 -0700516
mtkleinfd731ce2014-09-10 12:19:30 -0700517 // First add all .skps as RecordingBenches.
518 while (fCurrentRecording < fSKPs.count()) {
519 const SkString& path = fSKPs[fCurrentRecording++];
520 SkAutoTUnref<SkPicture> pic;
521 if (!ReadPicture(path.c_str(), &pic)) {
522 continue;
523 }
524 SkString name = SkOSPath::Basename(path.c_str());
525 fSourceType = "skp";
526 fBenchType = "recording";
527 return SkNEW_ARGS(RecordingBench, (name.c_str(), pic.get(), FLAGS_bbh));
528 }
529
530 // Then once each for each scale as SKPBenches (playback).
mtklein92007582014-08-01 07:46:52 -0700531 while (fCurrentScale < fScales.count()) {
532 while (fCurrentSKP < fSKPs.count()) {
robertphillips5b693772014-11-21 06:19:36 -0800533 const SkString& path = fSKPs[fCurrentSKP];
mtkleinfd731ce2014-09-10 12:19:30 -0700534 SkAutoTUnref<SkPicture> pic;
535 if (!ReadPicture(path.c_str(), &pic)) {
robertphillips5b693772014-11-21 06:19:36 -0800536 fCurrentSKP++;
mtklein92007582014-08-01 07:46:52 -0700537 continue;
538 }
robertphillips5b693772014-11-21 06:19:36 -0800539
540 while (fCurrentUseMPD < fUseMPDs.count()) {
541 if (FLAGS_bbh) {
542 // The SKP we read off disk doesn't have a BBH. Re-record so it grows one.
543 SkRTreeFactory factory;
544 SkPictureRecorder recorder;
545 static const int kFlags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag;
546 pic->playback(recorder.beginRecording(pic->cullRect().width(),
547 pic->cullRect().height(),
548 &factory, kFlags));
549 pic.reset(recorder.endRecording());
550 }
551 SkString name = SkOSPath::Basename(path.c_str());
552 fSourceType = "skp";
553 fBenchType = "playback";
554 return SkNEW_ARGS(SKPBench,
555 (name.c_str(), pic.get(), fClip,
556 fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++]));
mtklein20840502014-08-21 15:51:22 -0700557 }
robertphillips5b693772014-11-21 06:19:36 -0800558 fCurrentUseMPD = 0;
559 fCurrentSKP++;
mtklein92007582014-08-01 07:46:52 -0700560 }
561 fCurrentSKP = 0;
562 fCurrentScale++;
563 }
564
mtkleine714e752014-07-31 12:13:48 -0700565 return NULL;
566 }
mtklein92007582014-08-01 07:46:52 -0700567
568 void fillCurrentOptions(ResultsWriter* log) const {
569 log->configOption("source_type", fSourceType);
mtkleinfd731ce2014-09-10 12:19:30 -0700570 log->configOption("bench_type", fBenchType);
mtklein92007582014-08-01 07:46:52 -0700571 if (0 == strcmp(fSourceType, "skp")) {
572 log->configOption("clip",
573 SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop,
574 fClip.fRight, fClip.fBottom).c_str());
575 log->configOption("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str());
robertphillips5b693772014-11-21 06:19:36 -0800576 if (fCurrentUseMPD > 0) {
577 SkASSERT(1 == fCurrentUseMPD || 2 == fCurrentUseMPD);
578 log->configOption("multi_picture_draw", fUseMPDs[fCurrentUseMPD-1] ? "true" : "false");
579 }
mtklein92007582014-08-01 07:46:52 -0700580 }
581 }
582
mtkleine714e752014-07-31 12:13:48 -0700583private:
584 const BenchRegistry* fBenches;
585 const skiagm::GMRegistry* fGMs;
mtklein92007582014-08-01 07:46:52 -0700586 SkIRect fClip;
587 SkTArray<SkScalar> fScales;
588 SkTArray<SkString> fSKPs;
robertphillips5b693772014-11-21 06:19:36 -0800589 SkTArray<bool> fUseMPDs;
mtklein92007582014-08-01 07:46:52 -0700590
mtkleinfd731ce2014-09-10 12:19:30 -0700591 const char* fSourceType; // What we're benching: bench, GM, SKP, ...
592 const char* fBenchType; // How we bench it: micro, recording, playback, ...
593 int fCurrentRecording;
mtklein92007582014-08-01 07:46:52 -0700594 int fCurrentScale;
595 int fCurrentSKP;
robertphillips5b693772014-11-21 06:19:36 -0800596 int fCurrentUseMPD;
mtkleine714e752014-07-31 12:13:48 -0700597};
598
jcgregorio3b27ade2014-11-13 08:06:40 -0800599int nanobench_main();
caryclark17f0b6d2014-07-22 10:15:34 -0700600int nanobench_main() {
jcgregorio3b27ade2014-11-13 08:06:40 -0800601 SetupCrashHandler();
mtkleinf3723212014-06-25 14:08:00 -0700602 SkAutoGraphics ag;
robertphillips5b693772014-11-21 06:19:36 -0800603 // Multithreading is disabled pending resolution of skia:3149
604 //SkTaskGroup::Enabler enabled;
mtkleinf3723212014-06-25 14:08:00 -0700605
krajcevski69a55602014-08-13 10:46:31 -0700606#if SK_SUPPORT_GPU
krajcevski12b35442014-08-13 12:06:26 -0700607 GrContext::Options grContextOpts;
608 grContextOpts.fDrawPathToCompressedTexture = FLAGS_gpuCompressAlphaMasks;
609 gGrFactory.reset(SkNEW_ARGS(GrContextFactory, (grContextOpts)));
krajcevski69a55602014-08-13 10:46:31 -0700610#endif
611
bsalomon06cddec2014-10-24 10:40:50 -0700612 if (FLAGS_veryVerbose) {
613 FLAGS_verbose = true;
614 }
615
bsalomon6eb03cc2014-08-07 14:28:50 -0700616 if (kAutoTuneLoops != FLAGS_loops) {
mtkleina189ccd2014-07-14 12:28:47 -0700617 FLAGS_samples = 1;
618 FLAGS_gpuFrameLag = 0;
619 }
620
bsalomon6eb03cc2014-08-07 14:28:50 -0700621 if (!FLAGS_writePath.isEmpty()) {
622 SkDebugf("Writing files to %s.\n", FLAGS_writePath[0]);
623 if (!sk_mkdir(FLAGS_writePath[0])) {
624 SkDebugf("Could not create %s. Files won't be written.\n", FLAGS_writePath[0]);
625 FLAGS_writePath.set(0, NULL);
626 }
627 }
628
mtklein1915b622014-08-20 11:45:00 -0700629 SkAutoTDelete<ResultsWriter> log(SkNEW(ResultsWriter));
mtklein60317d0f2014-07-14 11:30:37 -0700630 if (!FLAGS_outResultsFile.isEmpty()) {
mtklein1915b622014-08-20 11:45:00 -0700631 log.reset(SkNEW(NanoJSONResultsWriter(FLAGS_outResultsFile[0])));
mtklein60317d0f2014-07-14 11:30:37 -0700632 }
mtklein1915b622014-08-20 11:45:00 -0700633
634 if (1 == FLAGS_properties.count() % 2) {
635 SkDebugf("ERROR: --properties must be passed with an even number of arguments.\n");
636 return 1;
637 }
638 for (int i = 1; i < FLAGS_properties.count(); i += 2) {
639 log->property(FLAGS_properties[i-1], FLAGS_properties[i]);
640 }
jcgregoriobf5e5232014-07-17 13:14:16 -0700641
642 if (1 == FLAGS_key.count() % 2) {
643 SkDebugf("ERROR: --key must be passed with an even number of arguments.\n");
644 return 1;
645 }
646 for (int i = 1; i < FLAGS_key.count(); i += 2) {
mtklein1915b622014-08-20 11:45:00 -0700647 log->key(FLAGS_key[i-1], FLAGS_key[i]);
mtklein94e51562014-08-19 12:41:53 -0700648 }
mtklein60317d0f2014-07-14 11:30:37 -0700649
mtkleinf3723212014-06-25 14:08:00 -0700650 const double overhead = estimate_timer_overhead();
mtklein55b0ffc2014-07-17 08:38:23 -0700651 SkDebugf("Timer overhead: %s\n", HUMANIZE(overhead));
Mike Klein91294772014-07-16 19:59:32 -0400652
mtkleinbb6a0282014-07-01 08:43:42 -0700653 SkAutoTMalloc<double> samples(FLAGS_samples);
654
bsalomon6eb03cc2014-08-07 14:28:50 -0700655 if (kAutoTuneLoops != FLAGS_loops) {
656 SkDebugf("Fixed number of loops; times would only be misleading so we won't print them.\n");
mtkleina189ccd2014-07-14 12:28:47 -0700657 } else if (FLAGS_verbose) {
mtkleinf3723212014-06-25 14:08:00 -0700658 // No header.
659 } else if (FLAGS_quiet) {
mtklein40b32be2014-07-09 08:46:49 -0700660 SkDebugf("median\tbench\tconfig\n");
mtkleinf3723212014-06-25 14:08:00 -0700661 } else {
qiankun.miao8247ec32014-09-09 19:24:36 -0700662 SkDebugf("maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\tbench\n",
663 FLAGS_samples, "samples");
mtkleinf3723212014-06-25 14:08:00 -0700664 }
665
bsalomonc2553372014-07-22 13:09:05 -0700666 SkTDArray<Config> configs;
667 create_configs(&configs);
668
mtkleine070c2b2014-10-14 08:40:43 -0700669 int runs = 0;
mtklein92007582014-08-01 07:46:52 -0700670 BenchmarkStream benchStream;
671 while (Benchmark* b = benchStream.next()) {
mtkleine714e752014-07-31 12:13:48 -0700672 SkAutoTDelete<Benchmark> bench(b);
mtklein96289052014-09-10 12:05:59 -0700673 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) {
mtkleinf3723212014-06-25 14:08:00 -0700674 continue;
675 }
676
mtkleinbb6a0282014-07-01 08:43:42 -0700677 SkTDArray<Target*> targets;
bsalomonc2553372014-07-22 13:09:05 -0700678 create_targets(&targets, bench.get(), configs);
mtkleinf3723212014-06-25 14:08:00 -0700679
jcgregoriobf5e5232014-07-17 13:14:16 -0700680 if (!targets.isEmpty()) {
mtklein96289052014-09-10 12:05:59 -0700681 log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSize().fY);
jcgregoriobf5e5232014-07-17 13:14:16 -0700682 bench->preDraw();
683 }
mtkleinbb6a0282014-07-01 08:43:42 -0700684 for (int j = 0; j < targets.count(); j++) {
685 SkCanvas* canvas = targets[j]->surface.get() ? targets[j]->surface->getCanvas() : NULL;
bsalomonc2553372014-07-22 13:09:05 -0700686 const char* config = targets[j]->config.name;
mtkleinf3723212014-06-25 14:08:00 -0700687
robertphillips5b693772014-11-21 06:19:36 -0800688#if SK_SUPPORT_GPU
689 if (Benchmark::kGPU_Backend == targets[j]->config.backend) {
690 setup_gl(targets[j]->gl);
691 }
692#endif
693
694 bench->perCanvasPreDraw(canvas);
695
mtkleinbb6a0282014-07-01 08:43:42 -0700696 const int loops =
697#if SK_SUPPORT_GPU
bsalomonc2553372014-07-22 13:09:05 -0700698 Benchmark::kGPU_Backend == targets[j]->config.backend
mtkleinbb6a0282014-07-01 08:43:42 -0700699 ? gpu_bench(targets[j]->gl, bench.get(), canvas, samples.get())
700 :
701#endif
702 cpu_bench( overhead, bench.get(), canvas, samples.get());
mtkleinf3723212014-06-25 14:08:00 -0700703
robertphillips5b693772014-11-21 06:19:36 -0800704 bench->perCanvasPostDraw(canvas);
705
bsalomon49f085d2014-09-05 13:34:00 -0700706 if (canvas && !FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) {
bsalomon6eb03cc2014-08-07 14:28:50 -0700707 SkString pngFilename = SkOSPath::Join(FLAGS_writePath[0], config);
mtklein96289052014-09-10 12:05:59 -0700708 pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getUniqueName());
bsalomon6eb03cc2014-08-07 14:28:50 -0700709 pngFilename.append(".png");
710 write_canvas_png(canvas, pngFilename);
711 }
712
713 if (kFailedLoops == loops) {
mtklein2069e222014-08-04 13:57:39 -0700714 // Can't be timed. A warning note has already been printed.
Mike Kleine3631362014-07-15 17:56:37 -0400715 continue;
716 }
717
mtkleinf3723212014-06-25 14:08:00 -0700718 Stats stats(samples.get(), FLAGS_samples);
mtklein1915b622014-08-20 11:45:00 -0700719 log->config(config);
mtklein96289052014-09-10 12:05:59 -0700720 log->configOption("name", bench->getName());
mtklein1915b622014-08-20 11:45:00 -0700721 benchStream.fillCurrentOptions(log.get());
jcgregoriobf5e5232014-07-17 13:14:16 -0700722#if SK_SUPPORT_GPU
bsalomonc2553372014-07-22 13:09:05 -0700723 if (Benchmark::kGPU_Backend == targets[j]->config.backend) {
mtklein1915b622014-08-20 11:45:00 -0700724 fill_gpu_options(log.get(), targets[j]->gl);
jcgregoriobf5e5232014-07-17 13:14:16 -0700725 }
726#endif
mtklein1915b622014-08-20 11:45:00 -0700727 log->timer("min_ms", stats.min);
728 log->timer("median_ms", stats.median);
729 log->timer("mean_ms", stats.mean);
730 log->timer("max_ms", stats.max);
731 log->timer("stddev_ms", sqrt(stats.var));
mtkleine070c2b2014-10-14 08:40:43 -0700732 if (runs++ % FLAGS_flushEvery == 0) {
733 log->flush();
734 }
mtklein60317d0f2014-07-14 11:30:37 -0700735
bsalomon6eb03cc2014-08-07 14:28:50 -0700736 if (kAutoTuneLoops != FLAGS_loops) {
mtkleina189ccd2014-07-14 12:28:47 -0700737 if (targets.count() == 1) {
738 config = ""; // Only print the config if we run the same bench on more than one.
739 }
mtklein53d25622014-09-18 07:39:42 -0700740 SkDebugf("%4dM\t%s\t%s\n"
741 , sk_tools::getMaxResidentSetSizeMB()
742 , bench->getUniqueName()
743 , config);
mtkleina189ccd2014-07-14 12:28:47 -0700744 } else if (FLAGS_verbose) {
mtkleinf3723212014-06-25 14:08:00 -0700745 for (int i = 0; i < FLAGS_samples; i++) {
mtklein55b0ffc2014-07-17 08:38:23 -0700746 SkDebugf("%s ", HUMANIZE(samples[i]));
mtkleinf3723212014-06-25 14:08:00 -0700747 }
mtklein96289052014-09-10 12:05:59 -0700748 SkDebugf("%s\n", bench->getUniqueName());
mtkleinf3723212014-06-25 14:08:00 -0700749 } else if (FLAGS_quiet) {
mtkleinbb6a0282014-07-01 08:43:42 -0700750 if (targets.count() == 1) {
mtkleinf3723212014-06-25 14:08:00 -0700751 config = ""; // Only print the config if we run the same bench on more than one.
752 }
mtklein96289052014-09-10 12:05:59 -0700753 SkDebugf("%s\t%s\t%s\n", HUMANIZE(stats.median), bench->getUniqueName(), config);
mtkleinf3723212014-06-25 14:08:00 -0700754 } else {
755 const double stddev_percent = 100 * sqrt(stats.var) / stats.mean;
mtkleinafb43792014-08-19 15:55:55 -0700756 SkDebugf("%4dM\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n"
757 , sk_tools::getMaxResidentSetSizeMB()
mtkleinf3723212014-06-25 14:08:00 -0700758 , loops
mtklein55b0ffc2014-07-17 08:38:23 -0700759 , HUMANIZE(stats.min)
760 , HUMANIZE(stats.median)
761 , HUMANIZE(stats.mean)
762 , HUMANIZE(stats.max)
mtkleinf3723212014-06-25 14:08:00 -0700763 , stddev_percent
mtklein5d9d10e2014-07-11 11:57:07 -0700764 , stats.plot.c_str()
mtkleinf3723212014-06-25 14:08:00 -0700765 , config
mtklein96289052014-09-10 12:05:59 -0700766 , bench->getUniqueName()
mtkleinf3723212014-06-25 14:08:00 -0700767 );
768 }
bsalomon06cddec2014-10-24 10:40:50 -0700769#if SK_SUPPORT_GPU && GR_CACHE_STATS
770 if (FLAGS_veryVerbose &&
771 Benchmark::kGPU_Backend == targets[j]->config.backend) {
mtklein6838d852014-10-29 14:15:10 -0700772 gGrFactory->get(targets[j]->config.ctxType)->printCacheStats();
bsalomon06cddec2014-10-24 10:40:50 -0700773 }
774#endif
mtkleinf3723212014-06-25 14:08:00 -0700775 }
mtkleinbb6a0282014-07-01 08:43:42 -0700776 targets.deleteAll();
Mike Klein3944a1d2014-07-15 13:40:19 -0400777
bsalomon06cddec2014-10-24 10:40:50 -0700778#if SK_SUPPORT_GPU
bsalomon2354f842014-07-28 13:48:36 -0700779 if (FLAGS_abandonGpuContext) {
krajcevski69a55602014-08-13 10:46:31 -0700780 gGrFactory->abandonContexts();
bsalomon2354f842014-07-28 13:48:36 -0700781 }
782 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) {
krajcevski69a55602014-08-13 10:46:31 -0700783 gGrFactory->destroyContexts();
Mike Klein3944a1d2014-07-15 13:40:19 -0400784 }
bsalomon06cddec2014-10-24 10:40:50 -0700785#endif
mtkleinf3723212014-06-25 14:08:00 -0700786 }
787
788 return 0;
789}
790
jcgregorio3b27ade2014-11-13 08:06:40 -0800791#if !defined SK_BUILD_FOR_IOS
792int main(int argc, char** argv) {
793 SkCommandLineFlags::Parse(argc, argv);
794 return nanobench_main();
795}
796#endif