| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 The Android Open Source Project | 3 * Copyright 2012 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkBenchmark.h" | 9 #include "SkBenchmark.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkWriter32.h" | 11 #include "SkWriter32.h" |
| 12 | 12 |
| 13 class WriterBench : public SkBenchmark { | 13 class WriterBench : public SkBenchmark { |
| 14 public: | 14 public: |
| 15 WriterBench() { fIsRendering = false; } | 15 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 16 return backend == kNonRendering_Backend; |
| 17 } |
| 16 | 18 |
| 17 protected: | 19 protected: |
| 18 virtual const char* onGetName() SK_OVERRIDE { | 20 virtual const char* onGetName() SK_OVERRIDE { |
| 19 return "writer"; | 21 return "writer"; |
| 20 } | 22 } |
| 21 | 23 |
| 22 virtual void onDraw(SkCanvas*) SK_OVERRIDE { | 24 virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 23 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; | 25 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; |
| 24 static const size_t gLen = strlen(gStr); | 26 static const size_t gLen = strlen(gStr); |
| 25 SkWriter32 writer(256 * 4); | 27 SkWriter32 writer(256 * 4); |
| 26 for (int i = 0; i < this->getLoops(); i++) { | 28 for (int i = 0; i < this->getLoops(); i++) { |
| 27 for (size_t j = 0; j <= gLen; j++) { | 29 for (size_t j = 0; j <= gLen; j++) { |
| 28 writer.writeString(gStr, j); | 30 writer.writeString(gStr, j); |
| 29 } | 31 } |
| 30 } | 32 } |
| 31 } | 33 } |
| 32 | 34 |
| 33 private: | 35 private: |
| 34 typedef SkBenchmark INHERITED; | 36 typedef SkBenchmark INHERITED; |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 //////////////////////////////////////////////////////////////////////////////// | 39 //////////////////////////////////////////////////////////////////////////////// |
| 38 | 40 |
| 39 DEF_BENCH( return new WriterBench(); ) | 41 DEF_BENCH( return new WriterBench(); ) |
| OLD | NEW |