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

Side by Side Diff: bench/nanobench.cpp

Issue 1211253003: Make nanobench zoom animation time based (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_printvalueswithverbose
Patch Set: fix msvc Created 5 years, 5 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 | « bench/SKPAnimationBench.cpp ('k') | 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 exit(1); 593 exit(1);
593 } 594 }
594 595
595 for (int i = 0; i < FLAGS_scales.count(); i++) { 596 for (int i = 0; i < FLAGS_scales.count(); i++) {
596 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) { 597 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) {
597 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS _scales[i]); 598 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS _scales[i]);
598 exit(1); 599 exit(1);
599 } 600 }
600 } 601 }
601 602
602 if (2 != sscanf(FLAGS_zoom[0], "%f,%d", &fZoomScale, &fZoomSteps)) { 603 if (2 != sscanf(FLAGS_zoom[0], "%f,%lf", &fZoomMax, &fZoomPeriodMs)) {
603 SkDebugf("Can't parse %s from --zoom as a scale,step.\n", FLAGS_zoom [0]); 604 SkDebugf("Can't parse %s from --zoom as a zoomMax,zoomPeriodMs.\n", FLAGS_zoom[0]);
604 exit(1); 605 exit(1);
605 } 606 }
606 607
607 if (FLAGS_mpd) { 608 if (FLAGS_mpd) {
608 fUseMPDs.push_back() = true; 609 fUseMPDs.push_back() = true;
609 } 610 }
610 fUseMPDs.push_back() = false; 611 fUseMPDs.push_back() = false;
611 612
612 // Prepare the images for decoding 613 // Prepare the images for decoding
613 for (int i = 0; i < FLAGS_images.count(); i++) { 614 for (int i = 0; i < FLAGS_images.count(); i++) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 722
722 } 723 }
723 fCurrentUseMPD = 0; 724 fCurrentUseMPD = 0;
724 fCurrentSKP++; 725 fCurrentSKP++;
725 } 726 }
726 fCurrentSKP = 0; 727 fCurrentSKP = 0;
727 fCurrentScale++; 728 fCurrentScale++;
728 } 729 }
729 730
730 // Now loop over each skp again if we have an animation 731 // Now loop over each skp again if we have an animation
731 if (fZoomScale != 1.0f && fZoomSteps != 1) { 732 if (fZoomMax != 1.0f && fZoomPeriodMs > 0) {
732 while (fCurrentAnimSKP < fSKPs.count()) { 733 while (fCurrentAnimSKP < fSKPs.count()) {
733 const SkString& path = fSKPs[fCurrentAnimSKP]; 734 const SkString& path = fSKPs[fCurrentAnimSKP];
734 SkAutoTUnref<SkPicture> pic; 735 SkAutoTUnref<SkPicture> pic;
735 if (!ReadPicture(path.c_str(), &pic)) { 736 if (!ReadPicture(path.c_str(), &pic)) {
736 fCurrentAnimSKP++; 737 fCurrentAnimSKP++;
737 continue; 738 continue;
738 } 739 }
739 740
740 fCurrentAnimSKP++; 741 fCurrentAnimSKP++;
741 SkString name = SkOSPath::Basename(path.c_str()); 742 SkString name = SkOSPath::Basename(path.c_str());
742 SkMatrix anim = SkMatrix::I(); 743 SkAutoTUnref<SKPAnimationBench::Animation> animation(
743 anim.setScale(fZoomScale, fZoomScale); 744 SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriod Ms));
744 return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), f Clip, anim, 745 return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), f Clip, animation,
745 fZoomSteps, FLAGS_loopSKP)); 746 FLAGS_loopSKP));
746 } 747 }
747 } 748 }
748 749
749 750
750 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { 751 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) {
751 const SkString& path = fImages[fCurrentCodec]; 752 const SkString& path = fImages[fCurrentCodec];
752 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); 753 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
753 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 754 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
754 if (!codec) { 755 if (!codec) {
755 // Nothing to time. 756 // Nothing to time.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 }; 904 };
904 905
905 const BenchRegistry* fBenches; 906 const BenchRegistry* fBenches;
906 const skiagm::GMRegistry* fGMs; 907 const skiagm::GMRegistry* fGMs;
907 SkIRect fClip; 908 SkIRect fClip;
908 SkTArray<SkScalar> fScales; 909 SkTArray<SkScalar> fScales;
909 SkTArray<SkString> fSKPs; 910 SkTArray<SkString> fSKPs;
910 SkTArray<bool> fUseMPDs; 911 SkTArray<bool> fUseMPDs;
911 SkTArray<SkString> fImages; 912 SkTArray<SkString> fImages;
912 SkTArray<SkColorType> fColorTypes; 913 SkTArray<SkColorType> fColorTypes;
913 SkScalar fZoomScale; 914 SkScalar fZoomMax;
914 int fZoomSteps; 915 double fZoomPeriodMs;
915 916
916 double fSKPBytes, fSKPOps; 917 double fSKPBytes, fSKPOps;
917 918
918 const char* fSourceType; // What we're benching: bench, GM, SKP, ... 919 const char* fSourceType; // What we're benching: bench, GM, SKP, ...
919 const char* fBenchType; // How we bench it: micro, recording, playback, .. . 920 const char* fBenchType; // How we bench it: micro, recording, playback, .. .
920 int fCurrentRecording; 921 int fCurrentRecording;
921 int fCurrentScale; 922 int fCurrentScale;
922 int fCurrentSKP; 923 int fCurrentSKP;
923 int fCurrentUseMPD; 924 int fCurrentUseMPD;
924 int fCurrentCodec; 925 int fCurrentCodec;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 1154
1154 return 0; 1155 return 0;
1155 } 1156 }
1156 1157
1157 #if !defined SK_BUILD_FOR_IOS 1158 #if !defined SK_BUILD_FOR_IOS
1158 int main(int argc, char** argv) { 1159 int main(int argc, char** argv) {
1159 SkCommandLineFlags::Parse(argc, argv); 1160 SkCommandLineFlags::Parse(argc, argv);
1160 return nanobench_main(); 1161 return nanobench_main();
1161 } 1162 }
1162 #endif 1163 #endif
OLDNEW
« no previous file with comments | « bench/SKPAnimationBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698