scroggo@google.com | dd39488 | 2012-07-24 20:47:55 +0000 | [diff] [blame] | 1 | |
| 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 | |
| 13 | class WriterBench : public SkBenchmark { |
| 14 | public: |
robertphillips@google.com | 433ce5e | 2012-09-17 10:49:30 +0000 | [diff] [blame] | 15 | WriterBench(void* param) : INHERITED(param) { |
| 16 | fIsRendering = false; |
| 17 | } |
scroggo@google.com | dd39488 | 2012-07-24 20:47:55 +0000 | [diff] [blame] | 18 | |
| 19 | protected: |
| 20 | virtual const char* onGetName() SK_OVERRIDE { |
| 21 | return "writer"; |
| 22 | } |
| 23 | |
sugoi@google.com | 77472f0 | 2013-03-05 18:50:01 +0000 | [diff] [blame] | 24 | virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
scroggo@google.com | dd39488 | 2012-07-24 20:47:55 +0000 | [diff] [blame] | 25 | static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; |
| 26 | static const size_t gLen = strlen(gStr); |
| 27 | SkWriter32 writer(256 * 4); |
| 28 | for (int i = 0; i < SkBENCHLOOP(800); i++) { |
| 29 | for (size_t j = 0; j <= gLen; j++) { |
| 30 | writer.writeString(gStr, j); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | private: |
| 36 | typedef SkBenchmark INHERITED; |
| 37 | }; |
| 38 | |
| 39 | //////////////////////////////////////////////////////////////////////////////// |
| 40 | |
| 41 | static SkBenchmark* fact(void* p) { return new WriterBench(p); } |
| 42 | static BenchRegistry gReg(fact); |