blob: 78c5d8b485ee78402ec4f8c9149e3039f979f3ca [file] [log] [blame]
scroggo@google.comdd394882012-07-24 20:47:55 +00001/*
2 * Copyright 2012 The Android Open Source Project
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
tfarinaf168b862014-06-19 12:32:29 -07008#include "Benchmark.h"
scroggo@google.comdd394882012-07-24 20:47:55 +00009#include "SkCanvas.h"
10#include "SkWriter32.h"
11
tfarinaf168b862014-06-19 12:32:29 -070012class WriterBench : public Benchmark {
scroggo@google.comdd394882012-07-24 20:47:55 +000013public:
mtklein36352bf2015-03-25 18:17:31 -070014 bool isSuitableFor(Backend backend) override {
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000015 return backend == kNonRendering_Backend;
16 }
scroggo@google.comdd394882012-07-24 20:47:55 +000017
18protected:
mtklein36352bf2015-03-25 18:17:31 -070019 const char* onGetName() override {
scroggo@google.comdd394882012-07-24 20:47:55 +000020 return "writer";
21 }
22
mtkleina1ebeb22015-10-01 09:43:39 -070023 void onDraw(int loops, SkCanvas*) override {
scroggo@google.comdd394882012-07-24 20:47:55 +000024 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
25 static const size_t gLen = strlen(gStr);
commit-bot@chromium.org19382422014-01-14 20:51:26 +000026 SkWriter32 writer;
commit-bot@chromium.org33614712013-12-03 18:17:16 +000027 for (int i = 0; i < loops; i++) {
scroggo@google.comdd394882012-07-24 20:47:55 +000028 for (size_t j = 0; j <= gLen; j++) {
29 writer.writeString(gStr, j);
30 }
31 }
32 }
33
34private:
tfarinaf168b862014-06-19 12:32:29 -070035 typedef Benchmark INHERITED;
scroggo@google.comdd394882012-07-24 20:47:55 +000036};
37
38////////////////////////////////////////////////////////////////////////////////
39
mtklein@google.com410e6e82013-09-13 19:52:27 +000040DEF_BENCH( return new WriterBench(); )