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

Unified Diff: bench/CodecBench.cpp

Issue 1572673004: Add --zero_init to simulate zero-initialized memory in CodecBench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: hoist Created 4 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/CodecBench.cpp
diff --git a/bench/CodecBench.cpp b/bench/CodecBench.cpp
index 66831fb24c6bc16b9696c5951a291f92e09f87e6..fc52edfb07bcda61fe6b40921e00c71a110608c6 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?");
scroggo 2016/01/08 22:20:29 Hahaha - we could also add this as another option
+
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698