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" |
11 | 11 |
12 #include "AndroidCodecBench.h" | 12 #include "AndroidCodecBench.h" |
13 #include "Benchmark.h" | 13 #include "Benchmark.h" |
14 #include "BitmapRegionDecoderBench.h" | 14 #include "BitmapRegionDecoderBench.h" |
15 #include "CodecBench.h" | 15 #include "CodecBench.h" |
16 #include "CodecBenchPriv.h" | 16 #include "CodecBenchPriv.h" |
17 #include "ColorCodecBench.h" | |
17 #include "CrashHandler.h" | 18 #include "CrashHandler.h" |
18 #include "GMBench.h" | 19 #include "GMBench.h" |
19 #include "ProcStats.h" | 20 #include "ProcStats.h" |
20 #include "ResultsWriter.h" | 21 #include "ResultsWriter.h" |
21 #include "RecordingBench.h" | 22 #include "RecordingBench.h" |
22 #include "SKPAnimationBench.h" | 23 #include "SKPAnimationBench.h" |
23 #include "SKPBench.h" | 24 #include "SKPBench.h" |
24 #include "Stats.h" | 25 #include "Stats.h" |
25 | 26 |
26 #include "SkAndroidCodec.h" | 27 #include "SkAndroidCodec.h" |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 public: | 552 public: |
552 BenchmarkStream() : fBenches(BenchRegistry::Head()) | 553 BenchmarkStream() : fBenches(BenchRegistry::Head()) |
553 , fGMs(skiagm::GMRegistry::Head()) | 554 , fGMs(skiagm::GMRegistry::Head()) |
554 , fCurrentRecording(0) | 555 , fCurrentRecording(0) |
555 , fCurrentScale(0) | 556 , fCurrentScale(0) |
556 , fCurrentSKP(0) | 557 , fCurrentSKP(0) |
557 , fCurrentUseMPD(0) | 558 , fCurrentUseMPD(0) |
558 , fCurrentCodec(0) | 559 , fCurrentCodec(0) |
559 , fCurrentAndroidCodec(0) | 560 , fCurrentAndroidCodec(0) |
560 , fCurrentBRDImage(0) | 561 , fCurrentBRDImage(0) |
562 , fCurrentColorImage(0) | |
561 , fCurrentColorType(0) | 563 , fCurrentColorType(0) |
562 , fCurrentAlphaType(0) | 564 , fCurrentAlphaType(0) |
563 , fCurrentSubsetType(0) | 565 , fCurrentSubsetType(0) |
564 , fCurrentSampleSize(0) | 566 , fCurrentSampleSize(0) |
565 , fCurrentAnimSKP(0) { | 567 , fCurrentAnimSKP(0) { |
566 for (int i = 0; i < FLAGS_skps.count(); i++) { | 568 for (int i = 0; i < FLAGS_skps.count(); i++) { |
567 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { | 569 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
568 fSKPs.push_back() = FLAGS_skps[i]; | 570 fSKPs.push_back() = FLAGS_skps[i]; |
569 } else { | 571 } else { |
570 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); | 572 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); |
(...skipping 24 matching lines...) Expand all Loading... | |
595 | 597 |
596 if (FLAGS_mpd) { | 598 if (FLAGS_mpd) { |
597 fUseMPDs.push_back() = true; | 599 fUseMPDs.push_back() = true; |
598 } | 600 } |
599 fUseMPDs.push_back() = false; | 601 fUseMPDs.push_back() = false; |
600 | 602 |
601 // Prepare the images for decoding | 603 // Prepare the images for decoding |
602 if (!CollectImages(FLAGS_images, &fImages)) { | 604 if (!CollectImages(FLAGS_images, &fImages)) { |
603 exit(1); | 605 exit(1); |
604 } | 606 } |
607 if (!CollectImages(FLAGS_colorImages, &fColorImages)) { | |
608 exit(1); | |
609 } | |
605 | 610 |
606 // Choose the candidate color types for image decoding | 611 // Choose the candidate color types for image decoding |
607 const SkColorType colorTypes[] = | 612 const SkColorType colorTypes[] = |
608 { kN32_SkColorType, | 613 { kN32_SkColorType, |
609 kRGB_565_SkColorType, | 614 kRGB_565_SkColorType, |
610 kAlpha_8_SkColorType, | 615 kAlpha_8_SkColorType, |
611 kIndex_8_SkColorType, | 616 kIndex_8_SkColorType, |
612 kGray_8_SkColorType }; | 617 kGray_8_SkColorType }; |
613 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes)); | 618 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes)); |
614 } | 619 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
910 } | 915 } |
911 fCurrentSubsetType = 0; | 916 fCurrentSubsetType = 0; |
912 fCurrentSampleSize++; | 917 fCurrentSampleSize++; |
913 } | 918 } |
914 fCurrentSampleSize = 0; | 919 fCurrentSampleSize = 0; |
915 fCurrentColorType++; | 920 fCurrentColorType++; |
916 } | 921 } |
917 fCurrentColorType = 0; | 922 fCurrentColorType = 0; |
918 } | 923 } |
919 | 924 |
925 while (fCurrentColorImage < fColorImages.count()) { | |
926 fSourceType = "colorimage"; | |
927 fBenchType = "skcolorcodec"; | |
928 const SkString& path = fColorImages[fCurrentColorImage]; | |
929 fCurrentColorImage++; | |
930 sk_sp<SkData> encoded = SkData::MakeFromFileName(path.c_str()); | |
931 if (encoded) { | |
932 return new ColorCodecBench(SkOSPath::Basename(path.c_str()).c_st r(), encoded); | |
scroggo
2016/06/02 18:51:50
nit: Should we std::move(encoded)?
Also, should t
msarett
2016/06/02 19:34:39
Yes and yes. Done for both.
| |
933 } | |
934 } | |
935 | |
920 return nullptr; | 936 return nullptr; |
921 } | 937 } |
922 | 938 |
923 void fillCurrentOptions(ResultsWriter* log) const { | 939 void fillCurrentOptions(ResultsWriter* log) const { |
924 log->configOption("source_type", fSourceType); | 940 log->configOption("source_type", fSourceType); |
925 log->configOption("bench_type", fBenchType); | 941 log->configOption("bench_type", fBenchType); |
926 if (0 == strcmp(fSourceType, "skp")) { | 942 if (0 == strcmp(fSourceType, "skp")) { |
927 log->configOption("clip", | 943 log->configOption("clip", |
928 SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop, | 944 SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop, |
929 fClip.fRight, fClip.fBottom).c _str()); | 945 fClip.fRight, fClip.fBottom).c _str()); |
(...skipping 23 matching lines...) Expand all Loading... | |
953 kLastSingle_SubsetType = kBottomRight_SubsetType, | 969 kLastSingle_SubsetType = kBottomRight_SubsetType, |
954 }; | 970 }; |
955 | 971 |
956 const BenchRegistry* fBenches; | 972 const BenchRegistry* fBenches; |
957 const skiagm::GMRegistry* fGMs; | 973 const skiagm::GMRegistry* fGMs; |
958 SkIRect fClip; | 974 SkIRect fClip; |
959 SkTArray<SkScalar> fScales; | 975 SkTArray<SkScalar> fScales; |
960 SkTArray<SkString> fSKPs; | 976 SkTArray<SkString> fSKPs; |
961 SkTArray<bool> fUseMPDs; | 977 SkTArray<bool> fUseMPDs; |
962 SkTArray<SkString> fImages; | 978 SkTArray<SkString> fImages; |
979 SkTArray<SkString> fColorImages; | |
963 SkTArray<SkColorType, true> fColorTypes; | 980 SkTArray<SkColorType, true> fColorTypes; |
964 SkScalar fZoomMax; | 981 SkScalar fZoomMax; |
965 double fZoomPeriodMs; | 982 double fZoomPeriodMs; |
966 | 983 |
967 double fSKPBytes, fSKPOps; | 984 double fSKPBytes, fSKPOps; |
968 | 985 |
969 const char* fSourceType; // What we're benching: bench, GM, SKP, ... | 986 const char* fSourceType; // What we're benching: bench, GM, SKP, ... |
970 const char* fBenchType; // How we bench it: micro, recording, playback, .. . | 987 const char* fBenchType; // How we bench it: micro, recording, playback, .. . |
971 int fCurrentRecording; | 988 int fCurrentRecording; |
972 int fCurrentScale; | 989 int fCurrentScale; |
973 int fCurrentSKP; | 990 int fCurrentSKP; |
974 int fCurrentUseMPD; | 991 int fCurrentUseMPD; |
975 int fCurrentCodec; | 992 int fCurrentCodec; |
976 int fCurrentAndroidCodec; | 993 int fCurrentAndroidCodec; |
977 int fCurrentBRDImage; | 994 int fCurrentBRDImage; |
995 int fCurrentColorImage; | |
978 int fCurrentColorType; | 996 int fCurrentColorType; |
979 int fCurrentAlphaType; | 997 int fCurrentAlphaType; |
980 int fCurrentSubsetType; | 998 int fCurrentSubsetType; |
981 int fCurrentSampleSize; | 999 int fCurrentSampleSize; |
982 int fCurrentAnimSKP; | 1000 int fCurrentAnimSKP; |
983 }; | 1001 }; |
984 | 1002 |
985 // Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung. | 1003 // Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung. |
986 // This prints something every once in a while so that it knows we're still work ing. | 1004 // This prints something every once in a while so that it knows we're still work ing. |
987 static void start_keepalive() { | 1005 static void start_keepalive() { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 | 1283 |
1266 return 0; | 1284 return 0; |
1267 } | 1285 } |
1268 | 1286 |
1269 #if !defined SK_BUILD_FOR_IOS | 1287 #if !defined SK_BUILD_FOR_IOS |
1270 int main(int argc, char** argv) { | 1288 int main(int argc, char** argv) { |
1271 SkCommandLineFlags::Parse(argc, argv); | 1289 SkCommandLineFlags::Parse(argc, argv); |
1272 return nanobench_main(); | 1290 return nanobench_main(); |
1273 } | 1291 } |
1274 #endif | 1292 #endif |
OLD | NEW |