OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkChecksum.h" | 10 #include "SkChecksum.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class FontCacheBench : public Benchmark { | 26 class FontCacheBench : public Benchmark { |
27 public: | 27 public: |
28 FontCacheBench() {} | 28 FontCacheBench() {} |
29 | 29 |
30 protected: | 30 protected: |
31 const char* onGetName() override { | 31 const char* onGetName() override { |
32 return "fontcache"; | 32 return "fontcache"; |
33 } | 33 } |
34 | 34 |
35 void onDraw(const int loops, SkCanvas* canvas) override { | 35 void onDraw(int loops, SkCanvas* canvas) override { |
36 SkPaint paint; | 36 SkPaint paint; |
37 this->setupPaint(&paint); | 37 this->setupPaint(&paint); |
38 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 38 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
39 | 39 |
40 const uint16_t* array = gUniqueGlyphIDs; | 40 const uint16_t* array = gUniqueGlyphIDs; |
41 while (*array != gUniqueGlyphIDs_Sentinel) { | 41 while (*array != gUniqueGlyphIDs_Sentinel) { |
42 int count = count_glyphs(array); | 42 int count = count_glyphs(array); |
43 for (int i = 0; i < loops; ++i) { | 43 for (int i = 0; i < loops; ++i) { |
44 paint.measureText(array, count * sizeof(uint16_t)); | 44 paint.measureText(array, count * sizeof(uint16_t)); |
45 } | 45 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 FontCacheEfficiency() { | 101 FontCacheEfficiency() { |
102 if (false) dump_array(nullptr, 0); | 102 if (false) dump_array(nullptr, 0); |
103 if (false) rotr(0, 0); | 103 if (false) rotr(0, 0); |
104 } | 104 } |
105 | 105 |
106 protected: | 106 protected: |
107 const char* onGetName() override { | 107 const char* onGetName() override { |
108 return "fontefficiency"; | 108 return "fontefficiency"; |
109 } | 109 } |
110 | 110 |
111 void onDraw(const int loops, SkCanvas* canvas) override { | 111 void onDraw(int loops, SkCanvas* canvas) override { |
112 static bool gDone; | 112 static bool gDone; |
113 if (gDone) { | 113 if (gDone) { |
114 return; | 114 return; |
115 } | 115 } |
116 gDone = true; | 116 gDone = true; |
117 | 117 |
118 for (int hashBits = 6; hashBits <= 12; hashBits += 1) { | 118 for (int hashBits = 6; hashBits <= 12; hashBits += 1) { |
119 int hashMask = ((1 << hashBits) - 1); | 119 int hashMask = ((1 << hashBits) - 1); |
120 for (int limit = 32; limit <= 1024; limit <<= 1) { | 120 for (int limit = 32; limit <= 1024; limit <<= 1) { |
121 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 121 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
(...skipping 16 matching lines...) Expand all Loading... |
138 private: | 138 private: |
139 typedef Benchmark INHERITED; | 139 typedef Benchmark INHERITED; |
140 }; | 140 }; |
141 | 141 |
142 /////////////////////////////////////////////////////////////////////////////// | 142 /////////////////////////////////////////////////////////////////////////////// |
143 | 143 |
144 DEF_BENCH( return new FontCacheBench(); ) | 144 DEF_BENCH( return new FontCacheBench(); ) |
145 | 145 |
146 // undefine this to run the efficiency test | 146 // undefine this to run the efficiency test |
147 //DEF_BENCH( return new FontCacheEfficiency(); ) | 147 //DEF_BENCH( return new FontCacheEfficiency(); ) |
OLD | NEW |