blob: f9a0ac89b48c92cd525d40cdaaee7cc48def2d25 [file] [log] [blame]
scroggo@google.comdd394882012-07-24 20:47:55 +00001
2/*
3 * Copyright 2012 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#include "SkBenchmark.h"
10#include "SkCanvas.h"
11#include "SkWriter32.h"
12
13class WriterBench : public SkBenchmark {
14public:
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000015 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
16 return backend == kNonRendering_Backend;
17 }
scroggo@google.comdd394882012-07-24 20:47:55 +000018
19protected:
20 virtual const char* onGetName() SK_OVERRIDE {
21 return "writer";
22 }
23
sugoi@google.com77472f02013-03-05 18:50:01 +000024 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
scroggo@google.comdd394882012-07-24 20:47:55 +000025 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
26 static const size_t gLen = strlen(gStr);
27 SkWriter32 writer(256 * 4);
mtklein@google.comc2897432013-09-10 19:23:38 +000028 for (int i = 0; i < this->getLoops(); i++) {
scroggo@google.comdd394882012-07-24 20:47:55 +000029 for (size_t j = 0; j <= gLen; j++) {
30 writer.writeString(gStr, j);
31 }
32 }
33 }
34
35private:
36 typedef SkBenchmark INHERITED;
37};
38
39////////////////////////////////////////////////////////////////////////////////
40
mtklein@google.com410e6e82013-09-13 19:52:27 +000041DEF_BENCH( return new WriterBench(); )