| 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 "Benchmark.h" | 12 #include "Benchmark.h" |
| 13 #include "BitmapRegionDecoderBench.h" | 13 #include "BitmapRegionDecoderBench.h" |
| 14 #include "CodecBench.h" | 14 #include "CodecBench.h" |
| 15 #include "CodecBenchPriv.h" | 15 #include "CodecBenchPriv.h" |
| 16 #include "CrashHandler.h" | 16 #include "CrashHandler.h" |
| 17 #include "DecodingBench.h" | |
| 18 #include "GMBench.h" | 17 #include "GMBench.h" |
| 19 #include "ProcStats.h" | 18 #include "ProcStats.h" |
| 20 #include "ResultsWriter.h" | 19 #include "ResultsWriter.h" |
| 21 #include "RecordingBench.h" | 20 #include "RecordingBench.h" |
| 22 #include "SKPAnimationBench.h" | 21 #include "SKPAnimationBench.h" |
| 23 #include "SKPBench.h" | 22 #include "SKPBench.h" |
| 24 #include "Stats.h" | 23 #include "Stats.h" |
| 25 | 24 |
| 26 #include "SkBitmapRegionDecoder.h" | 25 #include "SkBitmapRegionDecoder.h" |
| 27 #include "SkBBoxHierarchy.h" | 26 #include "SkBBoxHierarchy.h" |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 553 |
| 555 class BenchmarkStream { | 554 class BenchmarkStream { |
| 556 public: | 555 public: |
| 557 BenchmarkStream() : fBenches(BenchRegistry::Head()) | 556 BenchmarkStream() : fBenches(BenchRegistry::Head()) |
| 558 , fGMs(skiagm::GMRegistry::Head()) | 557 , fGMs(skiagm::GMRegistry::Head()) |
| 559 , fCurrentRecording(0) | 558 , fCurrentRecording(0) |
| 560 , fCurrentScale(0) | 559 , fCurrentScale(0) |
| 561 , fCurrentSKP(0) | 560 , fCurrentSKP(0) |
| 562 , fCurrentUseMPD(0) | 561 , fCurrentUseMPD(0) |
| 563 , fCurrentCodec(0) | 562 , fCurrentCodec(0) |
| 564 , fCurrentImage(0) | |
| 565 , fCurrentBRDImage(0) | 563 , fCurrentBRDImage(0) |
| 566 , fCurrentColorType(0) | 564 , fCurrentColorType(0) |
| 567 , fCurrentAlphaType(0) | 565 , fCurrentAlphaType(0) |
| 568 , fCurrentSubsetType(0) | 566 , fCurrentSubsetType(0) |
| 569 , fCurrentBRDStrategy(0) | 567 , fCurrentBRDStrategy(0) |
| 570 , fCurrentBRDSampleSize(0) | 568 , fCurrentBRDSampleSize(0) |
| 571 , fCurrentAnimSKP(0) { | 569 , fCurrentAnimSKP(0) { |
| 572 for (int i = 0; i < FLAGS_skps.count(); i++) { | 570 for (int i = 0; i < FLAGS_skps.count(); i++) { |
| 573 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { | 571 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
| 574 fSKPs.push_back() = FLAGS_skps[i]; | 572 fSKPs.push_back() = FLAGS_skps[i]; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 break; | 803 break; |
| 806 default: | 804 default: |
| 807 // This represents some sort of failure. | 805 // This represents some sort of failure. |
| 808 SkASSERT(false); | 806 SkASSERT(false); |
| 809 break; | 807 break; |
| 810 } | 808 } |
| 811 } | 809 } |
| 812 fCurrentColorType = 0; | 810 fCurrentColorType = 0; |
| 813 } | 811 } |
| 814 | 812 |
| 815 // Run the DecodingBenches | |
| 816 for (; fCurrentImage < fImages.count(); fCurrentImage++) { | |
| 817 fSourceType = "image"; | |
| 818 fBenchType = "skimagedecoder"; | |
| 819 const SkString& path = fImages[fCurrentImage]; | |
| 820 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { | |
| 821 continue; | |
| 822 } | |
| 823 while (fCurrentColorType < fColorTypes.count()) { | |
| 824 SkColorType colorType = fColorTypes[fCurrentColorType]; | |
| 825 fCurrentColorType++; | |
| 826 // Check if the image decodes to the right color type | |
| 827 // before creating the benchmark | |
| 828 SkBitmap bitmap; | |
| 829 if (SkImageDecoder::DecodeFile(path.c_str(), &bitmap, | |
| 830 colorType, SkImageDecoder::kDecodePixels_Mode) | |
| 831 && bitmap.colorType() == colorType) { | |
| 832 return new DecodingBench(path, colorType); | |
| 833 } | |
| 834 } | |
| 835 fCurrentColorType = 0; | |
| 836 } | |
| 837 | |
| 838 // Run the BRDBenches | 813 // Run the BRDBenches |
| 839 // We will benchmark multiple BRD strategies. | 814 // We will benchmark multiple BRD strategies. |
| 840 static const struct { | 815 static const struct { |
| 841 SkBitmapRegionDecoder::Strategy fStrategy; | 816 SkBitmapRegionDecoder::Strategy fStrategy; |
| 842 const char* fName; | 817 const char* fName; |
| 843 } strategies[] = { | 818 } strategies[] = { |
| 844 { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" }, | 819 { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" }, |
| 845 { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec"
}, | 820 { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec"
}, |
| 846 }; | 821 }; |
| 847 | 822 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 | 961 |
| 987 double fSKPBytes, fSKPOps; | 962 double fSKPBytes, fSKPOps; |
| 988 | 963 |
| 989 const char* fSourceType; // What we're benching: bench, GM, SKP, ... | 964 const char* fSourceType; // What we're benching: bench, GM, SKP, ... |
| 990 const char* fBenchType; // How we bench it: micro, recording, playback, ..
. | 965 const char* fBenchType; // How we bench it: micro, recording, playback, ..
. |
| 991 int fCurrentRecording; | 966 int fCurrentRecording; |
| 992 int fCurrentScale; | 967 int fCurrentScale; |
| 993 int fCurrentSKP; | 968 int fCurrentSKP; |
| 994 int fCurrentUseMPD; | 969 int fCurrentUseMPD; |
| 995 int fCurrentCodec; | 970 int fCurrentCodec; |
| 996 int fCurrentImage; | |
| 997 int fCurrentBRDImage; | 971 int fCurrentBRDImage; |
| 998 int fCurrentColorType; | 972 int fCurrentColorType; |
| 999 int fCurrentAlphaType; | 973 int fCurrentAlphaType; |
| 1000 int fCurrentSubsetType; | 974 int fCurrentSubsetType; |
| 1001 int fCurrentBRDStrategy; | 975 int fCurrentBRDStrategy; |
| 1002 int fCurrentBRDSampleSize; | 976 int fCurrentBRDSampleSize; |
| 1003 int fCurrentAnimSKP; | 977 int fCurrentAnimSKP; |
| 1004 }; | 978 }; |
| 1005 | 979 |
| 1006 // Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've
hung. | 980 // Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've
hung. |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 | 1238 |
| 1265 return 0; | 1239 return 0; |
| 1266 } | 1240 } |
| 1267 | 1241 |
| 1268 #if !defined SK_BUILD_FOR_IOS | 1242 #if !defined SK_BUILD_FOR_IOS |
| 1269 int main(int argc, char** argv) { | 1243 int main(int argc, char** argv) { |
| 1270 SkCommandLineFlags::Parse(argc, argv); | 1244 SkCommandLineFlags::Parse(argc, argv); |
| 1271 return nanobench_main(); | 1245 return nanobench_main(); |
| 1272 } | 1246 } |
| 1273 #endif | 1247 #endif |
| OLD | NEW |