aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/PictureOverheadBench.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-04-03 13:25:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-03 13:25:13 -0700
commit649e0451708b72d467e3a0ea4a71720699330c12 (patch)
tree916ffacdfbfa1a1de983bf08ae8d877f804e4269 /bench/PictureOverheadBench.cpp
parent7792dbf7ea089b3bcb81792a3ecda8a6f8b421e7 (diff)
Add a bench to measure SkPictureRecorder constant overhead.
BUG=chromium:470553 Review URL: https://codereview.chromium.org/1061633002
Diffstat (limited to 'bench/PictureOverheadBench.cpp')
-rw-r--r--bench/PictureOverheadBench.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/bench/PictureOverheadBench.cpp b/bench/PictureOverheadBench.cpp
new file mode 100644
index 0000000000..884b005ee7
--- /dev/null
+++ b/bench/PictureOverheadBench.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+// A benchmark designed to isolate the constant overheads of picture recording.
+// We record a very tiny (one op) picture; one op is better than none, as it forces
+// us to allocate memory to store that op... we can't just cheat by holding onto NULLs.
+
+#include "Benchmark.h"
+#include "SkCanvas.h"
+#include "SkPictureRecorder.h"
+
+struct PictureOverheadBench : public Benchmark {
+ const char* onGetName() override { return "picture_overhead"; }
+ bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
+
+ void onDraw(const int loops, SkCanvas*) override {
+ SkPictureRecorder rec;
+ for (int i = 0; i < loops; i++) {
+ SkCanvas* c = rec.beginRecording(SkRect::MakeWH(2000,3000));
+ c->drawRect(SkRect::MakeXYWH(10, 10, 1000, 1000), SkPaint());
+ SkAutoTUnref<SkPicture> pic(rec.endRecordingAsPicture());
+ }
+ }
+};
+DEF_BENCH(return new PictureOverheadBench;)