Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: bench/FontCacheBench.cpp

Issue 15682016: move measureText to be the only thing in the inner loop (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 #include "SkTemplates.h" 13 #include "SkTemplates.h"
14 14
15 #include "gUniqueGlyphIDs.h" 15 #include "gUniqueGlyphIDs.h"
16 16
17 class FontCacheBench : public SkBenchmark { 17 class FontCacheBench : public SkBenchmark {
18 enum { N = SkBENCHLOOP(40) }; 18 enum { N = SkBENCHLOOP(50) };
19 public: 19 public:
20 FontCacheBench(void* param) : INHERITED(param) { 20 FontCacheBench(void* param) : INHERITED(param) {
21 } 21 }
22 22
23 protected: 23 protected:
24 virtual const char* onGetName() SK_OVERRIDE { 24 virtual const char* onGetName() SK_OVERRIDE {
25 return "fontcache"; 25 return "fontcache";
26 } 26 }
27 27
28 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 28 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
29 SkPaint paint; 29 SkPaint paint;
30 this->setupPaint(&paint); 30 this->setupPaint(&paint);
31 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 31 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
32 32
33 for (int i = 0; i < N; ++i) { 33 const uint16_t* array = gUniqueGlyphIDs;
34 const uint16_t* array = gUniqueGlyphIDs; 34 while (*array != 0xFFFF) {
35 while (*array != 0xFFFF) { 35 const uint16_t* end = array + 1;
36 const uint16_t* end = array + 1; 36 while (*end != 0xFFFF) {
37 while (*end != 0xFFFF) { 37 end += 1;
38 end += 1; 38 }
39 } 39 for (int i = 0; i < N; ++i) {
40 paint.measureText(array, end - array); 40 paint.measureText(array, end - array);
41 array = end + 1; // skip the sentinel
42 } 41 }
42 array = end + 1; // skip the sentinel
43 } 43 }
44 } 44 }
45 45
46 private: 46 private:
47 typedef SkBenchmark INHERITED; 47 typedef SkBenchmark INHERITED;
48 }; 48 };
49 49
50 /////////////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////////////
51 51
52 DEF_BENCH( return new FontCacheBench(p); ) 52 DEF_BENCH( return new FontCacheBench(p); )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698