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

Side by Side Diff: bench/nanobench.cpp

Issue 2084683002: Add --simpleCodec to nanobench flags to run a smaller set of benchmarks (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); 112 DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
113 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); 113 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
114 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); 114 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?");
115 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); 115 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
116 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test ."); 116 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test .");
117 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); 117 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?");
118 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json") ; 118 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json") ;
119 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t ime out"); 119 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t ime out");
120 DEFINE_string(useThermalManager, "0,1,10,1000", "enabled,threshold,sleepTimeMs,T imeoutMs for " 120 DEFINE_string(useThermalManager, "0,1,10,1000", "enabled,threshold,sleepTimeMs,T imeoutMs for "
121 "thermalManager\n"); 121 "thermalManager\n");
122 DEFINE_bool(simpleCodec, false, "Only decode images to N32 opaque or premul");
122 123
123 DEFINE_string(sourceType, "", 124 DEFINE_string(sourceType, "",
124 "Apply usual --match rules to source type: bench, gm, skp, image, etc.") ; 125 "Apply usual --match rules to source type: bench, gm, skp, image, etc.") ;
125 DEFINE_string(benchType, "", 126 DEFINE_string(benchType, "",
126 "Apply usual --match rules to bench type: micro, recording, playback, sk codec, etc."); 127 "Apply usual --match rules to bench type: micro, recording, playback, sk codec, etc.");
127 128
128 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } 129 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
129 130
130 static SkString humanize(double ms) { 131 static SkString humanize(double ms) {
131 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); 132 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 613
613 // Prepare the images for decoding 614 // Prepare the images for decoding
614 if (!CollectImages(FLAGS_images, &fImages)) { 615 if (!CollectImages(FLAGS_images, &fImages)) {
615 exit(1); 616 exit(1);
616 } 617 }
617 if (!CollectImages(FLAGS_colorImages, &fColorImages)) { 618 if (!CollectImages(FLAGS_colorImages, &fColorImages)) {
618 exit(1); 619 exit(1);
619 } 620 }
620 621
621 // Choose the candidate color types for image decoding 622 // Choose the candidate color types for image decoding
622 const SkColorType colorTypes[] = 623 if (FLAGS_simpleCodec) {
scroggo 2016/06/21 14:52:48 Alternatively, you could always reset fColorTypes
623 { kN32_SkColorType, 624 const SkColorType colorTypes[] = {
624 kRGB_565_SkColorType, 625 kN32_SkColorType,
625 kAlpha_8_SkColorType, 626 };
626 kIndex_8_SkColorType, 627
627 kGray_8_SkColorType }; 628 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes));
628 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes)); 629 } else {
630 const SkColorType colorTypes[] = {
631 kN32_SkColorType,
632 kRGB_565_SkColorType,
633 kAlpha_8_SkColorType,
634 kIndex_8_SkColorType,
635 kGray_8_SkColorType,
636 };
637
638 fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes));
639 }
629 } 640 }
630 641
631 static sk_sp<SkPicture> ReadPicture(const char* path) { 642 static sk_sp<SkPicture> ReadPicture(const char* path) {
632 // Not strictly necessary, as it will be checked again later, 643 // Not strictly necessary, as it will be checked again later,
633 // but helps to avoid a lot of pointless work if we're going to skip it. 644 // but helps to avoid a lot of pointless work if we're going to skip it.
634 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path) .c_str())) { 645 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path) .c_str())) {
635 return nullptr; 646 return nullptr;
636 } 647 }
637 648
638 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); 649 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 if (!codec) { 767 if (!codec) {
757 // Nothing to time. 768 // Nothing to time.
758 SkDebugf("Cannot find codec for %s\n", path.c_str()); 769 SkDebugf("Cannot find codec for %s\n", path.c_str());
759 continue; 770 continue;
760 } 771 }
761 772
762 while (fCurrentColorType < fColorTypes.count()) { 773 while (fCurrentColorType < fColorTypes.count()) {
763 const SkColorType colorType = fColorTypes[fCurrentColorType]; 774 const SkColorType colorType = fColorTypes[fCurrentColorType];
764 775
765 SkAlphaType alphaType = codec->getInfo().alphaType(); 776 SkAlphaType alphaType = codec->getInfo().alphaType();
766 switch (alphaType) { 777 if (FLAGS_simpleCodec) {
767 case kOpaque_SkAlphaType: 778 if (kUnpremul_SkAlphaType == alphaType) {
768 // We only need to test one alpha type (opaque). 779 alphaType = kPremul_SkAlphaType;
769 fCurrentColorType++; 780 }
770 break; 781
771 case kUnpremul_SkAlphaType: 782 fCurrentColorType++;
772 case kPremul_SkAlphaType: 783 } else {
773 if (0 == fCurrentAlphaType) { 784 switch (alphaType) {
774 // Test unpremul first. 785 case kOpaque_SkAlphaType:
775 alphaType = kUnpremul_SkAlphaType; 786 // We only need to test one alpha type (opaque).
776 fCurrentAlphaType++;
777 } else {
778 // Test premul.
779 alphaType = kPremul_SkAlphaType;
780 fCurrentAlphaType = 0;
781 fCurrentColorType++; 787 fCurrentColorType++;
782 } 788 break;
783 break; 789 case kUnpremul_SkAlphaType:
784 default: 790 case kPremul_SkAlphaType:
785 SkASSERT(false); 791 if (0 == fCurrentAlphaType) {
786 fCurrentColorType++; 792 // Test unpremul first.
787 break; 793 alphaType = kUnpremul_SkAlphaType;
794 fCurrentAlphaType++;
795 } else {
796 // Test premul.
797 alphaType = kPremul_SkAlphaType;
798 fCurrentAlphaType = 0;
799 fCurrentColorType++;
800 }
801 break;
802 default:
803 SkASSERT(false);
804 fCurrentColorType++;
805 break;
806 }
788 } 807 }
789 808
790 // Make sure we can decode to this color type and alpha type. 809 // Make sure we can decode to this color type and alpha type.
791 SkImageInfo info = 810 SkImageInfo info =
792 codec->getInfo().makeColorType(colorType).makeAlphaType( alphaType); 811 codec->getInfo().makeColorType(colorType).makeAlphaType( alphaType);
793 const size_t rowBytes = info.minRowBytes(); 812 const size_t rowBytes = info.minRowBytes();
794 SkAutoMalloc storage(info.getSafeSize(rowBytes)); 813 SkAutoMalloc storage(info.getSafeSize(rowBytes));
795 814
796 // Used if fCurrentColorType is kIndex_8_SkColorType 815 // Used if fCurrentColorType is kIndex_8_SkColorType
797 int colorCount = 256; 816 int colorCount = 256;
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 1309
1291 return 0; 1310 return 0;
1292 } 1311 }
1293 1312
1294 #if !defined SK_BUILD_FOR_IOS 1313 #if !defined SK_BUILD_FOR_IOS
1295 int main(int argc, char** argv) { 1314 int main(int argc, char** argv) {
1296 SkCommandLineFlags::Parse(argc, argv); 1315 SkCommandLineFlags::Parse(argc, argv);
1297 return nanobench_main(); 1316 return nanobench_main();
1298 } 1317 }
1299 #endif 1318 #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