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

Side by Side Diff: bench/nanobench.cpp

Issue 1061323003: Change to add zoom animations to nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows warning Created 5 years, 8 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/SKPBench.cpp ('k') | gyp/bench.gyp » ('j') | 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"
11 11
12 #include "Benchmark.h" 12 #include "Benchmark.h"
13 #include "CodecBench.h" 13 #include "CodecBench.h"
14 #include "CrashHandler.h" 14 #include "CrashHandler.h"
15 #include "DecodingBench.h" 15 #include "DecodingBench.h"
16 #include "DecodingSubsetBench.h" 16 #include "DecodingSubsetBench.h"
17 #include "GMBench.h" 17 #include "GMBench.h"
18 #include "ProcStats.h" 18 #include "ProcStats.h"
19 #include "ResultsWriter.h" 19 #include "ResultsWriter.h"
20 #include "RecordingBench.h" 20 #include "RecordingBench.h"
21 #include "SKPAnimationBench.h"
21 #include "SKPBench.h" 22 #include "SKPBench.h"
22 #include "Stats.h" 23 #include "Stats.h"
23 #include "Timer.h" 24 #include "Timer.h"
24 25
25 #include "SkBBoxHierarchy.h" 26 #include "SkBBoxHierarchy.h"
26 #include "SkCanvas.h" 27 #include "SkCanvas.h"
27 #include "SkCodec.h" 28 #include "SkCodec.h"
28 #include "SkCommonFlags.h" 29 #include "SkCommonFlags.h"
29 #include "SkData.h" 30 #include "SkData.h"
30 #include "SkForceLinking.h" 31 #include "SkForceLinking.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allow s to lag."); 76 DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allow s to lag.");
76 DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling back to " 77 DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling back to "
77 "software path rendering."); 78 "software path rendering.");
78 79
79 DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); 80 DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
80 DEFINE_int32(maxCalibrationAttempts, 3, 81 DEFINE_int32(maxCalibrationAttempts, 3,
81 "Try up to this many times to guess loops for a bench, or skip the bench."); 82 "Try up to this many times to guess loops for a bench, or skip the bench.");
82 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); 83 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this.");
83 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); 84 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs.");
84 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); 85 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs.");
86 DEFINE_string(zoom, "1.0,1", "Comma-separated scale,step zoom factors for SKPs." );
85 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); 87 DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
86 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); 88 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
87 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); 89 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
88 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test ."); 90 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test .");
89 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); 91 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?");
90 92
91 static SkString humanize(double ms) { 93 static SkString humanize(double ms) {
92 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); 94 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
93 return HumanizeMs(ms); 95 return HumanizeMs(ms);
94 } 96 }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 BenchmarkStream() : fBenches(BenchRegistry::Head()) 486 BenchmarkStream() : fBenches(BenchRegistry::Head())
485 , fGMs(skiagm::GMRegistry::Head()) 487 , fGMs(skiagm::GMRegistry::Head())
486 , fCurrentRecording(0) 488 , fCurrentRecording(0)
487 , fCurrentScale(0) 489 , fCurrentScale(0)
488 , fCurrentSKP(0) 490 , fCurrentSKP(0)
489 , fCurrentUseMPD(0) 491 , fCurrentUseMPD(0)
490 , fCurrentCodec(0) 492 , fCurrentCodec(0)
491 , fCurrentImage(0) 493 , fCurrentImage(0)
492 , fCurrentSubsetImage(0) 494 , fCurrentSubsetImage(0)
493 , fCurrentColorType(0) 495 , fCurrentColorType(0)
496 , fCurrentAnimSKP(0)
494 , fDivisor(2) { 497 , fDivisor(2) {
495 for (int i = 0; i < FLAGS_skps.count(); i++) { 498 for (int i = 0; i < FLAGS_skps.count(); i++) {
496 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { 499 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
497 fSKPs.push_back() = FLAGS_skps[i]; 500 fSKPs.push_back() = FLAGS_skps[i];
498 } else { 501 } else {
499 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); 502 SkOSFile::Iter it(FLAGS_skps[i], ".skp");
500 SkString path; 503 SkString path;
501 while (it.next(&path)) { 504 while (it.next(&path)) {
502 fSKPs.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str ()); 505 fSKPs.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str ());
503 } 506 }
504 } 507 }
505 } 508 }
506 509
507 if (4 != sscanf(FLAGS_clip[0], "%d,%d,%d,%d", 510 if (4 != sscanf(FLAGS_clip[0], "%d,%d,%d,%d",
508 &fClip.fLeft, &fClip.fTop, &fClip.fRight, &fClip.fBottom )) { 511 &fClip.fLeft, &fClip.fTop, &fClip.fRight, &fClip.fBottom )) {
509 SkDebugf("Can't parse %s from --clip as an SkIRect.\n", FLAGS_clip[0 ]); 512 SkDebugf("Can't parse %s from --clip as an SkIRect.\n", FLAGS_clip[0 ]);
510 exit(1); 513 exit(1);
511 } 514 }
512 515
513 for (int i = 0; i < FLAGS_scales.count(); i++) { 516 for (int i = 0; i < FLAGS_scales.count(); i++) {
514 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) { 517 if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) {
515 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS _scales[i]); 518 SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS _scales[i]);
516 exit(1); 519 exit(1);
517 } 520 }
518 } 521 }
519 522
523 if (2 != sscanf(FLAGS_zoom[0], "%f,%d", &fZoomScale, &fZoomSteps)) {
524 SkDebugf("Can't parse %s from --zoom as a scale,step.\n", FLAGS_zoom [0]);
525 exit(1);
526 }
527
520 fUseMPDs.push_back() = false; 528 fUseMPDs.push_back() = false;
521 if (FLAGS_mpd) { 529 if (FLAGS_mpd) {
522 fUseMPDs.push_back() = true; 530 fUseMPDs.push_back() = true;
523 } 531 }
524 532
525 // Prepare the images for decoding 533 // Prepare the images for decoding
526 for (int i = 0; i < FLAGS_images.count(); i++) { 534 for (int i = 0; i < FLAGS_images.count(); i++) {
527 const char* flag = FLAGS_images[i]; 535 const char* flag = FLAGS_images[i];
528 if (sk_isdir(flag)) { 536 if (sk_isdir(flag)) {
529 // If the value passed in is a directory, add all the images 537 // If the value passed in is a directory, add all the images
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 pic->playback(recorder.beginRecording(pic->cullRect().wi dth(), 626 pic->playback(recorder.beginRecording(pic->cullRect().wi dth(),
619 pic->cullRect().he ight(), 627 pic->cullRect().he ight(),
620 &factory, 628 &factory,
621 fUseMPDs[fCurrentU seMPD] ? kFlags : 0)); 629 fUseMPDs[fCurrentU seMPD] ? kFlags : 0));
622 pic.reset(recorder.endRecording()); 630 pic.reset(recorder.endRecording());
623 } 631 }
624 SkString name = SkOSPath::Basename(path.c_str()); 632 SkString name = SkOSPath::Basename(path.c_str());
625 fSourceType = "skp"; 633 fSourceType = "skp";
626 fBenchType = "playback"; 634 fBenchType = "playback";
627 return SkNEW_ARGS(SKPBench, 635 return SkNEW_ARGS(SKPBench,
628 (name.c_str(), pic.get(), fClip, 636 (name.c_str(), pic.get(), fClip,
629 fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++]) ); 637 fScales[fCurrentScale], fUseMPDs[fCurrent UseMPD++]));
638
630 } 639 }
631 fCurrentUseMPD = 0; 640 fCurrentUseMPD = 0;
632 fCurrentSKP++; 641 fCurrentSKP++;
633 } 642 }
634 fCurrentSKP = 0; 643 fCurrentSKP = 0;
635 fCurrentScale++; 644 fCurrentScale++;
636 } 645 }
637 646
647 // Now loop over each skp again if we have an animation
648 if (fZoomScale != 1.0f && fZoomSteps != 1) {
649 while (fCurrentAnimSKP < fSKPs.count()) {
650 const SkString& path = fSKPs[fCurrentAnimSKP];
651 SkAutoTUnref<SkPicture> pic;
652 if (!ReadPicture(path.c_str(), &pic)) {
653 fCurrentAnimSKP++;
654 continue;
655 }
656
657 fCurrentAnimSKP++;
658 SkString name = SkOSPath::Basename(path.c_str());
659 SkMatrix anim = SkMatrix::I();
660 anim.setScale(fZoomScale, fZoomScale);
661 return SkNEW_ARGS(SKPAnimationBench, (name.c_str(), pic.get(), f Clip, anim,
662 fZoomSteps));
663 }
664 }
665
666
638 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { 667 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) {
639 const SkString& path = fImages[fCurrentCodec]; 668 const SkString& path = fImages[fCurrentCodec];
640 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); 669 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
641 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 670 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
642 if (!codec) { 671 if (!codec) {
643 // Nothing to time. 672 // Nothing to time.
644 SkDebugf("Cannot find codec for %s\n", path.c_str()); 673 SkDebugf("Cannot find codec for %s\n", path.c_str());
645 continue; 674 continue;
646 } 675 }
647 676
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 811
783 private: 812 private:
784 const BenchRegistry* fBenches; 813 const BenchRegistry* fBenches;
785 const skiagm::GMRegistry* fGMs; 814 const skiagm::GMRegistry* fGMs;
786 SkIRect fClip; 815 SkIRect fClip;
787 SkTArray<SkScalar> fScales; 816 SkTArray<SkScalar> fScales;
788 SkTArray<SkString> fSKPs; 817 SkTArray<SkString> fSKPs;
789 SkTArray<bool> fUseMPDs; 818 SkTArray<bool> fUseMPDs;
790 SkTArray<SkString> fImages; 819 SkTArray<SkString> fImages;
791 SkTArray<SkColorType> fColorTypes; 820 SkTArray<SkColorType> fColorTypes;
821 SkScalar fZoomScale;
822 int fZoomSteps;
792 823
793 double fSKPBytes, fSKPOps; 824 double fSKPBytes, fSKPOps;
794 825
795 const char* fSourceType; // What we're benching: bench, GM, SKP, ... 826 const char* fSourceType; // What we're benching: bench, GM, SKP, ...
796 const char* fBenchType; // How we bench it: micro, recording, playback, .. . 827 const char* fBenchType; // How we bench it: micro, recording, playback, .. .
797 int fCurrentRecording; 828 int fCurrentRecording;
798 int fCurrentScale; 829 int fCurrentScale;
799 int fCurrentSKP; 830 int fCurrentSKP;
800 int fCurrentUseMPD; 831 int fCurrentUseMPD;
801 int fCurrentCodec; 832 int fCurrentCodec;
802 int fCurrentImage; 833 int fCurrentImage;
803 int fCurrentSubsetImage; 834 int fCurrentSubsetImage;
804 int fCurrentColorType; 835 int fCurrentColorType;
836 int fCurrentAnimSKP;
805 const int fDivisor; 837 const int fDivisor;
806 }; 838 };
807 839
808 int nanobench_main(); 840 int nanobench_main();
809 int nanobench_main() { 841 int nanobench_main() {
810 SetupCrashHandler(); 842 SetupCrashHandler();
811 SkAutoGraphics ag; 843 SkAutoGraphics ag;
812 SkTaskGroup::Enabler enabled; 844 SkTaskGroup::Enabler enabled;
813 845
814 #if SK_SUPPORT_GPU 846 #if SK_SUPPORT_GPU
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 1024
993 return 0; 1025 return 0;
994 } 1026 }
995 1027
996 #if !defined SK_BUILD_FOR_IOS 1028 #if !defined SK_BUILD_FOR_IOS
997 int main(int argc, char** argv) { 1029 int main(int argc, char** argv) {
998 SkCommandLineFlags::Parse(argc, argv); 1030 SkCommandLineFlags::Parse(argc, argv);
999 return nanobench_main(); 1031 return nanobench_main();
1000 } 1032 }
1001 #endif 1033 #endif
OLDNEW
« no previous file with comments | « bench/SKPBench.cpp ('k') | gyp/bench.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698