OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "BenchTimer.h" | 10 #include "BenchTimer.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 static int findConfig(const char config[]) { | 264 static int findConfig(const char config[]) { |
265 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { | 265 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { |
266 if (!strcmp(config, gConfigs[i].fName)) { | 266 if (!strcmp(config, gConfigs[i].fName)) { |
267 return i; | 267 return i; |
268 } | 268 } |
269 } | 269 } |
270 return -1; | 270 return -1; |
271 } | 271 } |
272 | 272 |
273 static bool skip_name(const SkTDArray<const char*> array, const char name[]) { | 273 static bool skip_name(const SkTDArray<const char*> array, const char name[]) { |
274 if (0 == array.count()) { | 274 // FIXME: this duplicates the logic in skia_test.cpp, gmmain.cpp -- consolid
ate |
275 // no names, so don't skip anything | 275 int count = array.count(); |
276 return false; | 276 size_t testLen = strlen(name); |
277 } | 277 bool anyExclude = count == 0; |
278 for (int i = 0; i < array.count(); ++i) { | 278 for (int i = 0; i < array.count(); ++i) { |
279 if (strstr(name, array[i])) { | 279 const char* matchName = array[i]; |
280 // found the name, so don't skip | 280 size_t matchLen = strlen(matchName); |
281 return false; | 281 bool matchExclude, matchStart, matchEnd; |
| 282 if ((matchExclude = matchName[0] == '~')) { |
| 283 anyExclude = true; |
| 284 matchName++; |
| 285 matchLen--; |
| 286 } |
| 287 if ((matchStart = matchName[0] == '^')) { |
| 288 matchName++; |
| 289 matchLen--; |
| 290 } |
| 291 if ((matchEnd = matchName[matchLen - 1] == '$')) { |
| 292 matchLen--; |
| 293 } |
| 294 if (matchStart ? (!matchEnd || matchLen == testLen) |
| 295 && strncmp(name, matchName, matchLen) == 0 |
| 296 : matchEnd ? matchLen <= testLen |
| 297 && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 |
| 298 : strstr(name, matchName) != 0) { |
| 299 return matchExclude; |
282 } | 300 } |
283 } | 301 } |
284 return true; | 302 return !anyExclude; |
285 } | 303 } |
286 | 304 |
287 static void help() { | 305 static void help() { |
288 SkString configsStr; | 306 SkString configsStr; |
289 static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); | 307 static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); |
290 for (size_t i = 0; i < kConfigCount; ++i) { | 308 for (size_t i = 0; i < kConfigCount; ++i) { |
291 configsStr.appendf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ?
"" : "|")); | 309 configsStr.appendf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ?
"" : "|")); |
292 } | 310 } |
293 | 311 |
294 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] " | 312 SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] " |
(...skipping 27 matching lines...) Expand all Loading... |
322 SkDebugf(" --forceDither 1|0 : " | 340 SkDebugf(" --forceDither 1|0 : " |
323 "Enable/disable dithering, default is disabled.\n"); | 341 "Enable/disable dithering, default is disabled.\n"); |
324 SkDebugf(" --forceBlend 1|0 : " | 342 SkDebugf(" --forceBlend 1|0 : " |
325 "Enable/disable dithering, default is disabled.\n"); | 343 "Enable/disable dithering, default is disabled.\n"); |
326 #if SK_SUPPORT_GPU | 344 #if SK_SUPPORT_GPU |
327 SkDebugf(" --gpuCacheSize <bytes> <count>: " | 345 SkDebugf(" --gpuCacheSize <bytes> <count>: " |
328 "limits gpu cache to bytes size or object count.\n"); | 346 "limits gpu cache to bytes size or object count.\n"); |
329 SkDebugf(" -1 for either value means use the default. 0 for either disa
bles the cache.\n"); | 347 SkDebugf(" -1 for either value means use the default. 0 for either disa
bles the cache.\n"); |
330 #endif | 348 #endif |
331 SkDebugf(" --strokeWidth width : The width for path stroke.\n"); | 349 SkDebugf(" --strokeWidth width : The width for path stroke.\n"); |
332 SkDebugf(" --match name : Only run bench whose name is matched.\n"); | 350 SkDebugf(" --match [~][^]substring[$] [...] of test name to run.\n" |
| 351 " Multiple matches may be separated by spaces.\n" |
| 352 " ~ causes a matching test to always be skipped\n" |
| 353 " ^ requires the start of the test to match\n" |
| 354 " $ requires the end of the test to match\n" |
| 355 " ^ and $ requires an exact match\n" |
| 356 " If a test does not match any list entry,\n" |
| 357 " it is skipped unless some list entry starts with ~\n"
); |
333 SkDebugf(" --mode normal|deferred|deferredSilent|record|picturerecord :\n
" | 358 SkDebugf(" --mode normal|deferred|deferredSilent|record|picturerecord :\n
" |
334 " Run in the corresponding mode\n" | 359 " Run in the corresponding mode\n" |
335 " normal, Use a normal canvas to draw to;\n" | 360 " normal, Use a normal canvas to draw to;\n" |
336 " deferred, Use a deferrred canvas when drawing;\n" | 361 " deferred, Use a deferrred canvas when drawing;\n" |
337 " deferredSilent, deferred with silent playback;\n" | 362 " deferredSilent, deferred with silent playback;\n" |
338 " record, Benchmark the time to record to an SkPict
ure;\n" | 363 " record, Benchmark the time to record to an SkPict
ure;\n" |
339 " picturerecord, Benchmark the time to do record fr
om a \n" | 364 " picturerecord, Benchmark the time to do record fr
om a \n" |
340 " SkPicture to a SkPicture.\n"); | 365 " SkPicture to a SkPicture.\n"); |
341 SkDebugf(" --logFile filename : destination for writing log output, in ad
dition to stdout.\n"); | 366 SkDebugf(" --logFile filename : destination for writing log output, in ad
dition to stdout.\n"); |
342 SkDebugf(" --config %s:\n", configsStr.c_str()); | 367 SkDebugf(" --config %s:\n", configsStr.c_str()); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 return -1; | 544 return -1; |
520 } | 545 } |
521 hasStrokeWidth = true; | 546 hasStrokeWidth = true; |
522 } else { | 547 } else { |
523 logger.logError("missing arg for --strokeWidth\n"); | 548 logger.logError("missing arg for --strokeWidth\n"); |
524 help(); | 549 help(); |
525 return -1; | 550 return -1; |
526 } | 551 } |
527 } else if (strcmp(*argv, "--match") == 0) { | 552 } else if (strcmp(*argv, "--match") == 0) { |
528 argv++; | 553 argv++; |
529 if (argv < stop) { | 554 while (argv < stop && (*argv)[0] != '-') { |
530 *fMatches.append() = *argv; | 555 *fMatches.append() = *argv++; |
531 } else { | 556 } |
| 557 argv--; |
| 558 if (!fMatches.count()) { |
532 logger.logError("missing arg for --match\n"); | 559 logger.logError("missing arg for --match\n"); |
533 help(); | 560 help(); |
534 return -1; | 561 return -1; |
535 } | 562 } |
536 } else if (strcmp(*argv, "--config") == 0) { | 563 } else if (strcmp(*argv, "--config") == 0) { |
537 argv++; | 564 argv++; |
538 if (argv < stop) { | 565 if (argv < stop) { |
539 int index = findConfig(*argv); | 566 int index = findConfig(*argv); |
540 if (index >= 0) { | 567 if (index >= 0) { |
541 *configs.append() = index; | 568 *configs.append() = index; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 } | 982 } |
956 | 983 |
957 return 0; | 984 return 0; |
958 } | 985 } |
959 | 986 |
960 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 987 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
961 int main(int argc, char * const argv[]) { | 988 int main(int argc, char * const argv[]) { |
962 return tool_main(argc, (char**) argv); | 989 return tool_main(argc, (char**) argv); |
963 } | 990 } |
964 #endif | 991 #endif |
OLD | NEW |