Flutter Engine
The Flutter Engine
WriterBench.cpp
Go to the documentation of this file.
1/*
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
8#include "bench/Benchmark.h"
10#include "src/core/SkWriter32.h"
11
12class WriterBench : public Benchmark {
13public:
14 bool isSuitableFor(Backend backend) override {
16 }
17
18protected:
19 const char* onGetName() override {
20 return "writer";
21 }
22
23 void onDraw(int loops, SkCanvas*) override {
24 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
25 static const size_t gLen = strlen(gStr);
26 SkWriter32 writer;
27 for (int i = 0; i < loops; i++) {
28 for (size_t j = 0; j <= gLen; j++) {
29 writer.writeString(gStr, j);
30 }
31 }
32 }
33
34private:
35 using INHERITED = Benchmark;
36};
37
38////////////////////////////////////////////////////////////////////////////////
39
40DEF_BENCH( return new WriterBench(); )
#define DEF_BENCH(code)
Definition: Benchmark.h:20
const char * backend
void writeString(const char *str, size_t len=(size_t) -1)
Definition: SkWriter32.cpp:38
const char * onGetName() override
Definition: WriterBench.cpp:19
bool isSuitableFor(Backend backend) override
Definition: WriterBench.cpp:14
void onDraw(int loops, SkCanvas *) override
Definition: WriterBench.cpp:23