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