blob: 720621ec9a05ff870b466e152173267b1543d089 [file] [log] [blame]
reed@google.com006db0f2012-06-27 19:33:29 +00001/*
2 * Copyright 2012 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
8#include "BenchTimer.h"
scroggo@google.com4a26d9d2012-11-07 18:01:46 +00009#include "CopyTilesRenderer.h"
keyar@chromium.org163b5672012-08-01 17:53:29 +000010#include "PictureBenchmark.h"
scroggo@google.com161e1ba2013-03-04 16:41:06 +000011#include "PictureRenderingFlags.h"
scroggo@google.com9a412522012-09-07 15:21:18 +000012#include "SkBenchLogger.h"
scroggo@google.comd9ba9a02013-03-21 19:43:15 +000013#include "SkCommandLineFlags.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +000014#include "SkForceLinking.h"
scroggo@google.com0a36f432012-09-10 20:29:13 +000015#include "SkGraphics.h"
scroggo@google.com5a7c6be2012-10-04 21:46:08 +000016#include "SkImageDecoder.h"
scroggo@google.combb281f72013-03-18 21:37:39 +000017#if LAZY_CACHE_STATS
18 #include "SkLazyPixelRef.h"
19#endif
20#include "SkLruImageCache.h"
keyar@chromium.orgf4959ab2012-08-23 20:53:25 +000021#include "SkMath.h"
reed@google.com006db0f2012-06-27 19:33:29 +000022#include "SkOSFile.h"
23#include "SkPicture.h"
24#include "SkStream.h"
reed@google.com006db0f2012-06-27 19:33:29 +000025#include "picture_utils.h"
26
scroggo@google.com7def5e12013-05-31 14:00:10 +000027__SK_FORCE_IMAGE_DECODER_LINKING;
scroggo@google.com161e1ba2013-03-04 16:41:06 +000028
29SkBenchLogger gLogger;
30
31// Flags used by this file, in alphabetical order.
scroggo@google.coma560d00b2013-03-04 21:32:32 +000032DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp file");
scroggo@google.com161e1ba2013-03-04 16:41:06 +000033DECLARE_bool(deferImageDecoding);
34DEFINE_string(filter, "",
35 "type:flag : Enable canvas filtering to disable a paint flag, "
36 "use no blur or low quality blur, or use no hinting or "
37 "slight hinting. For all flags except AAClip, specify the "
38 "type of primitive to effect, or choose all. for AAClip "
39 "alone, the filter affects all clips independent of type. "
40 "Specific flags are listed above.");
41DEFINE_string(logFile, "", "Destination for writing log output, in addition to stdout.");
42DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean.");
43DEFINE_bool(min, false, "Print the minimum times (instead of average).");
44DECLARE_int32(multi);
scroggo@google.com604e0c22013-04-09 21:25:46 +000045DECLARE_string(readPath);
scroggo@google.com161e1ba2013-03-04 16:41:06 +000046DEFINE_int32(repeat, 1, "Set the number of times to repeat each test.");
47DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual tiles, rather than "
48 "times for drawing the whole page. Requires tiled rendering.");
49DEFINE_string(timers, "", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or truncated cpu time"
50 " for each picture.");
scroggo@google.comcc690202013-03-04 19:56:21 +000051DEFINE_bool(trackDeferredCaching, false, "Only meaningful with --deferImageDecoding and "
52 "LAZY_CACHE_STATS set to true. Report percentage of cache hits when using deferred "
53 "image decoding.");
reed@google.com006db0f2012-06-27 19:33:29 +000054
caryclark@google.coma3622372012-11-06 21:26:13 +000055static char const * const gFilterTypes[] = {
56 "paint",
57 "point",
58 "line",
59 "bitmap",
60 "rect",
jvanverth@google.comd3c208c2013-01-22 13:54:52 +000061 "oval",
caryclark@google.coma3622372012-11-06 21:26:13 +000062 "path",
63 "text",
64 "all",
65};
66
67static const size_t kFilterTypesCount = sizeof(gFilterTypes) / sizeof(gFilterTypes[0]);
68
69static char const * const gFilterFlags[] = {
70 "antiAlias",
71 "filterBitmap",
72 "dither",
73 "underlineText",
74 "strikeThruText",
75 "fakeBoldText",
76 "linearText",
77 "subpixelText",
78 "devKernText",
79 "LCDRenderText",
80 "embeddedBitmapText",
81 "autoHinting",
82 "verticalText",
83 "genA8FromLCD",
84 "blur",
85 "hinting",
86 "slightHinting",
caryclark@google.come3e940c2012-11-07 16:42:17 +000087 "AAClip",
caryclark@google.coma3622372012-11-06 21:26:13 +000088};
89
90static const size_t kFilterFlagsCount = sizeof(gFilterFlags) / sizeof(gFilterFlags[0]);
91
92static SkString filtersName(sk_tools::PictureRenderer::DrawFilterFlags* drawFilters) {
93 int all = drawFilters[0];
94 size_t tIndex;
95 for (tIndex = 1; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
96 all &= drawFilters[tIndex];
97 }
98 SkString result;
99 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
100 SkString types;
101 if (all & (1 << fIndex)) {
102 types = gFilterTypes[SkDrawFilter::kTypeCount];
103 } else {
104 for (tIndex = 0; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
105 if (drawFilters[tIndex] & (1 << fIndex)) {
106 types += gFilterTypes[tIndex];
107 }
108 }
109 }
110 if (!types.size()) {
111 continue;
112 }
113 result += "_";
114 result += types;
115 result += ".";
116 result += gFilterFlags[fIndex];
117 }
118 return result;
119}
120
121static SkString filterTypesUsage() {
122 SkString result;
123 for (size_t index = 0; index < kFilterTypesCount; ++index) {
124 result += gFilterTypes[index];
125 if (index < kFilterTypesCount - 1) {
126 result += " | ";
127 }
128 }
129 return result;
130}
131
132static SkString filterFlagsUsage() {
133 SkString result;
134 size_t len = 0;
135 for (size_t index = 0; index < kFilterFlagsCount; ++index) {
136 result += gFilterFlags[index];
137 if (result.size() - len >= 72) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000138 result += "\n\t\t";
caryclark@google.coma3622372012-11-06 21:26:13 +0000139 len = result.size();
140 }
141 if (index < kFilterFlagsCount - 1) {
142 result += " | ";
143 }
144 }
145 return result;
146}
147
scroggo@google.combb281f72013-03-18 21:37:39 +0000148// These are defined in PictureRenderingFlags.cpp
149extern SkLruImageCache gLruImageCache;
150extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap);
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000151
scroggo@google.comcc690202013-03-04 19:56:21 +0000152#if LAZY_CACHE_STATS
153static int32_t gTotalCacheHits;
154static int32_t gTotalCacheMisses;
155#endif
156
borenet@google.com66bcbd12012-09-17 18:26:06 +0000157static bool run_single_benchmark(const SkString& inputPath,
keyar@chromium.org163b5672012-08-01 17:53:29 +0000158 sk_tools::PictureBenchmark& benchmark) {
reed@google.com006db0f2012-06-27 19:33:29 +0000159 SkFILEStream inputStream;
160
reed@google.com006db0f2012-06-27 19:33:29 +0000161 inputStream.setPath(inputPath.c_str());
162 if (!inputStream.isValid()) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000163 SkString err;
164 err.printf("Could not open file %s\n", inputPath.c_str());
165 gLogger.logError(err);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000166 return false;
reed@google.com006db0f2012-06-27 19:33:29 +0000167 }
168
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000169 // Since the old picture has been deleted, all pixels should be cleared.
170 SkASSERT(gLruImageCache.getImageCacheUsed() == 0);
171 if (FLAGS_countRAM) {
172 // Set the limit to zero, so all pixels will be kept
173 gLruImageCache.setImageCacheLimit(0);
174 }
175
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000176 SkPicture::InstallPixelRefProc proc;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000177 if (FLAGS_deferImageDecoding) {
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000178 proc = &lazy_decode_bitmap;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000179 } else {
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000180 proc = &SkImageDecoder::DecodeMemory;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000181 }
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000182 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000183
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000184 if (NULL == picture.get()) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000185 SkString err;
186 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
187 gLogger.logError(err);
188 return false;
189 }
reed@google.com006db0f2012-06-27 19:33:29 +0000190
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000191 SkString filename;
192 sk_tools::get_basename(&filename, inputPath);
keyar@chromium.orgdb9a5fb2012-08-21 17:57:59 +0000193
194 SkString result;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000195 result.printf("running bench [%i %i] %s ", picture->width(), picture->height(),
196 filename.c_str());
scroggo@google.com9a412522012-09-07 15:21:18 +0000197 gLogger.logProgress(result);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000198
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000199 benchmark.run(picture);
scroggo@google.comcc690202013-03-04 19:56:21 +0000200
201#if LAZY_CACHE_STATS
202 if (FLAGS_trackDeferredCaching) {
203 int32_t cacheHits = SkLazyPixelRef::GetCacheHits();
204 int32_t cacheMisses = SkLazyPixelRef::GetCacheMisses();
205 SkLazyPixelRef::ResetCacheStats();
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000206 SkString hitString;
207 hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
208 gLogger.logProgress(hitString);
scroggo@google.comcc690202013-03-04 19:56:21 +0000209 gTotalCacheHits += cacheHits;
210 gTotalCacheMisses += cacheMisses;
211 }
212#endif
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000213 if (FLAGS_countRAM) {
214 SkString ramCount("RAM used for bitmaps: ");
215 size_t bytes = gLruImageCache.getImageCacheUsed();
216 if (bytes > 1024) {
217 size_t kb = bytes / 1024;
218 if (kb > 1024) {
219 size_t mb = kb / 1024;
220 ramCount.appendf("%zi MB\n", mb);
221 } else {
222 ramCount.appendf("%zi KB\n", kb);
223 }
224 } else {
225 ramCount.appendf("%zi bytes\n", bytes);
226 }
227 gLogger.logProgress(ramCount);
228 }
scroggo@google.comcc690202013-03-04 19:56:21 +0000229
borenet@google.com66bcbd12012-09-17 18:26:06 +0000230 return true;
keyar@chromium.org0665f252012-07-10 18:30:18 +0000231}
232
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000233static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
caryclark@google.coma3622372012-11-06 21:26:13 +0000234 sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
235 sk_bzero(drawFilters, sizeof(drawFilters));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000236
237 if (FLAGS_filter.count() > 0) {
238 const char* filters = FLAGS_filter[0];
239 const char* colon = strchr(filters, ':');
240 if (colon) {
scroggo@google.comcc690202013-03-04 19:56:21 +0000241 int32_t type = -1;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000242 size_t typeLen = colon - filters;
243 for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
244 if (typeLen == strlen(gFilterTypes[tIndex])
245 && !strncmp(filters, gFilterTypes[tIndex], typeLen)) {
scroggo@google.comcc690202013-03-04 19:56:21 +0000246 type = SkToS32(tIndex);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000247 break;
reed@google.com006db0f2012-06-27 19:33:29 +0000248 }
reed@google.com006db0f2012-06-27 19:33:29 +0000249 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000250 if (type < 0) {
junov@chromium.org9313ca42012-11-02 18:11:49 +0000251 SkString err;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000252 err.printf("Unknown type for --filter %s\n", filters);
junov@chromium.org9313ca42012-11-02 18:11:49 +0000253 gLogger.logError(err);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000254 exit(-1);
junov@chromium.org9313ca42012-11-02 18:11:49 +0000255 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000256 int flag = -1;
257 size_t flagLen = strlen(filters) - typeLen - 1;
258 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
259 if (flagLen == strlen(gFilterFlags[fIndex])
260 && !strncmp(colon + 1, gFilterFlags[fIndex], flagLen)) {
261 flag = 1 << fIndex;
262 break;
263 }
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000264 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000265 if (flag < 0) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000266 SkString err;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000267 err.printf("Unknown flag for --filter %s\n", filters);
scroggo@google.com9a412522012-09-07 15:21:18 +0000268 gLogger.logError(err);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000269 exit(-1);
reed@google.com006db0f2012-06-27 19:33:29 +0000270 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000271 for (int index = 0; index < SkDrawFilter::kTypeCount; ++index) {
272 if (type != SkDrawFilter::kTypeCount && index != type) {
273 continue;
scroggo@google.com5239c322012-09-11 19:15:32 +0000274 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000275 drawFilters[index] = (sk_tools::PictureRenderer::DrawFilterFlags)
276 (drawFilters[index] | flag);
scroggo@google.com5239c322012-09-11 19:15:32 +0000277 }
reed@google.com006db0f2012-06-27 19:33:29 +0000278 } else {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000279 SkString err;
280 err.printf("Unknown arg for --filter %s : missing colon\n", filters);
281 gLogger.logError(err);
282 exit(-1);
reed@google.com006db0f2012-06-27 19:33:29 +0000283 }
284 }
285
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000286 if (FLAGS_timers.count() > 0) {
287 size_t index = 0;
288 bool timerWall = false;
289 bool truncatedTimerWall = false;
290 bool timerCpu = false;
291 bool truncatedTimerCpu = false;
292 bool timerGpu = false;
293 while (index < strlen(FLAGS_timers[0])) {
294 switch (FLAGS_timers[0][index]) {
295 case 'w':
296 timerWall = true;
297 break;
298 case 'c':
299 timerCpu = true;
300 break;
301 case 'W':
302 truncatedTimerWall = true;
303 break;
304 case 'C':
305 truncatedTimerCpu = true;
306 break;
307 case 'g':
308 timerGpu = true;
scroggo@google.com0556ea02013-02-08 19:38:21 +0000309 break;
310 default:
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000311 SkDebugf("mystery character\n");
scroggo@google.com0556ea02013-02-08 19:38:21 +0000312 break;
313 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000314 index++;
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000315 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000316 benchmark->setTimersToShow(timerWall, truncatedTimerWall, timerCpu, truncatedTimerCpu,
317 timerGpu);
reed@google.com006db0f2012-06-27 19:33:29 +0000318 }
keyar@chromium.org163b5672012-08-01 17:53:29 +0000319
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000320 SkString errorString;
321 SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
322 kBench_PictureTool));
323
324 if (errorString.size() > 0) {
325 gLogger.logError(errorString);
keyar@chromium.org163b5672012-08-01 17:53:29 +0000326 }
junov@chromium.org9313ca42012-11-02 18:11:49 +0000327
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000328 if (NULL == renderer.get()) {
329 exit(-1);
330 }
331
332 if (FLAGS_timeIndividualTiles) {
333 if (FLAGS_multi > 1) {
334 gLogger.logError("Cannot time individual tiles with more than one thread.\n");
335 exit(-1);
336 }
337 sk_tools::TiledPictureRenderer* tiledRenderer = renderer->getTiledRenderer();
338 if (NULL == tiledRenderer) {
339 gLogger.logError("--timeIndividualTiles requires tiled rendering.\n");
340 exit(-1);
341 }
342 if (!tiledRenderer->supportsTimingIndividualTiles()) {
343 gLogger.logError("This renderer does not support --timeIndividualTiles.\n");
344 exit(-1);
345 }
346 benchmark->setTimeIndividualTiles(true);
347 }
348
scroggo@google.com604e0c22013-04-09 21:25:46 +0000349 if (FLAGS_readPath.count() < 1) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000350 gLogger.logError(".skp files or directories are required.\n");
351 exit(-1);
352 }
353
caryclark@google.coma3622372012-11-06 21:26:13 +0000354 renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000355 benchmark->setPrintMin(FLAGS_min);
356 benchmark->setLogPerIter(FLAGS_logPerIter);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000357 benchmark->setRenderer(renderer);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000358 benchmark->setRepeats(FLAGS_repeat);
scroggo@google.com9a412522012-09-07 15:21:18 +0000359 benchmark->setLogger(&gLogger);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000360}
reed@google.com006db0f2012-06-27 19:33:29 +0000361
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000362static int process_input(const char* input,
borenet@google.com66bcbd12012-09-17 18:26:06 +0000363 sk_tools::PictureBenchmark& benchmark) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000364 SkString inputAsSkString(input);
365 SkOSFile::Iter iter(input, "skp");
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000366 SkString inputFilename;
borenet@google.com66bcbd12012-09-17 18:26:06 +0000367 int failures = 0;
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000368 if (iter.next(&inputFilename)) {
369 do {
370 SkString inputPath;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000371 sk_tools::make_filepath(&inputPath, inputAsSkString, inputFilename);
borenet@google.com57837bf2012-09-19 17:28:29 +0000372 if (!run_single_benchmark(inputPath, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000373 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000374 }
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000375 } while(iter.next(&inputFilename));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000376 } else if (SkStrEndsWith(input, ".skp")) {
377 if (!run_single_benchmark(inputAsSkString, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000378 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000379 }
380 } else {
381 SkString warning;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000382 warning.printf("Warning: skipping %s\n", input);
borenet@google.com57837bf2012-09-19 17:28:29 +0000383 gLogger.logError(warning);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000384 }
borenet@google.com66bcbd12012-09-17 18:26:06 +0000385 return failures;
reed@google.com006db0f2012-06-27 19:33:29 +0000386}
387
caryclark@google.com5987f582012-10-02 18:33:14 +0000388int tool_main(int argc, char** argv);
389int tool_main(int argc, char** argv) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000390 SkString usage;
391 usage.printf("Time drawing .skp files.\n"
392 "\tPossible arguments for --filter: [%s]\n\t\t[%s]",
393 filterTypesUsage().c_str(), filterFlagsUsage().c_str());
scroggo@google.comd9ba9a02013-03-21 19:43:15 +0000394 SkCommandLineFlags::SetUsage(usage.c_str());
395 SkCommandLineFlags::Parse(argc, argv);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000396
397 if (FLAGS_repeat < 1) {
398 SkString error;
399 error.printf("--repeats must be >= 1. Was %i\n", FLAGS_repeat);
400 gLogger.logError(error);
401 exit(-1);
402 }
403
404 if (FLAGS_logFile.count() == 1) {
405 if (!gLogger.SetLogFile(FLAGS_logFile[0])) {
406 SkString str;
407 str.printf("Could not open %s for writing.\n", FLAGS_logFile[0]);
408 gLogger.logError(str);
409 // TODO(borenet): We're disabling this for now, due to
410 // write-protected Android devices. The very short-term
411 // solution is to ignore the fact that we have no log file.
412 //exit(-1);
413 }
414 }
415
416
bsalomon@google.com4e230682013-01-15 20:37:04 +0000417#if SK_ENABLE_INST_COUNT
scroggo@google.com5239c322012-09-11 19:15:32 +0000418 gPrintInstCount = true;
419#endif
scroggo@google.com0a36f432012-09-10 20:29:13 +0000420 SkAutoGraphics ag;
reed@google.com006db0f2012-06-27 19:33:29 +0000421
scroggo@google.com5239c322012-09-11 19:15:32 +0000422 sk_tools::PictureBenchmark benchmark;
423
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000424 setup_benchmark(&benchmark);
reed@google.com006db0f2012-06-27 19:33:29 +0000425
borenet@google.com66bcbd12012-09-17 18:26:06 +0000426 int failures = 0;
scroggo@google.com604e0c22013-04-09 21:25:46 +0000427 for (int i = 0; i < FLAGS_readPath.count(); ++i) {
428 failures += process_input(FLAGS_readPath[i], benchmark);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000429 }
430
431 if (failures != 0) {
432 SkString err;
433 err.printf("Failed to run %i benchmarks.\n", failures);
434 gLogger.logError(err);
435 return 1;
reed@google.com006db0f2012-06-27 19:33:29 +0000436 }
scroggo@google.comcc690202013-03-04 19:56:21 +0000437#if LAZY_CACHE_STATS
438 if (FLAGS_trackDeferredCaching) {
439 SkDebugf("Total cache hit rate: %f\n",
440 (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses));
441 }
442#endif
caryclark@google.com868e1f62012-10-02 20:00:03 +0000443 return 0;
reed@google.com006db0f2012-06-27 19:33:29 +0000444}
caryclark@google.com5987f582012-10-02 18:33:14 +0000445
446#if !defined SK_BUILD_FOR_IOS
447int main(int argc, char * const argv[]) {
448 return tool_main(argc, (char**) argv);
449}
450#endif