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