blob: 2de653c374f07854c077756ca9cd43825bf5329d [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:
15 WriterBench(void* param) : INHERITED(param) {}
16
17protected:
18 virtual const char* onGetName() SK_OVERRIDE {
19 return "writer";
20 }
21
22 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
23 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz";
24 static const size_t gLen = strlen(gStr);
25 SkWriter32 writer(256 * 4);
26 for (int i = 0; i < SkBENCHLOOP(800); i++) {
27 for (size_t j = 0; j <= gLen; j++) {
28 writer.writeString(gStr, j);
29 }
30 }
31 }
32
33private:
34 typedef SkBenchmark INHERITED;
35};
36
37////////////////////////////////////////////////////////////////////////////////
38
39static SkBenchmark* fact(void* p) { return new WriterBench(p); }
40static BenchRegistry gReg(fact);