skia2/bench/RecordingBench.cpp
mtklein fd731ce804 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
2014-09-10 12:19:30 -07:00

49 lines
1.3 KiB
C++

/*
* 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());
}
}