OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include <ctype.h> | 8 #include <ctype.h> |
9 | 9 |
10 #include "nanobench.h" | 10 #include "nanobench.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 DEFINE_int32(gpuFrameLag, 5, "If unknown, estimated maximum number of frames GPU
allows to lag."); | 92 DEFINE_int32(gpuFrameLag, 5, "If unknown, estimated maximum number of frames GPU
allows to lag."); |
93 DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling
back to " | 93 DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling
back to " |
94 "software path rendering."); | 94 "software path rendering."); |
95 | 95 |
96 DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); | 96 DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); |
97 DEFINE_int32(maxCalibrationAttempts, 3, | 97 DEFINE_int32(maxCalibrationAttempts, 3, |
98 "Try up to this many times to guess loops for a bench, or skip the
bench."); | 98 "Try up to this many times to guess loops for a bench, or skip the
bench."); |
99 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); | 99 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); |
100 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); | 100 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
101 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); | 101 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
102 DEFINE_string(zoom, "1.0,1", "Comma-separated scale,step zoom factors for SKPs."
); | 102 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a
periodic SKP zoom " |
| 103 "function that ping-pongs between 1.0 and zoomMax."
); |
103 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); | 104 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
104 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); | 105 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); |
105 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); | 106 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
106 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); | 107 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
107 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); | 108 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test
."); |
108 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); | 109 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
109 | 110 |
110 static SkString humanize(double ms) { | 111 static SkString humanize(double ms) { |
111 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); | 112 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); |
112 return HumanizeMs(ms); | 113 return HumanizeMs(ms); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 exit(1); | 592 exit(1); |
592 } | 593 } |
593 | 594 |
594 for (int i = 0; i < FLAGS_scales.count(); i++) { | 595 for (int i = 0; i < FLAGS_scales.count(); i++) { |
595 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) { | 596 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) { |
596 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS
_scales[i]); | 597 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS
_scales[i]); |
597 exit(1); | 598 exit(1); |
598 } | 599 } |
599 } | 600 } |
600 | 601 |
601 if (2 != sscanf(FLAGS_zoom[0], "%f,%d", &fZoomScale, &fZoomSteps)) { | 602 if (2 != sscanf(FLAGS_zoom[0], "%f,%lf", &fZoomMax, &fZoomPeriodMs)) { |
602 SkDebugf("Can't parse %s from --zoom as a scale,step.\n", FLAGS_zoom
[0]); | 603 SkDebugf("Can't parse %s from --zoom as a zoomMax,zoomPeriodMs.\n",
FLAGS_zoom[0]); |
603 exit(1); | 604 exit(1); |
604 } | 605 } |
605 | 606 |
606 if (FLAGS_mpd) { | 607 if (FLAGS_mpd) { |
607 fUseMPDs.push_back() = true; | 608 fUseMPDs.push_back() = true; |
608 } | 609 } |
609 fUseMPDs.push_back() = false; | 610 fUseMPDs.push_back() = false; |
610 | 611 |
611 // Prepare the images for decoding | 612 // Prepare the images for decoding |
612 for (int i = 0; i < FLAGS_images.count(); i++) { | 613 for (int i = 0; i < FLAGS_images.count(); i++) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 721 |
721 } | 722 } |
722 fCurrentUseMPD = 0; | 723 fCurrentUseMPD = 0; |
723 fCurrentSKP++; | 724 fCurrentSKP++; |
724 } | 725 } |
725 fCurrentSKP = 0; | 726 fCurrentSKP = 0; |
726 fCurrentScale++; | 727 fCurrentScale++; |
727 } | 728 } |
728 | 729 |
729 // Now loop over each skp again if we have an animation | 730 // Now loop over each skp again if we have an animation |
730 if (fZoomScale != 1.0f && fZoomSteps != 1) { | 731 if (fZoomMax != 1.0f && fZoomPeriodMs > 0) { |
731 while (fCurrentAnimSKP < fSKPs.count()) { | 732 while (fCurrentAnimSKP < fSKPs.count()) { |
732 const SkString& path = fSKPs[fCurrentAnimSKP]; | 733 const SkString& path = fSKPs[fCurrentAnimSKP]; |
733 SkAutoTUnref<SkPicture> pic; | 734 SkAutoTUnref<SkPicture> pic; |
734 if (!ReadPicture(path.c_str(), &pic)) { | 735 if (!ReadPicture(path.c_str(), &pic)) { |
735 fCurrentAnimSKP++; | 736 fCurrentAnimSKP++; |
736 continue; | 737 continue; |
737 } | 738 } |
738 | 739 |
739 fCurrentAnimSKP++; | 740 fCurrentAnimSKP++; |
740 SkString name = SkOSPath::Basename(path.c_str()); | 741 SkString name = SkOSPath::Basename(path.c_str()); |
741 SkMatrix anim = SkMatrix::I(); | 742 SkAutoTUnref<SKPAnimationBench::Animation> animation( |
742 anim.setScale(fZoomScale, fZoomScale); | 743 SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriod
Ms)); |
743 return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), f
Clip, anim, | 744 return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), f
Clip, animation, |
744 fZoomSteps, FLAGS_loopSKP)); | 745 FLAGS_loopSKP)); |
745 } | 746 } |
746 } | 747 } |
747 | 748 |
748 | 749 |
749 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { | 750 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { |
750 const SkString& path = fImages[fCurrentCodec]; | 751 const SkString& path = fImages[fCurrentCodec]; |
751 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 752 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
752 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 753 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
753 if (!codec) { | 754 if (!codec) { |
754 // Nothing to time. | 755 // Nothing to time. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 }; | 903 }; |
903 | 904 |
904 const BenchRegistry* fBenches; | 905 const BenchRegistry* fBenches; |
905 const skiagm::GMRegistry* fGMs; | 906 const skiagm::GMRegistry* fGMs; |
906 SkIRect fClip; | 907 SkIRect fClip; |
907 SkTArray<SkScalar> fScales; | 908 SkTArray<SkScalar> fScales; |
908 SkTArray<SkString> fSKPs; | 909 SkTArray<SkString> fSKPs; |
909 SkTArray<bool> fUseMPDs; | 910 SkTArray<bool> fUseMPDs; |
910 SkTArray<SkString> fImages; | 911 SkTArray<SkString> fImages; |
911 SkTArray<SkColorType> fColorTypes; | 912 SkTArray<SkColorType> fColorTypes; |
912 SkScalar fZoomScale; | 913 SkScalar fZoomMax; |
913 int fZoomSteps; | 914 double fZoomPeriodMs; |
914 | 915 |
915 double fSKPBytes, fSKPOps; | 916 double fSKPBytes, fSKPOps; |
916 | 917 |
917 const char* fSourceType; // What we're benching: bench, GM, SKP, ... | 918 const char* fSourceType; // What we're benching: bench, GM, SKP, ... |
918 const char* fBenchType; // How we bench it: micro, recording, playback, ..
. | 919 const char* fBenchType; // How we bench it: micro, recording, playback, ..
. |
919 int fCurrentRecording; | 920 int fCurrentRecording; |
920 int fCurrentScale; | 921 int fCurrentScale; |
921 int fCurrentSKP; | 922 int fCurrentSKP; |
922 int fCurrentUseMPD; | 923 int fCurrentUseMPD; |
923 int fCurrentCodec; | 924 int fCurrentCodec; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 | 1159 |
1159 return 0; | 1160 return 0; |
1160 } | 1161 } |
1161 | 1162 |
1162 #if !defined SK_BUILD_FOR_IOS | 1163 #if !defined SK_BUILD_FOR_IOS |
1163 int main(int argc, char** argv) { | 1164 int main(int argc, char** argv) { |
1164 SkCommandLineFlags::Parse(argc, argv); | 1165 SkCommandLineFlags::Parse(argc, argv); |
1165 return nanobench_main(); | 1166 return nanobench_main(); |
1166 } | 1167 } |
1167 #endif | 1168 #endif |
OLD | NEW |