blob: 40cc1a85128c3f068ac3d300a63f5d443a7b919c [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "bench/Benchmark.h"
9#include "include/core/SkCanvas.h"
10#include "src/core/SkWriter32.h"
scroggo@google.comdd394882012-07-24 20:47:55 +000011
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(); )