#include "SkLiteRecorder.h"
#include "SkPictureRecorder.h"
-RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH, bool lite)
- : fName(name)
- , fUseBBH(useBBH) {
+PictureCentricBench::PictureCentricBench(const char* name, const SkPicture* pic) : fName(name) {
// Flatten the source picture in case it's trivially nested (useless for timing).
SkPictureRecorder rec;
pic->playback(rec.beginRecording(pic->cullRect(), nullptr,
SkPictureRecorder::kPlaybackDrawPicture_RecordFlag));
fSrc = rec.finishRecordingAsPicture();
-
- // If we're recording into an SkLiteDL, also record _from_ one.
- if (lite) {
- fDL = SkLiteDL::New(pic->cullRect());
- SkLiteRecorder r;
- r.reset(fDL.get());
- fSrc->playback(&r);
- }
}
-const char* RecordingBench::onGetName() {
+const char* PictureCentricBench::onGetName() {
return fName.c_str();
}
-bool RecordingBench::isSuitableFor(Backend backend) {
+bool PictureCentricBench::isSuitableFor(Backend backend) {
return backend == kNonRendering_Backend;
}
-SkIPoint RecordingBench::onGetSize() {
+SkIPoint PictureCentricBench::onGetSize() {
return SkIPoint::Make(SkScalarCeilToInt(fSrc->cullRect().width()),
SkScalarCeilToInt(fSrc->cullRect().height()));
}
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+RecordingBench::RecordingBench(const char* name, const SkPicture* pic, bool useBBH, bool lite)
+ : INHERITED(name, pic)
+ , fUseBBH(useBBH)
+{
+ // If we're recording into an SkLiteDL, also record _from_ one.
+ if (lite) {
+ fDL = SkLiteDL::New(fSrc->cullRect());
+ SkLiteRecorder r;
+ r.reset(fDL.get());
+ fSrc->playback(&r);
+ }
+}
+
void RecordingBench::onDraw(int loops, SkCanvas*) {
if (fDL) {
SkLiteRecorder rec;
}
}
}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include "SkPipe.h"
+#include "SkStream.h"
+
+PipingBench::PipingBench(const char* name, const SkPicture* pic) : INHERITED(name, pic) {
+ fName.prepend("pipe_");
+}
+
+void PipingBench::onDraw(int loops, SkCanvas*) {
+ SkDynamicMemoryWStream stream;
+ SkPipeSerializer serializer;
+
+ while (loops --> 0) {
+ fSrc->playback(serializer.beginWrite(fSrc->cullRect(), &stream));
+ serializer.endWrite();
+ stream.reset();
+ }
+}
#include "SkPicture.h"
#include "SkLiteDL.h"
-class RecordingBench : public Benchmark {
+class PictureCentricBench : public Benchmark {
public:
- RecordingBench(const char* name, const SkPicture*, bool useBBH, bool lite);
+ PictureCentricBench(const char* name, const SkPicture*);
protected:
const char* onGetName() override;
bool isSuitableFor(Backend) override;
- void onDraw(int loops, SkCanvas*) override;
SkIPoint onGetSize() override;
-private:
+protected:
sk_sp<const SkPicture> fSrc;
SkString fName;
+
+ typedef Benchmark INHERITED;
+};
+
+class RecordingBench : public PictureCentricBench {
+public:
+ RecordingBench(const char* name, const SkPicture*, bool useBBH, bool lite);
+
+protected:
+ void onDraw(int loops, SkCanvas*) override;
+
+private:
sk_sp<SkLiteDL> fDL;
bool fUseBBH;
- typedef Benchmark INHERITED;
+ typedef PictureCentricBench INHERITED;
+};
+
+class PipingBench : public PictureCentricBench {
+public:
+ PipingBench(const char* name, const SkPicture*);
+
+protected:
+ void onDraw(int loops, SkCanvas*) override;
+
+private:
+ typedef PictureCentricBench INHERITED;
};
#endif//RecordingBench_DEFINED
DEFINE_string(sourceType, "",
"Apply usual --match rules to source type: bench, gm, skp, image, etc.");
DEFINE_string(benchType, "",
- "Apply usual --match rules to bench type: micro, recording, playback, skcodec, etc.");
+ "Apply usual --match rules to bench type: micro, recording, piping, playback, skcodec, etc.");
static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
BenchmarkStream() : fBenches(BenchRegistry::Head())
, fGMs(skiagm::GMRegistry::Head())
, fCurrentRecording(0)
+ , fCurrentPiping(0)
, fCurrentScale(0)
, fCurrentSKP(0)
, fCurrentSVG(0)
return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh, FLAGS_lite);
}
+ // Add all .skps as PipeBenches.
+ while (fCurrentPiping < fSKPs.count()) {
+ const SkString& path = fSKPs[fCurrentPiping++];
+ sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+ if (!pic) {
+ continue;
+ }
+ SkString name = SkOSPath::Basename(path.c_str());
+ fSourceType = "skp";
+ fBenchType = "piping";
+ fSKPBytes = static_cast<double>(SkPictureUtils::ApproximateBytesUsed(pic.get()));
+ fSKPOps = pic->approximateOpCount();
+ return new PipingBench(name.c_str(), pic.get());
+ }
+
// Then once each for each scale as SKPBenches (playback).
while (fCurrentScale < fScales.count()) {
while (fCurrentSKP < fSKPs.count()) {
const char* fSourceType; // What we're benching: bench, GM, SKP, ...
const char* fBenchType; // How we bench it: micro, recording, playback, ...
int fCurrentRecording;
+ int fCurrentPiping;
int fCurrentScale;
int fCurrentSKP;
int fCurrentSVG;