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

Side by Side Diff: bench/nanobench.cpp

Issue 1044363002: Add timing SkCodec to nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
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 "CrashHandler.h" 14 #include "CrashHandler.h"
14 #include "DecodingBench.h" 15 #include "DecodingBench.h"
15 #include "DecodingSubsetBench.h" 16 #include "DecodingSubsetBench.h"
16 #include "GMBench.h" 17 #include "GMBench.h"
17 #include "ProcStats.h" 18 #include "ProcStats.h"
18 #include "ResultsWriter.h" 19 #include "ResultsWriter.h"
19 #include "RecordingBench.h" 20 #include "RecordingBench.h"
20 #include "SKPBench.h" 21 #include "SKPBench.h"
21 #include "Stats.h" 22 #include "Stats.h"
22 #include "Timer.h" 23 #include "Timer.h"
23 24
24 #include "SkBBoxHierarchy.h" 25 #include "SkBBoxHierarchy.h"
25 #include "SkCanvas.h" 26 #include "SkCanvas.h"
27 #include "SkCodec.h"
26 #include "SkCommonFlags.h" 28 #include "SkCommonFlags.h"
27 #include "SkData.h" 29 #include "SkData.h"
28 #include "SkForceLinking.h" 30 #include "SkForceLinking.h"
29 #include "SkGraphics.h" 31 #include "SkGraphics.h"
30 #include "SkOSFile.h" 32 #include "SkOSFile.h"
31 #include "SkPictureRecorder.h" 33 #include "SkPictureRecorder.h"
32 #include "SkPictureUtils.h" 34 #include "SkPictureUtils.h"
33 #include "SkString.h" 35 #include "SkString.h"
34 #include "SkSurface.h" 36 #include "SkSurface.h"
35 #include "SkTaskGroup.h" 37 #include "SkTaskGroup.h"
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 480
479 481
480 class BenchmarkStream { 482 class BenchmarkStream {
481 public: 483 public:
482 BenchmarkStream() : fBenches(BenchRegistry::Head()) 484 BenchmarkStream() : fBenches(BenchRegistry::Head())
483 , fGMs(skiagm::GMRegistry::Head()) 485 , fGMs(skiagm::GMRegistry::Head())
484 , fCurrentRecording(0) 486 , fCurrentRecording(0)
485 , fCurrentScale(0) 487 , fCurrentScale(0)
486 , fCurrentSKP(0) 488 , fCurrentSKP(0)
487 , fCurrentUseMPD(0) 489 , fCurrentUseMPD(0)
490 , fCurrentCodec(0)
488 , fCurrentImage(0) 491 , fCurrentImage(0)
489 , fCurrentSubsetImage(0) 492 , fCurrentSubsetImage(0)
490 , fCurrentColorType(0) 493 , fCurrentColorType(0)
491 , fDivisor(2) { 494 , fDivisor(2) {
492 for (int i = 0; i < FLAGS_skps.count(); i++) { 495 for (int i = 0; i < FLAGS_skps.count(); i++) {
493 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { 496 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
494 fSKPs.push_back() = FLAGS_skps[i]; 497 fSKPs.push_back() = FLAGS_skps[i];
495 } else { 498 } else {
496 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); 499 SkOSFile::Iter it(FLAGS_skps[i], ".skp");
497 SkString path; 500 SkString path;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 (name.c_str(), pic.get(), fClip, 628 (name.c_str(), pic.get(), fClip,
626 fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++]) ); 629 fScales[fCurrentScale], fUseMPDs[fCurrentUseMPD++]) );
627 } 630 }
628 fCurrentUseMPD = 0; 631 fCurrentUseMPD = 0;
629 fCurrentSKP++; 632 fCurrentSKP++;
630 } 633 }
631 fCurrentSKP = 0; 634 fCurrentSKP = 0;
632 fCurrentScale++; 635 fCurrentScale++;
633 } 636 }
634 637
638 for (; fCurrentCodec < fImages.count(); fCurrentCodec++) {
djsollen 2015/04/01 16:06:07 range based for loop? C++11!!
scroggo 2015/04/01 17:18:04 Will that work here? I need to use fCurrentCodec,
639 const SkString& path = fImages[fCurrentCodec];
640 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
641 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
642 SkASSERT(codec);
scroggo 2015/03/31 19:20:03 Maybe we should add the filter from DM that says t
643 if (!codec) {
644 // Nothing to time.
645 continue;
646 }
647 while (fCurrentColorType < fColorTypes.count()) {
djsollen 2015/04/01 16:06:07 range based loop
scroggo 2015/04/01 17:18:04 Again, I do not think that will work, unless I'm m
648 SkColorType colorType = fColorTypes[fCurrentColorType];
649 fCurrentColorType++;
650 // Make sure we can decode to this color type.
651 SkBitmap bitmap;
652 SkImageInfo info = codec->getInfo().makeColorType(colorType);
653 bitmap.allocPixels(info);
654 const SkImageGenerator::Result result = codec->getPixels(
655 bitmap.info(), bitmap.getPixels(), bitmap.rowBytes());
656 switch (result) {
657 case SkImageGenerator::kSuccess:
658 case SkImageGenerator::kIncompleteInput:
659 return new CodecBench(SkOSPath::Basename(path.c_str()),
660 encoded, colorType);
661 case SkImageGenerator::kInvalidConversion:
662 // This is okay. Not all conversions are valid.
663 break;
664 case SkImageGenerator::kCouldNotRewind:
665 // FIXME: This is due to a bug in some implementations
666 // of SkCodec. All should support rewinding.
scroggo 2015/03/31 19:20:03 All should support rewinding - in the case where w
djsollen 2015/04/01 16:06:07 Should this fire an assert then?
scroggo 2015/04/01 17:18:04 Once I fix all our SkCodecs to handle rewinding pr
667 break;
668 default:
669 // This represents some sort of failure.
670 SkASSERT(false);
671 break;
672 }
673 }
674 fCurrentColorType = 0;
675 }
676
635 // Run the DecodingBenches 677 // Run the DecodingBenches
636 while (fCurrentImage < fImages.count()) { 678 while (fCurrentImage < fImages.count()) {
637 while (fCurrentColorType < fColorTypes.count()) { 679 while (fCurrentColorType < fColorTypes.count()) {
638 const SkString& path = fImages[fCurrentImage]; 680 const SkString& path = fImages[fCurrentImage];
639 SkColorType colorType = fColorTypes[fCurrentColorType]; 681 SkColorType colorType = fColorTypes[fCurrentColorType];
640 fCurrentColorType++; 682 fCurrentColorType++;
641 // Check if the image decodes before creating the benchmark 683 // Check if the image decodes to the right color type
684 // before creating the benchmark
642 SkBitmap bitmap; 685 SkBitmap bitmap;
643 if (SkImageDecoder::DecodeFile(path.c_str(), &bitmap, 686 if (SkImageDecoder::DecodeFile(path.c_str(), &bitmap,
644 colorType, SkImageDecoder::kDecodePixels_Mode)) { 687 colorType, SkImageDecoder::kDecodePixels_Mode)
688 && bitmap.colorType() == colorType) {
645 return new DecodingBench(path, colorType); 689 return new DecodingBench(path, colorType);
646 } 690 }
647 } 691 }
648 fCurrentColorType = 0; 692 fCurrentColorType = 0;
649 fCurrentImage++; 693 fCurrentImage++;
650 } 694 }
651 695
652 // Run the DecodingSubsetBenches 696 // Run the DecodingSubsetBenches
653 while (fCurrentSubsetImage < fImages.count()) { 697 while (fCurrentSubsetImage < fImages.count()) {
654 while (fCurrentColorType < fColorTypes.count()) { 698 while (fCurrentColorType < fColorTypes.count()) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 SkTArray<SkColorType> fColorTypes; 778 SkTArray<SkColorType> fColorTypes;
735 779
736 double fSKPBytes, fSKPOps; 780 double fSKPBytes, fSKPOps;
737 781
738 const char* fSourceType; // What we're benching: bench, GM, SKP, ... 782 const char* fSourceType; // What we're benching: bench, GM, SKP, ...
739 const char* fBenchType; // How we bench it: micro, recording, playback, .. . 783 const char* fBenchType; // How we bench it: micro, recording, playback, .. .
740 int fCurrentRecording; 784 int fCurrentRecording;
741 int fCurrentScale; 785 int fCurrentScale;
742 int fCurrentSKP; 786 int fCurrentSKP;
743 int fCurrentUseMPD; 787 int fCurrentUseMPD;
788 int fCurrentCodec;
744 int fCurrentImage; 789 int fCurrentImage;
745 int fCurrentSubsetImage; 790 int fCurrentSubsetImage;
746 int fCurrentColorType; 791 int fCurrentColorType;
747 const int fDivisor; 792 const int fDivisor;
748 }; 793 };
749 794
750 int nanobench_main(); 795 int nanobench_main();
751 int nanobench_main() { 796 int nanobench_main() {
752 SetupCrashHandler(); 797 SetupCrashHandler();
753 SkAutoGraphics ag; 798 SkAutoGraphics ag;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 979
935 return 0; 980 return 0;
936 } 981 }
937 982
938 #if !defined SK_BUILD_FOR_IOS 983 #if !defined SK_BUILD_FOR_IOS
939 int main(int argc, char** argv) { 984 int main(int argc, char** argv) {
940 SkCommandLineFlags::Parse(argc, argv); 985 SkCommandLineFlags::Parse(argc, argv);
941 return nanobench_main(); 986 return nanobench_main();
942 } 987 }
943 #endif 988 #endif
OLDNEW
« bench/CodecBench.cpp ('K') | « bench/DecodingBench.cpp ('k') | gyp/bench.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698