Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: bench/nanobench.cpp

Issue 1577873002: apply --match to image file names too, like we do for .skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: sp Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriod Ms)); 736 SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriod Ms));
737 return new SKPAnimationBench(name.c_str(), pic.get(), fClip, ani mation, 737 return new SKPAnimationBench(name.c_str(), pic.get(), fClip, ani mation,
738 FLAGS_loopSKP); 738 FLAGS_loopSKP);
739 } 739 }
740 } 740 }
741 741
742 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { 742 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) {
743 fSourceType = "image"; 743 fSourceType = "image";
744 fBenchType = "skcodec"; 744 fBenchType = "skcodec";
745 const SkString& path = fImages[fCurrentCodec]; 745 const SkString& path = fImages[fCurrentCodec];
746 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
msarett 2016/01/11 19:55:49 I should have noticed this on my review, but this
scroggo 2016/02/03 15:30:00 Proposed fix in crrev.com/1663103002
747 continue;
748 }
746 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); 749 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
747 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 750 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
748 if (!codec) { 751 if (!codec) {
749 // Nothing to time. 752 // Nothing to time.
750 SkDebugf("Cannot find codec for %s\n", path.c_str()); 753 SkDebugf("Cannot find codec for %s\n", path.c_str());
751 continue; 754 continue;
752 } 755 }
753 756
754 while (fCurrentColorType < fColorTypes.count()) { 757 while (fCurrentColorType < fColorTypes.count()) {
755 const SkColorType colorType = fColorTypes[fCurrentColorType]; 758 const SkColorType colorType = fColorTypes[fCurrentColorType];
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 default: 806 default:
804 // This represents some sort of failure. 807 // This represents some sort of failure.
805 SkASSERT(false); 808 SkASSERT(false);
806 break; 809 break;
807 } 810 }
808 } 811 }
809 fCurrentColorType = 0; 812 fCurrentColorType = 0;
810 } 813 }
811 814
812 // Run the DecodingBenches 815 // Run the DecodingBenches
813 while (fCurrentImage < fImages.count()) { 816 for (; fCurrentImage < fImages.count(); fCurrentImage++) {
814 fSourceType = "image"; 817 fSourceType = "image";
815 fBenchType = "skimagedecoder"; 818 fBenchType = "skimagedecoder";
819 const SkString& path = fImages[fCurrentImage];
820 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
821 continue;
822 }
816 while (fCurrentColorType < fColorTypes.count()) { 823 while (fCurrentColorType < fColorTypes.count()) {
817 const SkString& path = fImages[fCurrentImage];
818 SkColorType colorType = fColorTypes[fCurrentColorType]; 824 SkColorType colorType = fColorTypes[fCurrentColorType];
819 fCurrentColorType++; 825 fCurrentColorType++;
820 // Check if the image decodes to the right color type 826 // Check if the image decodes to the right color type
821 // before creating the benchmark 827 // before creating the benchmark
822 SkBitmap bitmap; 828 SkBitmap bitmap;
823 if (SkImageDecoder::DecodeFile(path.c_str(), &bitmap, 829 if (SkImageDecoder::DecodeFile(path.c_str(), &bitmap,
824 colorType, SkImageDecoder::kDecodePixels_Mode) 830 colorType, SkImageDecoder::kDecodePixels_Mode)
825 && bitmap.colorType() == colorType) { 831 && bitmap.colorType() == colorType) {
826 return new DecodingBench(path, colorType); 832 return new DecodingBench(path, colorType);
827 } 833 }
828 } 834 }
829 fCurrentColorType = 0; 835 fCurrentColorType = 0;
830 fCurrentImage++;
831 } 836 }
832 837
833 // Run the BRDBenches 838 // Run the BRDBenches
834 // We will benchmark multiple BRD strategies. 839 // We will benchmark multiple BRD strategies.
835 static const struct { 840 static const struct {
836 SkBitmapRegionDecoder::Strategy fStrategy; 841 SkBitmapRegionDecoder::Strategy fStrategy;
837 const char* fName; 842 const char* fName;
838 } strategies[] = { 843 } strategies[] = {
839 { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" }, 844 { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" },
840 { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec" }, 845 { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec" },
841 }; 846 };
842 847
843 // We intend to create benchmarks that model the use cases in 848 // We intend to create benchmarks that model the use cases in
844 // android/libraries/social/tiledimage. In this library, an image is de coded in 512x512 849 // android/libraries/social/tiledimage. In this library, an image is de coded in 512x512
845 // tiles. The image can be translated freely, so the location of a tile may be anywhere in 850 // tiles. The image can be translated freely, so the location of a tile may be anywhere in
846 // the image. For that reason, we will benchmark decodes in five repres entative locations 851 // the image. For that reason, we will benchmark decodes in five repres entative locations
847 // in the image. Additionally, this use case utilizes power of two scal ing, so we will 852 // in the image. Additionally, this use case utilizes power of two scal ing, so we will
848 // test on power of two sample sizes. The output tile is always 512x512 , so, when a 853 // test on power of two sample sizes. The output tile is always 512x512 , so, when a
849 // sampleSize is used, the size of the subset that is decoded is always 854 // sampleSize is used, the size of the subset that is decoded is always
850 // (sampleSize*512)x(sampleSize*512). 855 // (sampleSize*512)x(sampleSize*512).
851 // There are a few good reasons to only test on power of two sample size s at this time: 856 // There are a few good reasons to only test on power of two sample size s at this time:
852 // JPEG decodes using kOriginal_Strategy are broken for non-powers o f two. 857 // JPEG decodes using kOriginal_Strategy are broken for non-powers o f two.
853 // https://bug.skia.org/4319 858 // https://bug.skia.org/4319
854 // All use cases we are aware of only scale by powers of two. 859 // All use cases we are aware of only scale by powers of two.
855 // PNG decodes use the indicated sampling strategy regardless of the sample size, so 860 // PNG decodes use the indicated sampling strategy regardless of the sample size, so
856 // these tests are sufficient to provide good coverage of our sc aling options. 861 // these tests are sufficient to provide good coverage of our sc aling options.
857 const uint32_t sampleSizes[] = { 1, 2, 4, 8, 16, 32, 64 }; 862 const uint32_t sampleSizes[] = { 1, 2, 4, 8, 16, 32, 64 };
858 const uint32_t minOutputSize = 512; 863 const uint32_t minOutputSize = 512;
859 while (fCurrentBRDImage < fImages.count()) { 864 for (; fCurrentBRDImage < fImages.count(); fCurrentBRDImage++) {
865 const SkString& path = fImages[fCurrentBRDImage];
866 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
867 continue;
868 }
860 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) { 869 while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) {
861 fSourceType = "image"; 870 fSourceType = "image";
862 fBenchType = strategies[fCurrentBRDStrategy].fName; 871 fBenchType = strategies[fCurrentBRDStrategy].fName;
863 872
864 const SkString& path = fImages[fCurrentBRDImage];
865 const SkBitmapRegionDecoder::Strategy strategy = 873 const SkBitmapRegionDecoder::Strategy strategy =
866 strategies[fCurrentBRDStrategy].fStrategy; 874 strategies[fCurrentBRDStrategy].fStrategy;
867 875
868 while (fCurrentColorType < fColorTypes.count()) { 876 while (fCurrentColorType < fColorTypes.count()) {
869 while (fCurrentBRDSampleSize < (int) SK_ARRAY_COUNT(sampleSi zes)) { 877 while (fCurrentBRDSampleSize < (int) SK_ARRAY_COUNT(sampleSi zes)) {
870 while (fCurrentSubsetType <= kLastSingle_SubsetType) { 878 while (fCurrentSubsetType <= kLastSingle_SubsetType) {
871 879
872 880
873 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName (path.c_str())); 881 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName (path.c_str()));
874 const SkColorType colorType = fColorTypes[fCurrentCo lorType]; 882 const SkColorType colorType = fColorTypes[fCurrentCo lorType];
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 fCurrentSubsetType = 0; 928 fCurrentSubsetType = 0;
921 fCurrentBRDSampleSize++; 929 fCurrentBRDSampleSize++;
922 } 930 }
923 fCurrentBRDSampleSize = 0; 931 fCurrentBRDSampleSize = 0;
924 fCurrentColorType++; 932 fCurrentColorType++;
925 } 933 }
926 fCurrentColorType = 0; 934 fCurrentColorType = 0;
927 fCurrentBRDStrategy++; 935 fCurrentBRDStrategy++;
928 } 936 }
929 fCurrentBRDStrategy = 0; 937 fCurrentBRDStrategy = 0;
930 fCurrentBRDImage++;
931 } 938 }
932 939
933 return nullptr; 940 return nullptr;
934 } 941 }
935 942
936 void fillCurrentOptions(ResultsWriter* log) const { 943 void fillCurrentOptions(ResultsWriter* log) const {
937 log->configOption("source_type", fSourceType); 944 log->configOption("source_type", fSourceType);
938 log->configOption("bench_type", fBenchType); 945 log->configOption("bench_type", fBenchType);
939 if (0 == strcmp(fSourceType, "skp")) { 946 if (0 == strcmp(fSourceType, "skp")) {
940 log->configOption("clip", 947 log->configOption("clip",
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 1252
1246 return 0; 1253 return 0;
1247 } 1254 }
1248 1255
1249 #if !defined SK_BUILD_FOR_IOS 1256 #if !defined SK_BUILD_FOR_IOS
1250 int main(int argc, char** argv) { 1257 int main(int argc, char** argv) {
1251 SkCommandLineFlags::Parse(argc, argv); 1258 SkCommandLineFlags::Parse(argc, argv);
1252 return nanobench_main(); 1259 return nanobench_main();
1253 } 1260 }
1254 #endif 1261 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698