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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 372 |
373 int tool_main(int argc, char** argv); | 373 int tool_main(int argc, char** argv); |
374 int tool_main(int argc, char** argv) { | 374 int tool_main(int argc, char** argv) { |
375 #if SK_ENABLE_INST_COUNT | 375 #if SK_ENABLE_INST_COUNT |
376 gPrintInstCount = true; | 376 gPrintInstCount = true; |
377 #endif | 377 #endif |
378 SkAutoGraphics ag; | 378 SkAutoGraphics ag; |
379 | 379 |
380 SkTDict<const char*> defineDict(1024); | 380 SkTDict<const char*> defineDict(1024); |
381 int repeatDraw = 1; | 381 int repeatDraw = 1; |
382 bool logPerIter = false; | 382 |
383 int forceAlpha = 0xFF; | 383 int forceAlpha = 0xFF; |
384 bool forceAA = true; | 384 bool forceAA = true; |
385 bool forceFilter = false; | 385 bool forceFilter = false; |
386 SkTriState::State forceDither = SkTriState::kDefault; | 386 SkTriState::State forceDither = SkTriState::kDefault; |
387 bool timerWall = false; | 387 |
388 bool truncatedTimerWall = false; | 388 static const uint32_t kDefaultTimerTypes = TimerData::kCpu_Flag | TimerData:
:kGpu_Flag; |
389 bool timerCpu = true; | 389 static const TimerData::Result kDefaultTimerResult = TimerData::kAvg_Result; |
390 bool truncatedTimerCpu = false; | 390 uint32_t timerTypes = kDefaultTimerTypes; |
391 bool timerGpu = true; | 391 TimerData::Result timerResult = kDefaultTimerResult; |
| 392 |
392 bool doScale = false; | 393 bool doScale = false; |
393 bool doRotate = false; | 394 bool doRotate = false; |
394 bool doClip = false; | 395 bool doClip = false; |
395 bool printMin = false; | |
396 bool hasStrokeWidth = false; | 396 bool hasStrokeWidth = false; |
397 | 397 |
398 #if SK_SUPPORT_GPU | 398 #if SK_SUPPORT_GPU |
399 struct { | 399 struct { |
400 int fBytes; | 400 int fBytes; |
401 int fCount; | 401 int fCount; |
402 } gpuCacheSize = { -1, -1 }; // -1s mean use the default | 402 } gpuCacheSize = { -1, -1 }; // -1s mean use the default |
403 #endif | 403 #endif |
404 | 404 |
405 float strokeWidth; | 405 float strokeWidth; |
(...skipping 28 matching lines...) Expand all Loading... |
434 repeatDraw = atoi(*argv); | 434 repeatDraw = atoi(*argv); |
435 if (repeatDraw < 1) { | 435 if (repeatDraw < 1) { |
436 repeatDraw = 1; | 436 repeatDraw = 1; |
437 } | 437 } |
438 } else { | 438 } else { |
439 logger.logError("missing arg for --repeat\n"); | 439 logger.logError("missing arg for --repeat\n"); |
440 help(); | 440 help(); |
441 return -1; | 441 return -1; |
442 } | 442 } |
443 } else if (strcmp(*argv, "--logPerIter") == 0) { | 443 } else if (strcmp(*argv, "--logPerIter") == 0) { |
444 logPerIter = true; | 444 timerResult = TimerData::kPerIter_Result; |
445 } else if (strcmp(*argv, "--timers") == 0) { | 445 } else if (strcmp(*argv, "--timers") == 0) { |
446 argv++; | 446 argv++; |
447 if (argv < stop) { | 447 if (argv < stop) { |
448 timerWall = false; | 448 timerTypes = 0; |
449 truncatedTimerWall = false; | |
450 timerCpu = false; | |
451 truncatedTimerCpu = false; | |
452 timerGpu = false; | |
453 for (char* t = *argv; *t; ++t) { | 449 for (char* t = *argv; *t; ++t) { |
454 switch (*t) { | 450 switch (*t) { |
455 case 'w': timerWall = true; break; | 451 case 'w': timerTypes |= TimerData::kWall_Flag; break; |
456 case 'c': timerCpu = true; break; | 452 case 'c': timerTypes |= TimerData::kCpu_Flag; break; |
457 case 'W': truncatedTimerWall = true; break; | 453 case 'W': timerTypes |= TimerData::kTruncatedWall_Flag; brea
k; |
458 case 'C': truncatedTimerCpu = true; break; | 454 case 'C': timerTypes |= TimerData::kTruncatedCpu_Flag; break
; |
459 case 'g': timerGpu = true; break; | 455 case 'g': timerTypes |= TimerData::kGpu_Flag; break; |
460 } | 456 } |
461 } | 457 } |
462 } else { | 458 } else { |
463 logger.logError("missing arg for --timers\n"); | 459 logger.logError("missing arg for --timers\n"); |
464 help(); | 460 help(); |
465 return -1; | 461 return -1; |
466 } | 462 } |
467 } else if (!strcmp(*argv, "--rotate")) { | 463 } else if (!strcmp(*argv, "--rotate")) { |
468 doRotate = true; | 464 doRotate = true; |
469 } else if (!strcmp(*argv, "--scale")) { | 465 } else if (!strcmp(*argv, "--scale")) { |
470 doScale = true; | 466 doScale = true; |
471 } else if (!strcmp(*argv, "--clip")) { | 467 } else if (!strcmp(*argv, "--clip")) { |
472 doClip = true; | 468 doClip = true; |
473 } else if (!strcmp(*argv, "--min")) { | 469 } else if (!strcmp(*argv, "--min")) { |
474 printMin = true; | 470 timerResult = TimerData::kMin_Result; |
475 } else if (strcmp(*argv, "--forceAA") == 0) { | 471 } else if (strcmp(*argv, "--forceAA") == 0) { |
476 if (!parse_bool_arg(++argv, stop, &forceAA)) { | 472 if (!parse_bool_arg(++argv, stop, &forceAA)) { |
477 logger.logError("missing arg for --forceAA\n"); | 473 logger.logError("missing arg for --forceAA\n"); |
478 help(); | 474 help(); |
479 return -1; | 475 return -1; |
480 } | 476 } |
481 } else if (strcmp(*argv, "--forceFilter") == 0) { | 477 } else if (strcmp(*argv, "--forceFilter") == 0) { |
482 if (!parse_bool_arg(++argv, stop, &forceFilter)) { | 478 if (!parse_bool_arg(++argv, stop, &forceFilter)) { |
483 logger.logError("missing arg for --forceFilter\n"); | 479 logger.logError("missing arg for --forceFilter\n"); |
484 help(); | 480 help(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 #endif | 668 #endif |
673 | 669 |
674 // report our current settings | 670 // report our current settings |
675 { | 671 { |
676 SkString str; | 672 SkString str; |
677 const char* deferredMode = benchMode == kDeferred_benchModes ? "yes" : | 673 const char* deferredMode = benchMode == kDeferred_benchModes ? "yes" : |
678 (benchMode == kDeferredSilent_benchModes ? "silent" : "no"); | 674 (benchMode == kDeferredSilent_benchModes ? "silent" : "no"); |
679 str.printf("skia bench: alpha=0x%02X antialias=%d filter=%d " | 675 str.printf("skia bench: alpha=0x%02X antialias=%d filter=%d " |
680 "deferred=%s logperiter=%d", | 676 "deferred=%s logperiter=%d", |
681 forceAlpha, forceAA, forceFilter, deferredMode, | 677 forceAlpha, forceAA, forceFilter, deferredMode, |
682 logPerIter); | 678 TimerData::kPerIter_Result == timerResult); |
683 str.appendf(" rotate=%d scale=%d clip=%d min=%d", | 679 str.appendf(" rotate=%d scale=%d clip=%d min=%d", |
684 doRotate, doScale, doClip, printMin); | 680 doRotate, doScale, doClip, TimerData::kMin_Result == timerRes
ult); |
685 str.appendf(" record=%d picturerecord=%d", | 681 str.appendf(" record=%d picturerecord=%d", |
686 benchMode == kRecord_benchModes, | 682 benchMode == kRecord_benchModes, |
687 benchMode == kPictureRecord_benchModes); | 683 benchMode == kPictureRecord_benchModes); |
688 const char * ditherName; | 684 const char * ditherName; |
689 switch (forceDither) { | 685 switch (forceDither) { |
690 case SkTriState::kDefault: ditherName = "default"; break; | 686 case SkTriState::kDefault: ditherName = "default"; break; |
691 case SkTriState::kTrue: ditherName = "true"; break; | 687 case SkTriState::kTrue: ditherName = "true"; break; |
692 case SkTriState::kFalse: ditherName = "false"; break; | 688 case SkTriState::kFalse: ditherName = "false"; break; |
693 default: ditherName = "<invalid>"; break; | 689 default: ditherName = "<invalid>"; break; |
694 } | 690 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 } | 903 } |
908 #if SK_SUPPORT_GPU | 904 #if SK_SUPPORT_GPU |
909 if (NULL != context) { | 905 if (NULL != context) { |
910 context->flush(); | 906 context->flush(); |
911 SK_GL(*glContext, Finish()); | 907 SK_GL(*glContext, Finish()); |
912 } | 908 } |
913 #endif | 909 #endif |
914 } | 910 } |
915 | 911 |
916 // record timer values for each repeat, and their sum | 912 // record timer values for each repeat, and their sum |
917 TimerData timerData(perIterTimeformat, normalTimeFormat); | 913 TimerData timerData(repeatDraw); |
918 for (int i = 0; i < repeatDraw; i++) { | 914 for (int i = 0; i < repeatDraw; i++) { |
919 if ((benchMode == kRecord_benchModes || benchMode == kPictur
eRecord_benchModes)) { | 915 if ((benchMode == kRecord_benchModes || benchMode == kPictur
eRecord_benchModes)) { |
920 // This will clear the recorded commands so that they do
not | 916 // This will clear the recorded commands so that they do
not |
921 // accumulate. | 917 // accumulate. |
922 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, | 918 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, |
923 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 919 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
924 } | 920 } |
925 | 921 |
926 timer->start(bench->getDurationScale()); | 922 timer->start(bench->getDurationScale()); |
927 if (NULL != canvas) { | 923 if (NULL != canvas) { |
(...skipping 21 matching lines...) Expand all Loading... |
949 #if SK_SUPPORT_GPU | 945 #if SK_SUPPORT_GPU |
950 if (NULL != glContext) { | 946 if (NULL != glContext) { |
951 context->flush(); | 947 context->flush(); |
952 SK_GL(*glContext, Finish()); | 948 SK_GL(*glContext, Finish()); |
953 } | 949 } |
954 #endif | 950 #endif |
955 // stop the inclusive and gpu timers once all the GL calls | 951 // stop the inclusive and gpu timers once all the GL calls |
956 // have completed | 952 // have completed |
957 timer->end(); | 953 timer->end(); |
958 | 954 |
959 timerData.appendTimes(timer, repeatDraw - 1 == i); | 955 timerData.appendTimes(timer); |
960 | 956 |
961 } | 957 } |
962 if (repeatDraw > 1) { | 958 if (repeatDraw > 1) { |
963 SkString result = timerData.getResult( | 959 const char* timeFormat; |
964 logPerIter, printMin, repeatDraw, config
Name, | 960 if (TimerData::kPerIter_Result == timerResult) { |
965 timerWall, truncatedTimerWall, timerCpu, | 961 timeFormat = perIterTimeformat.c_str(); |
966 truncatedTimerCpu, | 962 } else { |
967 timerGpu && NULL != context); | 963 timeFormat = normalTimeFormat.c_str(); |
| 964 } |
| 965 uint32_t filteredTimerTypes = timerTypes; |
| 966 if (NULL == context) { |
| 967 filteredTimerTypes &= ~TimerData::kGpu_Flag; |
| 968 } |
| 969 SkString result = timerData.getResult(timeFormat, |
| 970 timerResult, |
| 971 configName, |
| 972 filteredTimerTypes); |
968 logger.logProgress(result); | 973 logger.logProgress(result); |
969 } | 974 } |
970 if (outDir.size() > 0 && kNonRendering_Backend != backend) { | 975 if (outDir.size() > 0 && kNonRendering_Backend != backend) { |
971 saveFile(bench->getName(), configName, outDir.c_str(), | 976 saveFile(bench->getName(), configName, outDir.c_str(), |
972 device->accessBitmap(false)); | 977 device->accessBitmap(false)); |
973 } | 978 } |
974 } | 979 } |
975 } | 980 } |
976 if (loggedBenchStart) { | 981 if (loggedBenchStart) { |
977 logger.logProgress(SkString("\n")); | 982 logger.logProgress(SkString("\n")); |
(...skipping 19 matching lines...) Expand all Loading... |
997 } | 1002 } |
998 | 1003 |
999 return 0; | 1004 return 0; |
1000 } | 1005 } |
1001 | 1006 |
1002 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1007 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1003 int main(int argc, char * const argv[]) { | 1008 int main(int argc, char * const argv[]) { |
1004 return tool_main(argc, (char**) argv); | 1009 return tool_main(argc, (char**) argv); |
1005 } | 1010 } |
1006 #endif | 1011 #endif |
OLD | NEW |