blob: d027db96333aea524fd6177d9f52873573b6bdde [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.comf8d7d272013-02-22 21:38:35 +000013#include "SkBitmapFactory.h"
reed@google.com006db0f2012-06-27 19:33:29 +000014#include "SkCanvas.h"
scroggo@google.com161e1ba2013-03-04 16:41:06 +000015#include "SkFlags.h"
scroggo@google.com0a36f432012-09-10 20:29:13 +000016#include "SkGraphics.h"
scroggo@google.com5a7c6be2012-10-04 21:46:08 +000017#include "SkImageDecoder.h"
keyar@chromium.orgf4959ab2012-08-23 20:53:25 +000018#include "SkMath.h"
reed@google.com006db0f2012-06-27 19:33:29 +000019#include "SkOSFile.h"
20#include "SkPicture.h"
21#include "SkStream.h"
22#include "SkTArray.h"
23#include "picture_utils.h"
24
scroggo@google.com161e1ba2013-03-04 16:41:06 +000025
26SkBenchLogger gLogger;
27
28// Flags used by this file, in alphabetical order.
scroggo@google.coma560d00b2013-03-04 21:32:32 +000029DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp file");
scroggo@google.com161e1ba2013-03-04 16:41:06 +000030DECLARE_bool(deferImageDecoding);
31DEFINE_string(filter, "",
32 "type:flag : Enable canvas filtering to disable a paint flag, "
33 "use no blur or low quality blur, or use no hinting or "
34 "slight hinting. For all flags except AAClip, specify the "
35 "type of primitive to effect, or choose all. for AAClip "
36 "alone, the filter affects all clips independent of type. "
37 "Specific flags are listed above.");
38DEFINE_string(logFile, "", "Destination for writing log output, in addition to stdout.");
39DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean.");
40DEFINE_bool(min, false, "Print the minimum times (instead of average).");
41DECLARE_int32(multi);
42DECLARE_string(r);
43DEFINE_int32(repeat, 1, "Set the number of times to repeat each test.");
44DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual tiles, rather than "
45 "times for drawing the whole page. Requires tiled rendering.");
46DEFINE_string(timers, "", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or truncated cpu time"
47 " for each picture.");
scroggo@google.comcc690202013-03-04 19:56:21 +000048DEFINE_bool(trackDeferredCaching, false, "Only meaningful with --deferImageDecoding and "
49 "LAZY_CACHE_STATS set to true. Report percentage of cache hits when using deferred "
50 "image decoding.");
reed@google.com006db0f2012-06-27 19:33:29 +000051
caryclark@google.coma3622372012-11-06 21:26:13 +000052static char const * const gFilterTypes[] = {
53 "paint",
54 "point",
55 "line",
56 "bitmap",
57 "rect",
jvanverth@google.comd3c208c2013-01-22 13:54:52 +000058 "oval",
caryclark@google.coma3622372012-11-06 21:26:13 +000059 "path",
60 "text",
61 "all",
62};
63
64static const size_t kFilterTypesCount = sizeof(gFilterTypes) / sizeof(gFilterTypes[0]);
65
66static char const * const gFilterFlags[] = {
67 "antiAlias",
68 "filterBitmap",
69 "dither",
70 "underlineText",
71 "strikeThruText",
72 "fakeBoldText",
73 "linearText",
74 "subpixelText",
75 "devKernText",
76 "LCDRenderText",
77 "embeddedBitmapText",
78 "autoHinting",
79 "verticalText",
80 "genA8FromLCD",
81 "blur",
82 "hinting",
83 "slightHinting",
caryclark@google.come3e940c2012-11-07 16:42:17 +000084 "AAClip",
caryclark@google.coma3622372012-11-06 21:26:13 +000085};
86
87static const size_t kFilterFlagsCount = sizeof(gFilterFlags) / sizeof(gFilterFlags[0]);
88
89static SkString filtersName(sk_tools::PictureRenderer::DrawFilterFlags* drawFilters) {
90 int all = drawFilters[0];
91 size_t tIndex;
92 for (tIndex = 1; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
93 all &= drawFilters[tIndex];
94 }
95 SkString result;
96 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
97 SkString types;
98 if (all & (1 << fIndex)) {
99 types = gFilterTypes[SkDrawFilter::kTypeCount];
100 } else {
101 for (tIndex = 0; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
102 if (drawFilters[tIndex] & (1 << fIndex)) {
103 types += gFilterTypes[tIndex];
104 }
105 }
106 }
107 if (!types.size()) {
108 continue;
109 }
110 result += "_";
111 result += types;
112 result += ".";
113 result += gFilterFlags[fIndex];
114 }
115 return result;
116}
117
118static SkString filterTypesUsage() {
119 SkString result;
120 for (size_t index = 0; index < kFilterTypesCount; ++index) {
121 result += gFilterTypes[index];
122 if (index < kFilterTypesCount - 1) {
123 result += " | ";
124 }
125 }
126 return result;
127}
128
129static SkString filterFlagsUsage() {
130 SkString result;
131 size_t len = 0;
132 for (size_t index = 0; index < kFilterFlagsCount; ++index) {
133 result += gFilterFlags[index];
134 if (result.size() - len >= 72) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000135 result += "\n\t\t";
caryclark@google.coma3622372012-11-06 21:26:13 +0000136 len = result.size();
137 }
138 if (index < kFilterFlagsCount - 1) {
139 result += " | ";
140 }
141 }
142 return result;
143}
144
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000145#include "SkData.h"
146#include "SkLruImageCache.h"
scroggo@google.comcc690202013-03-04 19:56:21 +0000147#include "SkLazyPixelRef.h"
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000148
149static SkLruImageCache gLruImageCache(1024*1024);
150
151static bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap) {
152 void* copiedBuffer = sk_malloc_throw(size);
153 memcpy(copiedBuffer, buffer, size);
154 SkAutoDataUnref data(SkData::NewFromMalloc(copiedBuffer, size));
155 SkBitmapFactory factory(&SkImageDecoder::DecodeMemoryToTarget);
156 factory.setImageCache(&gLruImageCache);
157 return factory.installPixelRef(data, bitmap);
158}
159
scroggo@google.comcc690202013-03-04 19:56:21 +0000160#if LAZY_CACHE_STATS
161static int32_t gTotalCacheHits;
162static int32_t gTotalCacheMisses;
163#endif
164
borenet@google.com66bcbd12012-09-17 18:26:06 +0000165static bool run_single_benchmark(const SkString& inputPath,
keyar@chromium.org163b5672012-08-01 17:53:29 +0000166 sk_tools::PictureBenchmark& benchmark) {
reed@google.com006db0f2012-06-27 19:33:29 +0000167 SkFILEStream inputStream;
168
reed@google.com006db0f2012-06-27 19:33:29 +0000169 inputStream.setPath(inputPath.c_str());
170 if (!inputStream.isValid()) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000171 SkString err;
172 err.printf("Could not open file %s\n", inputPath.c_str());
173 gLogger.logError(err);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000174 return false;
reed@google.com006db0f2012-06-27 19:33:29 +0000175 }
176
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000177 // Since the old picture has been deleted, all pixels should be cleared.
178 SkASSERT(gLruImageCache.getImageCacheUsed() == 0);
179 if (FLAGS_countRAM) {
180 // Set the limit to zero, so all pixels will be kept
181 gLruImageCache.setImageCacheLimit(0);
182 }
183
borenet@google.com66bcbd12012-09-17 18:26:06 +0000184 bool success = false;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000185 SkPicture* picture;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000186 if (FLAGS_deferImageDecoding) {
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000187 picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &lazy_decode_bitmap));
188 } else {
189 picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &SkImageDecoder::DecodeMemory));
190 }
191 SkAutoTDelete<SkPicture> ad(picture);
192
borenet@google.com66bcbd12012-09-17 18:26:06 +0000193 if (!success) {
194 SkString err;
195 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
196 gLogger.logError(err);
197 return false;
198 }
reed@google.com006db0f2012-06-27 19:33:29 +0000199
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000200 SkString filename;
201 sk_tools::get_basename(&filename, inputPath);
keyar@chromium.orgdb9a5fb2012-08-21 17:57:59 +0000202
203 SkString result;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000204 result.printf("running bench [%i %i] %s ", picture->width(), picture->height(),
205 filename.c_str());
scroggo@google.com9a412522012-09-07 15:21:18 +0000206 gLogger.logProgress(result);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000207
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000208 benchmark.run(picture);
scroggo@google.comcc690202013-03-04 19:56:21 +0000209
210#if LAZY_CACHE_STATS
211 if (FLAGS_trackDeferredCaching) {
212 int32_t cacheHits = SkLazyPixelRef::GetCacheHits();
213 int32_t cacheMisses = SkLazyPixelRef::GetCacheMisses();
214 SkLazyPixelRef::ResetCacheStats();
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000215 SkString hitString;
216 hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
217 gLogger.logProgress(hitString);
scroggo@google.comcc690202013-03-04 19:56:21 +0000218 gTotalCacheHits += cacheHits;
219 gTotalCacheMisses += cacheMisses;
220 }
221#endif
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000222 if (FLAGS_countRAM) {
223 SkString ramCount("RAM used for bitmaps: ");
224 size_t bytes = gLruImageCache.getImageCacheUsed();
225 if (bytes > 1024) {
226 size_t kb = bytes / 1024;
227 if (kb > 1024) {
228 size_t mb = kb / 1024;
229 ramCount.appendf("%zi MB\n", mb);
230 } else {
231 ramCount.appendf("%zi KB\n", kb);
232 }
233 } else {
234 ramCount.appendf("%zi bytes\n", bytes);
235 }
236 gLogger.logProgress(ramCount);
237 }
scroggo@google.comcc690202013-03-04 19:56:21 +0000238
borenet@google.com66bcbd12012-09-17 18:26:06 +0000239 return true;
keyar@chromium.org0665f252012-07-10 18:30:18 +0000240}
241
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000242static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
caryclark@google.coma3622372012-11-06 21:26:13 +0000243 sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
244 sk_bzero(drawFilters, sizeof(drawFilters));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000245
246 if (FLAGS_filter.count() > 0) {
247 const char* filters = FLAGS_filter[0];
248 const char* colon = strchr(filters, ':');
249 if (colon) {
scroggo@google.comcc690202013-03-04 19:56:21 +0000250 int32_t type = -1;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000251 size_t typeLen = colon - filters;
252 for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
253 if (typeLen == strlen(gFilterTypes[tIndex])
254 && !strncmp(filters, gFilterTypes[tIndex], typeLen)) {
scroggo@google.comcc690202013-03-04 19:56:21 +0000255 type = SkToS32(tIndex);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000256 break;
reed@google.com006db0f2012-06-27 19:33:29 +0000257 }
reed@google.com006db0f2012-06-27 19:33:29 +0000258 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000259 if (type < 0) {
junov@chromium.org9313ca42012-11-02 18:11:49 +0000260 SkString err;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000261 err.printf("Unknown type for --filter %s\n", filters);
junov@chromium.org9313ca42012-11-02 18:11:49 +0000262 gLogger.logError(err);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000263 exit(-1);
junov@chromium.org9313ca42012-11-02 18:11:49 +0000264 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000265 int flag = -1;
266 size_t flagLen = strlen(filters) - typeLen - 1;
267 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
268 if (flagLen == strlen(gFilterFlags[fIndex])
269 && !strncmp(colon + 1, gFilterFlags[fIndex], flagLen)) {
270 flag = 1 << fIndex;
271 break;
272 }
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000273 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000274 if (flag < 0) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000275 SkString err;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000276 err.printf("Unknown flag for --filter %s\n", filters);
scroggo@google.com9a412522012-09-07 15:21:18 +0000277 gLogger.logError(err);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000278 exit(-1);
reed@google.com006db0f2012-06-27 19:33:29 +0000279 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000280 for (int index = 0; index < SkDrawFilter::kTypeCount; ++index) {
281 if (type != SkDrawFilter::kTypeCount && index != type) {
282 continue;
scroggo@google.com5239c322012-09-11 19:15:32 +0000283 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000284 drawFilters[index] = (sk_tools::PictureRenderer::DrawFilterFlags)
285 (drawFilters[index] | flag);
scroggo@google.com5239c322012-09-11 19:15:32 +0000286 }
reed@google.com006db0f2012-06-27 19:33:29 +0000287 } else {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000288 SkString err;
289 err.printf("Unknown arg for --filter %s : missing colon\n", filters);
290 gLogger.logError(err);
291 exit(-1);
reed@google.com006db0f2012-06-27 19:33:29 +0000292 }
293 }
294
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000295 if (FLAGS_timers.count() > 0) {
296 size_t index = 0;
297 bool timerWall = false;
298 bool truncatedTimerWall = false;
299 bool timerCpu = false;
300 bool truncatedTimerCpu = false;
301 bool timerGpu = false;
302 while (index < strlen(FLAGS_timers[0])) {
303 switch (FLAGS_timers[0][index]) {
304 case 'w':
305 timerWall = true;
306 break;
307 case 'c':
308 timerCpu = true;
309 break;
310 case 'W':
311 truncatedTimerWall = true;
312 break;
313 case 'C':
314 truncatedTimerCpu = true;
315 break;
316 case 'g':
317 timerGpu = true;
scroggo@google.com0556ea02013-02-08 19:38:21 +0000318 break;
319 default:
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000320 SkDebugf("mystery character\n");
scroggo@google.com0556ea02013-02-08 19:38:21 +0000321 break;
322 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000323 index++;
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000324 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000325 benchmark->setTimersToShow(timerWall, truncatedTimerWall, timerCpu, truncatedTimerCpu,
326 timerGpu);
reed@google.com006db0f2012-06-27 19:33:29 +0000327 }
keyar@chromium.org163b5672012-08-01 17:53:29 +0000328
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000329 SkString errorString;
330 SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
331 kBench_PictureTool));
332
333 if (errorString.size() > 0) {
334 gLogger.logError(errorString);
keyar@chromium.org163b5672012-08-01 17:53:29 +0000335 }
junov@chromium.org9313ca42012-11-02 18:11:49 +0000336
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000337 if (NULL == renderer.get()) {
338 exit(-1);
339 }
340
341 if (FLAGS_timeIndividualTiles) {
342 if (FLAGS_multi > 1) {
343 gLogger.logError("Cannot time individual tiles with more than one thread.\n");
344 exit(-1);
345 }
346 sk_tools::TiledPictureRenderer* tiledRenderer = renderer->getTiledRenderer();
347 if (NULL == tiledRenderer) {
348 gLogger.logError("--timeIndividualTiles requires tiled rendering.\n");
349 exit(-1);
350 }
351 if (!tiledRenderer->supportsTimingIndividualTiles()) {
352 gLogger.logError("This renderer does not support --timeIndividualTiles.\n");
353 exit(-1);
354 }
355 benchmark->setTimeIndividualTiles(true);
356 }
357
358 if (FLAGS_r.count() < 1) {
359 gLogger.logError(".skp files or directories are required.\n");
360 exit(-1);
361 }
362
caryclark@google.coma3622372012-11-06 21:26:13 +0000363 renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000364 benchmark->setPrintMin(FLAGS_min);
365 benchmark->setLogPerIter(FLAGS_logPerIter);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000366 benchmark->setRenderer(renderer);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000367 benchmark->setRepeats(FLAGS_repeat);
scroggo@google.com9a412522012-09-07 15:21:18 +0000368 benchmark->setLogger(&gLogger);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000369}
reed@google.com006db0f2012-06-27 19:33:29 +0000370
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000371static int process_input(const char* input,
borenet@google.com66bcbd12012-09-17 18:26:06 +0000372 sk_tools::PictureBenchmark& benchmark) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000373 SkString inputAsSkString(input);
374 SkOSFile::Iter iter(input, "skp");
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000375 SkString inputFilename;
borenet@google.com66bcbd12012-09-17 18:26:06 +0000376 int failures = 0;
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000377 if (iter.next(&inputFilename)) {
378 do {
379 SkString inputPath;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000380 sk_tools::make_filepath(&inputPath, inputAsSkString, inputFilename);
borenet@google.com57837bf2012-09-19 17:28:29 +0000381 if (!run_single_benchmark(inputPath, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000382 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000383 }
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000384 } while(iter.next(&inputFilename));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000385 } else if (SkStrEndsWith(input, ".skp")) {
386 if (!run_single_benchmark(inputAsSkString, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000387 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000388 }
389 } else {
390 SkString warning;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000391 warning.printf("Warning: skipping %s\n", input);
borenet@google.com57837bf2012-09-19 17:28:29 +0000392 gLogger.logError(warning);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000393 }
borenet@google.com66bcbd12012-09-17 18:26:06 +0000394 return failures;
reed@google.com006db0f2012-06-27 19:33:29 +0000395}
396
caryclark@google.com5987f582012-10-02 18:33:14 +0000397int tool_main(int argc, char** argv);
398int tool_main(int argc, char** argv) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000399 SkString usage;
400 usage.printf("Time drawing .skp files.\n"
401 "\tPossible arguments for --filter: [%s]\n\t\t[%s]",
402 filterTypesUsage().c_str(), filterFlagsUsage().c_str());
403 SkFlags::SetUsage(usage.c_str());
404 SkFlags::ParseCommandLine(argc, argv);
405
406 if (FLAGS_repeat < 1) {
407 SkString error;
408 error.printf("--repeats must be >= 1. Was %i\n", FLAGS_repeat);
409 gLogger.logError(error);
410 exit(-1);
411 }
412
413 if (FLAGS_logFile.count() == 1) {
414 if (!gLogger.SetLogFile(FLAGS_logFile[0])) {
415 SkString str;
416 str.printf("Could not open %s for writing.\n", FLAGS_logFile[0]);
417 gLogger.logError(str);
418 // TODO(borenet): We're disabling this for now, due to
419 // write-protected Android devices. The very short-term
420 // solution is to ignore the fact that we have no log file.
421 //exit(-1);
422 }
423 }
424
425
bsalomon@google.com4e230682013-01-15 20:37:04 +0000426#if SK_ENABLE_INST_COUNT
scroggo@google.com5239c322012-09-11 19:15:32 +0000427 gPrintInstCount = true;
428#endif
scroggo@google.com0a36f432012-09-10 20:29:13 +0000429 SkAutoGraphics ag;
reed@google.com006db0f2012-06-27 19:33:29 +0000430
scroggo@google.com5239c322012-09-11 19:15:32 +0000431 sk_tools::PictureBenchmark benchmark;
432
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000433 setup_benchmark(&benchmark);
reed@google.com006db0f2012-06-27 19:33:29 +0000434
borenet@google.com66bcbd12012-09-17 18:26:06 +0000435 int failures = 0;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000436 for (int i = 0; i < FLAGS_r.count(); ++i) {
437 failures += process_input(FLAGS_r[i], benchmark);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000438 }
439
440 if (failures != 0) {
441 SkString err;
442 err.printf("Failed to run %i benchmarks.\n", failures);
443 gLogger.logError(err);
444 return 1;
reed@google.com006db0f2012-06-27 19:33:29 +0000445 }
scroggo@google.comcc690202013-03-04 19:56:21 +0000446#if LAZY_CACHE_STATS
447 if (FLAGS_trackDeferredCaching) {
448 SkDebugf("Total cache hit rate: %f\n",
449 (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses));
450 }
451#endif
caryclark@google.com868e1f62012-10-02 20:00:03 +0000452 return 0;
reed@google.com006db0f2012-06-27 19:33:29 +0000453}
caryclark@google.com5987f582012-10-02 18:33:14 +0000454
455#if !defined SK_BUILD_FOR_IOS
456int main(int argc, char * const argv[]) {
457 return tool_main(argc, (char**) argv);
458}
459#endif