diff options
author | mtklein <mtklein@chromium.org> | 2016-01-08 14:20:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-08 14:20:36 -0800 |
commit | c146aa6fd45dffe29b4f565aafd4ec3a16d9f73b (patch) | |
tree | 0c7bd9303f6a21eeff457c2302166ed4030deb87 | |
parent | 1bcbc8f8c0747691496d779055675bc47ca65c86 (diff) |
Add --zero_init to simulate zero-initialized memory in CodecBench
BUG=skia:4767
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1572673004
Review URL: https://codereview.chromium.org/1572673004
-rw-r--r-- | bench/CodecBench.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bench/CodecBench.cpp b/bench/CodecBench.cpp index 66831fb24c..fc52edfb07 100644 --- a/bench/CodecBench.cpp +++ b/bench/CodecBench.cpp @@ -9,8 +9,12 @@ #include "CodecBenchPriv.h" #include "SkBitmap.h" #include "SkCodec.h" +#include "SkCommandLineFlags.h" #include "SkOSFile.h" +// Actually zeroing the memory would throw off timing, so we just lie. +DEFINE_bool(zero_init, false, "Pretend our destination is zero-intialized, simulating Android?"); + CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType, SkAlphaType alphaType) : fColorType(colorType) @@ -47,6 +51,10 @@ void CodecBench::onDraw(int n, SkCanvas* canvas) { SkAutoTDelete<SkCodec> codec; SkPMColor colorTable[256]; int colorCount; + SkCodec::Options options; + if (FLAGS_zero_init) { + options.fZeroInitialized = SkCodec::kYes_ZeroInitialized; + } for (int i = 0; i < n; i++) { colorCount = 256; codec.reset(SkCodec::NewFromData(fData)); @@ -54,7 +62,7 @@ void CodecBench::onDraw(int n, SkCanvas* canvas) { const SkCodec::Result result = #endif codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(), - nullptr, colorTable, &colorCount); + &options, colorTable, &colorCount); SkASSERT(result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput); } |