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

Unified Diff: bench/SkipZeroesBench.cpp

Issue 24440002: Bench baseline for mostly 0 image. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/SkBenchmark.cpp ('k') | bench/benchmain.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SkipZeroesBench.cpp
diff --git a/bench/ImageDecodeBench.cpp b/bench/SkipZeroesBench.cpp
similarity index 58%
copy from bench/ImageDecodeBench.cpp
copy to bench/SkipZeroesBench.cpp
index 3a61163862082830bfcbcc7b3d5f8d421ff9b335..ca6b371b825578a67bd6e680a73569a98201d546 100644
--- a/bench/ImageDecodeBench.cpp
+++ b/bench/SkipZeroesBench.cpp
@@ -18,24 +18,35 @@ __SK_FORCE_IMAGE_DECODER_LINKING;
class SkCanvas;
-class ImageDecodeBench : public SkBenchmark {
+class SkipZeroesBench : public SkBenchmark {
public:
- ImageDecodeBench(void* p, const char* filename)
- : fName("image_decode_")
+ SkipZeroesBench(const char* filename, bool skipZeroes)
+ : fName("SkipZeroes_")
+ , fDecoder(NULL)
, fFilename(filename)
, fStream()
+ , fSkipZeroes(skipZeroes)
, fValid(false) {
- fName.append(SkOSPath::SkBasename(filename));
+ fName.append(filename);
+ if (skipZeroes) {
+ fName.append("_skip_zeroes");
+ } else {
+ fName.append("_write_zeroes");
+ }
fIsRendering = false;
}
+ ~SkipZeroesBench() {
+ SkDELETE(fDecoder);
+ }
protected:
virtual const char* onGetName() SK_OVERRIDE {
return fName.c_str();
}
virtual void onPreDraw() SK_OVERRIDE {
- SkFILEStream fileStream(fFilename.c_str());
+ SkString fullPath = SkOSPath::SkPathJoin(GetResourcePath().c_str(), fFilename.c_str());
+ SkFILEStream fileStream(fullPath.c_str());
fValid = fileStream.isValid() && fileStream.getLength() > 0;
if (fValid) {
const size_t size = fileStream.getLength();
@@ -45,6 +56,14 @@ protected:
} else {
SkAutoTUnref<SkData> skdata(SkData::NewFromMalloc(data, size));
fStream.setData(skdata.get());
+ fDecoder = SkImageDecoder::Factory(&fStream);
+ if (fDecoder) {
+ // Disabling until the feature is checked in.
+ // See https://codereview.chromium.org/24269006/
+ //fDecoder->setSkipWritingZeroes(fSkipZeroes);
+ } else {
+ fValid = false;
+ }
}
}
}
@@ -59,7 +78,8 @@ protected:
// Decode a bunch of times
SkBitmap bm;
for (int i = 0; i < this->getLoops(); ++i) {
- SkDEBUGCODE(bool success =) SkImageDecoder::DecodeStream(&fStream, &bm);
+ SkDEBUGCODE(bool success =) fDecoder->decode(&fStream, &bm,
+ SkImageDecoder::kDecodePixels_Mode);
#ifdef SK_DEBUG
if (!success) {
SkDebugf("failed to decode %s\n", fName.c_str());
@@ -78,13 +98,15 @@ protected:
private:
SkString fName;
+ SkImageDecoder* fDecoder;
mtklein 2013/09/25 13:48:32 SkAutoTDelete?
scroggo 2013/09/25 17:54:57 Done.
const SkString fFilename;
SkMemoryStream fStream;
+ bool fSkipZeroes;
bool fValid;
typedef SkBenchmark INHERITED;
};
-// These are files which call decodePalette
-//DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, ("/usr/local/google/home/scroggo/Downloads/images/hal_163x90.png")); )
-//DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, ("/usr/local/google/home/scroggo/Downloads/images/box_19_top-left.png")); )
+// Enable the true version once the feature is checked in.
+//DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", true)));
+DEF_BENCH( return SkNEW_ARGS(SkipZeroesBench, ("arrow.png", false)));
« no previous file with comments | « bench/SkBenchmark.cpp ('k') | bench/benchmain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698