| 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 "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkFontHost.h" | 10 #include "SkFontHost.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class FontCacheBench : public SkBenchmark { | 26 class FontCacheBench : public SkBenchmark { |
| 27 public: | 27 public: |
| 28 FontCacheBench() {} | 28 FontCacheBench() {} |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 virtual const char* onGetName() SK_OVERRIDE { | 31 virtual const char* onGetName() SK_OVERRIDE { |
| 32 return "fontcache"; | 32 return "fontcache"; |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 35 virtual void onDraw(const int loops, SkCanvas* canvas) SK_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 < this->getLoops(); ++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 } |
| 46 array += count + 1; // skip the sentinel | 46 array += count + 1; // skip the sentinel |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 typedef SkBenchmark INHERITED; | 51 typedef SkBenchmark INHERITED; |
| 52 }; | 52 }; |
| 53 | 53 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 FontCacheEfficiency() { | 112 FontCacheEfficiency() { |
| 113 if (false) dump_array(NULL, 0); | 113 if (false) dump_array(NULL, 0); |
| 114 if (false) rotr(0, 0); | 114 if (false) rotr(0, 0); |
| 115 } | 115 } |
| 116 | 116 |
| 117 protected: | 117 protected: |
| 118 virtual const char* onGetName() SK_OVERRIDE { | 118 virtual const char* onGetName() SK_OVERRIDE { |
| 119 return "fontefficiency"; | 119 return "fontefficiency"; |
| 120 } | 120 } |
| 121 | 121 |
| 122 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 122 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
| 123 static bool gDone; | 123 static bool gDone; |
| 124 if (gDone) { | 124 if (gDone) { |
| 125 return; | 125 return; |
| 126 } | 126 } |
| 127 gDone = true; | 127 gDone = true; |
| 128 | 128 |
| 129 for (int hashBits = 6; hashBits <= 12; hashBits += 1) { | 129 for (int hashBits = 6; hashBits <= 12; hashBits += 1) { |
| 130 int hashMask = ((1 << hashBits) - 1); | 130 int hashMask = ((1 << hashBits) - 1); |
| 131 for (int limit = 32; limit <= 1024; limit <<= 1) { | 131 for (int limit = 32; limit <= 1024; limit <<= 1) { |
| 132 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 132 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 149 private: | 149 private: |
| 150 typedef SkBenchmark INHERITED; | 150 typedef SkBenchmark INHERITED; |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 /////////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////////// |
| 154 | 154 |
| 155 DEF_BENCH( return new FontCacheBench(); ) | 155 DEF_BENCH( return new FontCacheBench(); ) |
| 156 | 156 |
| 157 // undefine this to run the efficiency test | 157 // undefine this to run the efficiency test |
| 158 //DEF_BENCH( return new FontCacheEfficiency(); ) | 158 //DEF_BENCH( return new FontCacheEfficiency(); ) |
| OLD | NEW |