blob: 115ffc1d420c0382ef7cf66c21243f8030c7e4ce [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
tfarinaf168b862014-06-19 12:32:29 -07009#include "Benchmark.h"
scroggo@google.comdd394882012-07-24 20:47:55 +000010#include "SkCanvas.h"
11#include "SkWriter32.h"
12
tfarinaf168b862014-06-19 12:32:29 -070013class WriterBench : public Benchmark {
scroggo@google.comdd394882012-07-24 20:47:55 +000014public:
mtklein36352bf2015-03-25 18:17:31 -070015 bool isSuitableFor(Backend backend) override {
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000016 return backend == kNonRendering_Backend;
17 }
scroggo@google.comdd394882012-07-24 20:47:55 +000018
19protected:
mtklein36352bf2015-03-25 18:17:31 -070020 const char* onGetName() override {
scroggo@google.comdd394882012-07-24 20:47:55 +000021 return "writer";
22 }
23
mtkleina1ebeb22015-10-01 09:43:39 -070024 void onDraw(int loops, SkCanvas*) override {
scroggo@google.comdd394882012-07-24 20:47:55 +000025 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
26 static const size_t gLen = strlen(gStr);
commit-bot@chromium.org19382422014-01-14 20:51:26 +000027 SkWriter32 writer;
commit-bot@chromium.org33614712013-12-03 18:17:16 +000028 for (int i = 0; i < loops; 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:
tfarinaf168b862014-06-19 12:32:29 -070036 typedef Benchmark INHERITED;
scroggo@google.comdd394882012-07-24 20:47:55 +000037};
38
39////////////////////////////////////////////////////////////////////////////////
40
mtklein@google.com410e6e82013-09-13 19:52:27 +000041DEF_BENCH( return new WriterBench(); )