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

Side by Side Diff: bench/PathIterBench.cpp

Issue 23478013: Major bench refactoring. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: merge with head agani Created 7 years, 3 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 | « bench/PathBench.cpp ('k') | bench/PathUtilsBench.cpp » ('j') | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 12 matching lines...) Expand all
23 pts[i].fY = rand.nextSScalar1(); 23 pts[i].fY = rand.nextSScalar1();
24 } 24 }
25 return n; 25 return n;
26 } 26 }
27 27
28 class PathIterBench : public SkBenchmark { 28 class PathIterBench : public SkBenchmark {
29 SkString fName; 29 SkString fName;
30 SkPath fPath; 30 SkPath fPath;
31 bool fRaw; 31 bool fRaw;
32 32
33 enum { N = SkBENCHLOOP(500) };
34
35 public: 33 public:
36 PathIterBench(void* param, bool raw) : INHERITED(param) { 34 PathIterBench(void* param, bool raw) : INHERITED(param) {
37 fName.printf("pathiter_%s", raw ? "raw" : "consume"); 35 fName.printf("pathiter_%s", raw ? "raw" : "consume");
38 fRaw = raw; 36 fRaw = raw;
39 37
40 SkRandom rand; 38 SkRandom rand;
41 for (int i = 0; i < 1000; ++i) { 39 for (int i = 0; i < 1000; ++i) {
42 SkPoint pts[4]; 40 SkPoint pts[4];
43 int n = rand_pts(rand, pts); 41 int n = rand_pts(rand, pts);
44 switch (n) { 42 switch (n) {
(...skipping 15 matching lines...) Expand all
60 fIsRendering = false; 58 fIsRendering = false;
61 } 59 }
62 60
63 protected: 61 protected:
64 virtual const char* onGetName() SK_OVERRIDE { 62 virtual const char* onGetName() SK_OVERRIDE {
65 return fName.c_str(); 63 return fName.c_str();
66 } 64 }
67 65
68 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 66 virtual void onDraw(SkCanvas*) SK_OVERRIDE {
69 if (fRaw) { 67 if (fRaw) {
70 for (int i = 0; i < N; ++i) { 68 for (int i = 0; i < this->getLoops(); ++i) {
71 SkPath::RawIter iter(fPath); 69 SkPath::RawIter iter(fPath);
72 SkPath::Verb verb; 70 SkPath::Verb verb;
73 SkPoint pts[4]; 71 SkPoint pts[4];
74 72
75 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { } 73 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { }
76 } 74 }
77 } else { 75 } else {
78 for (int i = 0; i < N; ++i) { 76 for (int i = 0; i < this->getLoops(); ++i) {
79 SkPath::Iter iter(fPath, false); 77 SkPath::Iter iter(fPath, false);
80 SkPath::Verb verb; 78 SkPath::Verb verb;
81 SkPoint pts[4]; 79 SkPoint pts[4];
82 80
83 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { } 81 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { }
84 } 82 }
85 } 83 }
86 } 84 }
87 85
88 private: 86 private:
89 typedef SkBenchmark INHERITED; 87 typedef SkBenchmark INHERITED;
90 }; 88 };
91 89
92 /////////////////////////////////////////////////////////////////////////////// 90 ///////////////////////////////////////////////////////////////////////////////
93 91
94 static SkBenchmark* F0(void* p) { return new PathIterBench(p, false); } 92 static SkBenchmark* F0(void* p) { return new PathIterBench(p, false); }
95 static SkBenchmark* F1(void* p) { return new PathIterBench(p, true); } 93 static SkBenchmark* F1(void* p) { return new PathIterBench(p, true); }
96 94
97 static BenchRegistry gR0(F0); 95 static BenchRegistry gR0(F0);
98 static BenchRegistry gR1(F1); 96 static BenchRegistry gR1(F1);
OLDNEW
« no previous file with comments | « bench/PathBench.cpp ('k') | bench/PathUtilsBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698