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 WriterBench() { } |
| 16 |
| 17 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 18 return backend == kNonRendering_Backend; |
| 19 } |
16 | 20 |
17 protected: | 21 protected: |
18 virtual const char* onGetName() SK_OVERRIDE { | 22 virtual const char* onGetName() SK_OVERRIDE { |
19 return "writer"; | 23 return "writer"; |
20 } | 24 } |
21 | 25 |
22 virtual void onDraw(SkCanvas*) SK_OVERRIDE { | 26 virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
23 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; | 27 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; |
24 static const size_t gLen = strlen(gStr); | 28 static const size_t gLen = strlen(gStr); |
25 SkWriter32 writer(256 * 4); | 29 SkWriter32 writer(256 * 4); |
26 for (int i = 0; i < this->getLoops(); i++) { | 30 for (int i = 0; i < this->getLoops(); i++) { |
27 for (size_t j = 0; j <= gLen; j++) { | 31 for (size_t j = 0; j <= gLen; j++) { |
28 writer.writeString(gStr, j); | 32 writer.writeString(gStr, j); |
29 } | 33 } |
30 } | 34 } |
31 } | 35 } |
32 | 36 |
33 private: | 37 private: |
34 typedef SkBenchmark INHERITED; | 38 typedef SkBenchmark INHERITED; |
35 }; | 39 }; |
36 | 40 |
37 //////////////////////////////////////////////////////////////////////////////// | 41 //////////////////////////////////////////////////////////////////////////////// |
38 | 42 |
39 DEF_BENCH( return new WriterBench(); ) | 43 DEF_BENCH( return new WriterBench(); ) |
OLD | NEW |