blob: 884b005ee7f5f09dd74a5066311ab295655d6e21 [file] [log] [blame]
mtklein649e0452015-04-03 13:25:13 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8// A benchmark designed to isolate the constant overheads of picture recording.
9// We record a very tiny (one op) picture; one op is better than none, as it forces
10// us to allocate memory to store that op... we can't just cheat by holding onto NULLs.
11
12#include "Benchmark.h"
13#include "SkCanvas.h"
14#include "SkPictureRecorder.h"
15
16struct PictureOverheadBench : public Benchmark {
17 const char* onGetName() override { return "picture_overhead"; }
18 bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
19
20 void onDraw(const int loops, SkCanvas*) override {
21 SkPictureRecorder rec;
22 for (int i = 0; i < loops; i++) {
23 SkCanvas* c = rec.beginRecording(SkRect::MakeWH(2000,3000));
24 c->drawRect(SkRect::MakeXYWH(10, 10, 1000, 1000), SkPaint());
25 SkAutoTUnref<SkPicture> pic(rec.endRecordingAsPicture());
26 }
27 }
28};
29DEF_BENCH(return new PictureOverheadBench;)