aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/RecordingBench.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-09-10 12:19:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-10 12:19:30 -0700
commitfd731ce804cd3223318f3feee2c98404890b65f2 (patch)
treea0d8da69bff1916ff480fa98e0e3f2a5aef7cb7a /bench/RecordingBench.cpp
parent33bce0a68bf24696f35b6ce102e6eed2873b69a4 (diff)
Measure picture recording speed in nanobench.
Today we measure SkPicture playback speed, but not the time it takes to record the SkPicture. This fixes that by reading SKPs from disk and re-recording them. On the console, recording shows up first as the nonrendering skp benches, followed later by the usual playback benches: maxrss loops min median mean max stddev samples config bench 51M 2 165µs 168µs 169µs 178µs 3% ▆▄▃█▂▄▁▂▁▁ nonrendering tabl_slashdot.skp 57M 1 9.72ms 9.77ms 9.79ms 9.97ms 1% █▂▂▅▃▂▁▄▂▁ nonrendering desk_pokemonwiki.skp 57M 32 2.92µs 2.96µs 3.03µs 3.46µs 6% ▅▁▁▁▁▁▁█▂▁ nonrendering desk_yahoosports.skp ... 147M 1 3.86ms 3.87ms 3.97ms 4.81ms 7% █▁▁▁▁▁▁▁▁▁ 8888 tabl_slashdot.skp_1 147M 1 4.54ms 4.56ms 4.55ms 4.56ms 0% █▅▇▅█▅▂▁▅▁ 565 tabl_slashdot.skp_1 147M 2 3.08ms 3.24ms 4.17ms 8.18ms 50% █▁▁█▁▁▁▁▁▁ gpu tabl_slashdot.skp_1 147M 1 1.61ms 1.62ms 1.69ms 2.33ms 13% █▁▁▁▁▁▁▁▁▁ 8888 desk_pokemonwiki.skp_1 147M 1 1.44ms 1.44ms 1.45ms 1.47ms 1% ▅▂█▂▂▅▁▁▂▁ 565 desk_pokemonwiki.skp_1 ... On skiaperf.com, they'll also be separated out from playback benches by bench_type. BUG=skia: R=reed@google.com, mtklein@google.com, jcgregorio@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/559153002
Diffstat (limited to 'bench/RecordingBench.cpp')
-rw-r--r--bench/RecordingBench.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/bench/RecordingBench.cpp b/bench/RecordingBench.cpp
new file mode 100644
index 0000000000..ee626bc52c
--- /dev/null
+++ b/bench/RecordingBench.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "RecordingBench.h"
+
+#include "SkBBHFactory.h"
+#include "SkPictureRecorder.h"
+
+static const int kTileSize = 256;
+
+RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH)
+ : fSrc(SkRef(pic))
+ , fName(name)
+ , fUseBBH(useBBH) {}
+
+const char* RecordingBench::onGetName() {
+ return fName.c_str();
+}
+
+bool RecordingBench::isSuitableFor(Backend backend) {
+ return backend == kNonRendering_Backend;
+}
+
+SkIPoint RecordingBench::onGetSize() {
+ return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()),
+ SkScalarCeilToInt(fSrc->cullRect().height()));
+}
+
+void RecordingBench::onDraw(const int loops, SkCanvas*) {
+ SkTileGridFactory::TileGridInfo info;
+ info.fTileInterval.set(kTileSize, kTileSize);
+ info.fMargin.setEmpty();
+ info.fOffset.setZero();
+ SkTileGridFactory factory(info);
+
+ const SkScalar w = fSrc->cullRect().width(),
+ h = fSrc->cullRect().height();
+
+ for (int i = 0; i < loops; i++) {
+ SkPictureRecorder recorder;
+ fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL));
+ SkDELETE(recorder.endRecording());
+ }
+}