blob: 31d432daa93145a8d3b25889de6196b72e454f0e [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"
commit-bot@chromium.org56799e22013-07-16 18:21:46 +000010#include "LazyDecodeBitmap.h"
keyar@chromium.org163b5672012-08-01 17:53:29 +000011#include "PictureBenchmark.h"
scroggo@google.com161e1ba2013-03-04 16:41:06 +000012#include "PictureRenderingFlags.h"
scroggo@google.com9a412522012-09-07 15:21:18 +000013#include "SkBenchLogger.h"
scroggo@google.comd9ba9a02013-03-21 19:43:15 +000014#include "SkCommandLineFlags.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.com161e1ba2013-03-04 16:41:06 +000027SkBenchLogger gLogger;
28
29// Flags used by this file, in alphabetical order.
scroggo@google.coma560d00b2013-03-04 21:32:32 +000030DEFINE_bool(countRAM, false, "Count the RAM used for bitmap pixels in each skp file");
scroggo@google.com161e1ba2013-03-04 16:41:06 +000031DECLARE_bool(deferImageDecoding);
32DEFINE_string(filter, "",
33 "type:flag : Enable canvas filtering to disable a paint flag, "
34 "use no blur or low quality blur, or use no hinting or "
35 "slight hinting. For all flags except AAClip, specify the "
36 "type of primitive to effect, or choose all. for AAClip "
37 "alone, the filter affects all clips independent of type. "
38 "Specific flags are listed above.");
39DEFINE_string(logFile, "", "Destination for writing log output, in addition to stdout.");
40DEFINE_bool(logPerIter, false, "Log each repeat timer instead of mean.");
41DEFINE_bool(min, false, "Print the minimum times (instead of average).");
42DECLARE_int32(multi);
scroggo@google.com604e0c22013-04-09 21:25:46 +000043DECLARE_string(readPath);
scroggo@google.com161e1ba2013-03-04 16:41:06 +000044DEFINE_int32(repeat, 1, "Set the number of times to repeat each test.");
45DEFINE_bool(timeIndividualTiles, false, "Report times for drawing individual tiles, rather than "
46 "times for drawing the whole page. Requires tiled rendering.");
scroggo@google.com65e508d2013-08-02 16:09:10 +000047DEFINE_string(timers, "c", "[wcgWC]*: Display wall, cpu, gpu, truncated wall or truncated cpu time"
scroggo@google.com161e1ba2013-03-04 16:41:06 +000048 " for each picture.");
scroggo@google.comcc690202013-03-04 19:56:21 +000049DEFINE_bool(trackDeferredCaching, false, "Only meaningful with --deferImageDecoding and "
50 "LAZY_CACHE_STATS set to true. Report percentage of cache hits when using deferred "
51 "image decoding.");
reed@google.com006db0f2012-06-27 19:33:29 +000052
caryclark@google.coma3622372012-11-06 21:26:13 +000053static char const * const gFilterTypes[] = {
54 "paint",
55 "point",
56 "line",
57 "bitmap",
58 "rect",
jvanverth@google.comd3c208c2013-01-22 13:54:52 +000059 "oval",
caryclark@google.coma3622372012-11-06 21:26:13 +000060 "path",
61 "text",
62 "all",
63};
64
65static const size_t kFilterTypesCount = sizeof(gFilterTypes) / sizeof(gFilterTypes[0]);
66
67static char const * const gFilterFlags[] = {
68 "antiAlias",
69 "filterBitmap",
70 "dither",
71 "underlineText",
72 "strikeThruText",
73 "fakeBoldText",
74 "linearText",
75 "subpixelText",
76 "devKernText",
77 "LCDRenderText",
78 "embeddedBitmapText",
79 "autoHinting",
80 "verticalText",
81 "genA8FromLCD",
82 "blur",
83 "hinting",
84 "slightHinting",
caryclark@google.come3e940c2012-11-07 16:42:17 +000085 "AAClip",
caryclark@google.coma3622372012-11-06 21:26:13 +000086};
87
88static const size_t kFilterFlagsCount = sizeof(gFilterFlags) / sizeof(gFilterFlags[0]);
89
90static SkString filtersName(sk_tools::PictureRenderer::DrawFilterFlags* drawFilters) {
91 int all = drawFilters[0];
92 size_t tIndex;
93 for (tIndex = 1; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
94 all &= drawFilters[tIndex];
95 }
96 SkString result;
97 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
98 SkString types;
99 if (all & (1 << fIndex)) {
100 types = gFilterTypes[SkDrawFilter::kTypeCount];
101 } else {
102 for (tIndex = 0; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
103 if (drawFilters[tIndex] & (1 << fIndex)) {
104 types += gFilterTypes[tIndex];
105 }
106 }
107 }
108 if (!types.size()) {
109 continue;
110 }
111 result += "_";
112 result += types;
113 result += ".";
114 result += gFilterFlags[fIndex];
115 }
116 return result;
117}
118
119static SkString filterTypesUsage() {
120 SkString result;
121 for (size_t index = 0; index < kFilterTypesCount; ++index) {
122 result += gFilterTypes[index];
123 if (index < kFilterTypesCount - 1) {
124 result += " | ";
125 }
126 }
127 return result;
128}
129
130static SkString filterFlagsUsage() {
131 SkString result;
132 size_t len = 0;
133 for (size_t index = 0; index < kFilterFlagsCount; ++index) {
134 result += gFilterFlags[index];
135 if (result.size() - len >= 72) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000136 result += "\n\t\t";
caryclark@google.coma3622372012-11-06 21:26:13 +0000137 len = result.size();
138 }
139 if (index < kFilterFlagsCount - 1) {
140 result += " | ";
141 }
142 }
143 return result;
144}
145
commit-bot@chromium.org56799e22013-07-16 18:21:46 +0000146// Defined in LazyDecodeBitmap.cpp
scroggo@google.combb281f72013-03-18 21:37:39 +0000147extern SkLruImageCache gLruImageCache;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000148
scroggo@google.comcc690202013-03-04 19:56:21 +0000149#if LAZY_CACHE_STATS
150static int32_t gTotalCacheHits;
151static int32_t gTotalCacheMisses;
152#endif
153
borenet@google.com66bcbd12012-09-17 18:26:06 +0000154static bool run_single_benchmark(const SkString& inputPath,
keyar@chromium.org163b5672012-08-01 17:53:29 +0000155 sk_tools::PictureBenchmark& benchmark) {
reed@google.com006db0f2012-06-27 19:33:29 +0000156 SkFILEStream inputStream;
157
reed@google.com006db0f2012-06-27 19:33:29 +0000158 inputStream.setPath(inputPath.c_str());
159 if (!inputStream.isValid()) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000160 SkString err;
161 err.printf("Could not open file %s\n", inputPath.c_str());
162 gLogger.logError(err);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000163 return false;
reed@google.com006db0f2012-06-27 19:33:29 +0000164 }
165
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000166 // Since the old picture has been deleted, all pixels should be cleared.
167 SkASSERT(gLruImageCache.getImageCacheUsed() == 0);
168 if (FLAGS_countRAM) {
169 // Set the limit to zero, so all pixels will be kept
commit-bot@chromium.org56799e22013-07-16 18:21:46 +0000170 gLruImageCache.setImageCacheLimit(0);
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000171 }
172
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000173 SkPicture::InstallPixelRefProc proc;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000174 if (FLAGS_deferImageDecoding) {
commit-bot@chromium.org56799e22013-07-16 18:21:46 +0000175 proc = &sk_tools::LazyDecodeBitmap;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000176 } else {
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000177 proc = &SkImageDecoder::DecodeMemory;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000178 }
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000179 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000180
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000181 if (NULL == picture.get()) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000182 SkString err;
183 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
184 gLogger.logError(err);
185 return false;
186 }
reed@google.com006db0f2012-06-27 19:33:29 +0000187
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000188 SkString filename;
189 sk_tools::get_basename(&filename, inputPath);
keyar@chromium.orgdb9a5fb2012-08-21 17:57:59 +0000190
191 SkString result;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000192 result.printf("running bench [%i %i] %s ", picture->width(), picture->height(),
193 filename.c_str());
scroggo@google.com9a412522012-09-07 15:21:18 +0000194 gLogger.logProgress(result);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000195
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000196 benchmark.run(picture);
scroggo@google.comcc690202013-03-04 19:56:21 +0000197
198#if LAZY_CACHE_STATS
199 if (FLAGS_trackDeferredCaching) {
200 int32_t cacheHits = SkLazyPixelRef::GetCacheHits();
201 int32_t cacheMisses = SkLazyPixelRef::GetCacheMisses();
202 SkLazyPixelRef::ResetCacheStats();
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000203 SkString hitString;
204 hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
205 gLogger.logProgress(hitString);
scroggo@google.comcc690202013-03-04 19:56:21 +0000206 gTotalCacheHits += cacheHits;
207 gTotalCacheMisses += cacheMisses;
208 }
209#endif
scroggo@google.coma560d00b2013-03-04 21:32:32 +0000210 if (FLAGS_countRAM) {
211 SkString ramCount("RAM used for bitmaps: ");
212 size_t bytes = gLruImageCache.getImageCacheUsed();
213 if (bytes > 1024) {
214 size_t kb = bytes / 1024;
215 if (kb > 1024) {
216 size_t mb = kb / 1024;
217 ramCount.appendf("%zi MB\n", mb);
218 } else {
219 ramCount.appendf("%zi KB\n", kb);
220 }
221 } else {
222 ramCount.appendf("%zi bytes\n", bytes);
223 }
224 gLogger.logProgress(ramCount);
225 }
scroggo@google.comcc690202013-03-04 19:56:21 +0000226
borenet@google.com66bcbd12012-09-17 18:26:06 +0000227 return true;
keyar@chromium.org0665f252012-07-10 18:30:18 +0000228}
229
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000230static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
caryclark@google.coma3622372012-11-06 21:26:13 +0000231 sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
232 sk_bzero(drawFilters, sizeof(drawFilters));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000233
234 if (FLAGS_filter.count() > 0) {
235 const char* filters = FLAGS_filter[0];
236 const char* colon = strchr(filters, ':');
237 if (colon) {
scroggo@google.comcc690202013-03-04 19:56:21 +0000238 int32_t type = -1;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000239 size_t typeLen = colon - filters;
240 for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
241 if (typeLen == strlen(gFilterTypes[tIndex])
242 && !strncmp(filters, gFilterTypes[tIndex], typeLen)) {
scroggo@google.comcc690202013-03-04 19:56:21 +0000243 type = SkToS32(tIndex);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000244 break;
reed@google.com006db0f2012-06-27 19:33:29 +0000245 }
reed@google.com006db0f2012-06-27 19:33:29 +0000246 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000247 if (type < 0) {
junov@chromium.org9313ca42012-11-02 18:11:49 +0000248 SkString err;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000249 err.printf("Unknown type for --filter %s\n", filters);
junov@chromium.org9313ca42012-11-02 18:11:49 +0000250 gLogger.logError(err);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000251 exit(-1);
junov@chromium.org9313ca42012-11-02 18:11:49 +0000252 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000253 int flag = -1;
254 size_t flagLen = strlen(filters) - typeLen - 1;
255 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
256 if (flagLen == strlen(gFilterFlags[fIndex])
257 && !strncmp(colon + 1, gFilterFlags[fIndex], flagLen)) {
258 flag = 1 << fIndex;
259 break;
260 }
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000261 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000262 if (flag < 0) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000263 SkString err;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000264 err.printf("Unknown flag for --filter %s\n", filters);
scroggo@google.com9a412522012-09-07 15:21:18 +0000265 gLogger.logError(err);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000266 exit(-1);
reed@google.com006db0f2012-06-27 19:33:29 +0000267 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000268 for (int index = 0; index < SkDrawFilter::kTypeCount; ++index) {
269 if (type != SkDrawFilter::kTypeCount && index != type) {
270 continue;
scroggo@google.com5239c322012-09-11 19:15:32 +0000271 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000272 drawFilters[index] = (sk_tools::PictureRenderer::DrawFilterFlags)
273 (drawFilters[index] | flag);
scroggo@google.com5239c322012-09-11 19:15:32 +0000274 }
reed@google.com006db0f2012-06-27 19:33:29 +0000275 } else {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000276 SkString err;
277 err.printf("Unknown arg for --filter %s : missing colon\n", filters);
278 gLogger.logError(err);
279 exit(-1);
reed@google.com006db0f2012-06-27 19:33:29 +0000280 }
281 }
282
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000283 if (FLAGS_timers.count() > 0) {
284 size_t index = 0;
285 bool timerWall = false;
286 bool truncatedTimerWall = false;
287 bool timerCpu = false;
288 bool truncatedTimerCpu = false;
289 bool timerGpu = false;
290 while (index < strlen(FLAGS_timers[0])) {
291 switch (FLAGS_timers[0][index]) {
292 case 'w':
293 timerWall = true;
294 break;
295 case 'c':
296 timerCpu = true;
297 break;
298 case 'W':
299 truncatedTimerWall = true;
300 break;
301 case 'C':
302 truncatedTimerCpu = true;
303 break;
304 case 'g':
305 timerGpu = true;
scroggo@google.com0556ea02013-02-08 19:38:21 +0000306 break;
307 default:
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000308 SkDebugf("mystery character\n");
scroggo@google.com0556ea02013-02-08 19:38:21 +0000309 break;
310 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000311 index++;
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000312 }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000313 benchmark->setTimersToShow(timerWall, truncatedTimerWall, timerCpu, truncatedTimerCpu,
314 timerGpu);
reed@google.com006db0f2012-06-27 19:33:29 +0000315 }
keyar@chromium.org163b5672012-08-01 17:53:29 +0000316
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000317 SkString errorString;
318 SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
319 kBench_PictureTool));
320
321 if (errorString.size() > 0) {
322 gLogger.logError(errorString);
keyar@chromium.org163b5672012-08-01 17:53:29 +0000323 }
junov@chromium.org9313ca42012-11-02 18:11:49 +0000324
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000325 if (NULL == renderer.get()) {
326 exit(-1);
327 }
328
329 if (FLAGS_timeIndividualTiles) {
330 if (FLAGS_multi > 1) {
331 gLogger.logError("Cannot time individual tiles with more than one thread.\n");
332 exit(-1);
333 }
334 sk_tools::TiledPictureRenderer* tiledRenderer = renderer->getTiledRenderer();
335 if (NULL == tiledRenderer) {
336 gLogger.logError("--timeIndividualTiles requires tiled rendering.\n");
337 exit(-1);
338 }
339 if (!tiledRenderer->supportsTimingIndividualTiles()) {
340 gLogger.logError("This renderer does not support --timeIndividualTiles.\n");
341 exit(-1);
342 }
343 benchmark->setTimeIndividualTiles(true);
344 }
345
scroggo@google.com604e0c22013-04-09 21:25:46 +0000346 if (FLAGS_readPath.count() < 1) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000347 gLogger.logError(".skp files or directories are required.\n");
348 exit(-1);
349 }
350
caryclark@google.coma3622372012-11-06 21:26:13 +0000351 renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +0000352 if (FLAGS_logPerIter) {
353 benchmark->setTimerResultType(TimerData::kPerIter_Result);
354 } else if (FLAGS_min) {
355 benchmark->setTimerResultType(TimerData::kMin_Result);
356 } else {
357 benchmark->setTimerResultType(TimerData::kAvg_Result);
358 }
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000359 benchmark->setRenderer(renderer);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000360 benchmark->setRepeats(FLAGS_repeat);
scroggo@google.com9a412522012-09-07 15:21:18 +0000361 benchmark->setLogger(&gLogger);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000362}
reed@google.com006db0f2012-06-27 19:33:29 +0000363
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000364static int process_input(const char* input,
borenet@google.com66bcbd12012-09-17 18:26:06 +0000365 sk_tools::PictureBenchmark& benchmark) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000366 SkString inputAsSkString(input);
367 SkOSFile::Iter iter(input, "skp");
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000368 SkString inputFilename;
borenet@google.com66bcbd12012-09-17 18:26:06 +0000369 int failures = 0;
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000370 if (iter.next(&inputFilename)) {
371 do {
372 SkString inputPath;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000373 sk_tools::make_filepath(&inputPath, inputAsSkString, inputFilename);
borenet@google.com57837bf2012-09-19 17:28:29 +0000374 if (!run_single_benchmark(inputPath, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000375 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000376 }
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000377 } while(iter.next(&inputFilename));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000378 } else if (SkStrEndsWith(input, ".skp")) {
379 if (!run_single_benchmark(inputAsSkString, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000380 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000381 }
382 } else {
383 SkString warning;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000384 warning.printf("Warning: skipping %s\n", input);
borenet@google.com57837bf2012-09-19 17:28:29 +0000385 gLogger.logError(warning);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000386 }
borenet@google.com66bcbd12012-09-17 18:26:06 +0000387 return failures;
reed@google.com006db0f2012-06-27 19:33:29 +0000388}
389
caryclark@google.com5987f582012-10-02 18:33:14 +0000390int tool_main(int argc, char** argv);
391int tool_main(int argc, char** argv) {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000392 SkString usage;
393 usage.printf("Time drawing .skp files.\n"
394 "\tPossible arguments for --filter: [%s]\n\t\t[%s]",
395 filterTypesUsage().c_str(), filterFlagsUsage().c_str());
scroggo@google.comd9ba9a02013-03-21 19:43:15 +0000396 SkCommandLineFlags::SetUsage(usage.c_str());
397 SkCommandLineFlags::Parse(argc, argv);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000398
399 if (FLAGS_repeat < 1) {
400 SkString error;
401 error.printf("--repeats must be >= 1. Was %i\n", FLAGS_repeat);
402 gLogger.logError(error);
403 exit(-1);
404 }
405
406 if (FLAGS_logFile.count() == 1) {
407 if (!gLogger.SetLogFile(FLAGS_logFile[0])) {
408 SkString str;
409 str.printf("Could not open %s for writing.\n", FLAGS_logFile[0]);
410 gLogger.logError(str);
411 // TODO(borenet): We're disabling this for now, due to
412 // write-protected Android devices. The very short-term
413 // solution is to ignore the fact that we have no log file.
414 //exit(-1);
415 }
416 }
417
418
bsalomon@google.com4e230682013-01-15 20:37:04 +0000419#if SK_ENABLE_INST_COUNT
scroggo@google.com5239c322012-09-11 19:15:32 +0000420 gPrintInstCount = true;
421#endif
scroggo@google.com0a36f432012-09-10 20:29:13 +0000422 SkAutoGraphics ag;
reed@google.com006db0f2012-06-27 19:33:29 +0000423
scroggo@google.com5239c322012-09-11 19:15:32 +0000424 sk_tools::PictureBenchmark benchmark;
425
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000426 setup_benchmark(&benchmark);
reed@google.com006db0f2012-06-27 19:33:29 +0000427
borenet@google.com66bcbd12012-09-17 18:26:06 +0000428 int failures = 0;
scroggo@google.com604e0c22013-04-09 21:25:46 +0000429 for (int i = 0; i < FLAGS_readPath.count(); ++i) {
430 failures += process_input(FLAGS_readPath[i], benchmark);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000431 }
432
433 if (failures != 0) {
434 SkString err;
435 err.printf("Failed to run %i benchmarks.\n", failures);
436 gLogger.logError(err);
437 return 1;
reed@google.com006db0f2012-06-27 19:33:29 +0000438 }
scroggo@google.comcc690202013-03-04 19:56:21 +0000439#if LAZY_CACHE_STATS
440 if (FLAGS_trackDeferredCaching) {
441 SkDebugf("Total cache hit rate: %f\n",
442 (double) gTotalCacheHits / (gTotalCacheHits + gTotalCacheMisses));
443 }
444#endif
caryclark@google.com868e1f62012-10-02 20:00:03 +0000445 return 0;
reed@google.com006db0f2012-06-27 19:33:29 +0000446}
caryclark@google.com5987f582012-10-02 18:33:14 +0000447
448#if !defined SK_BUILD_FOR_IOS
449int main(int argc, char * const argv[]) {
450 return tool_main(argc, (char**) argv);
451}
452#endif