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

Side by Side Diff: bench/ScalarBench.cpp

Issue 73643005: Implement a benchmark for GrResourceCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address comments Created 7 years, 1 month 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/RegionContainBench.cpp ('k') | bench/SkBenchmark.h » ('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 "SkFloatBits.h" 9 #include "SkFloatBits.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
11 #include "SkRect.h" 11 #include "SkRect.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 13
14 class ScalarBench : public SkBenchmark { 14 class ScalarBench : public SkBenchmark {
15 SkString fName; 15 SkString fName;
16 public: 16 public:
17 ScalarBench(const char name[]) { 17 ScalarBench(const char name[]) {
18 fName.printf("scalar_%s", name); 18 fName.printf("scalar_%s", name);
19 fIsRendering = false; 19 }
20
21 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
22 return backend == kNonRendering_Backend;
20 } 23 }
21 24
22 virtual void performTest() = 0; 25 virtual void performTest() = 0;
23 26
24 protected: 27 protected:
25 virtual int mulLoopCount() const { return 1; } 28 virtual int mulLoopCount() const { return 1; }
26 29
27 virtual const char* onGetName() SK_OVERRIDE { 30 virtual const char* onGetName() SK_OVERRIDE {
28 return fName.c_str(); 31 return fName.c_str();
29 } 32 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 }; 139 };
137 SkPoint fPts[PTS]; 140 SkPoint fPts[PTS];
138 141
139 public: 142 public:
140 RectBoundsBench() { 143 RectBoundsBench() {
141 SkRandom rand; 144 SkRandom rand;
142 for (int i = 0; i < PTS; ++i) { 145 for (int i = 0; i < PTS; ++i) {
143 fPts[i].fX = rand.nextSScalar1(); 146 fPts[i].fX = rand.nextSScalar1();
144 fPts[i].fY = rand.nextSScalar1(); 147 fPts[i].fY = rand.nextSScalar1();
145 } 148 }
146 fIsRendering = false; 149 }
150
151 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
152 return backend == kNonRendering_Backend;
147 } 153 }
148 154
149 protected: 155 protected:
150 virtual const char* onGetName() SK_OVERRIDE { 156 virtual const char* onGetName() SK_OVERRIDE {
151 return "rect_bounds"; 157 return "rect_bounds";
152 } 158 }
153 159
154 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 160 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
155 SkRect r; 161 SkRect r;
156 for (int i = 0; i < this->getLoops(); ++i) { 162 for (int i = 0; i < this->getLoops(); ++i) {
157 r.set(fPts, PTS); 163 r.set(fPts, PTS);
158 } 164 }
159 } 165 }
160 166
161 private: 167 private:
162 typedef SkBenchmark INHERITED; 168 typedef SkBenchmark INHERITED;
163 }; 169 };
164 170
165 /////////////////////////////////////////////////////////////////////////////// 171 ///////////////////////////////////////////////////////////////////////////////
166 172
167 DEF_BENCH( return new FloatComparisonBench(); ) 173 DEF_BENCH( return new FloatComparisonBench(); )
168 DEF_BENCH( return new ForcedIntComparisonBench(); ) 174 DEF_BENCH( return new ForcedIntComparisonBench(); )
169 DEF_BENCH( return new RectBoundsBench(); ) 175 DEF_BENCH( return new RectBoundsBench(); )
170 DEF_BENCH( return new IsFiniteScalarBench(); ) 176 DEF_BENCH( return new IsFiniteScalarBench(); )
OLDNEW
« no previous file with comments | « bench/RegionContainBench.cpp ('k') | bench/SkBenchmark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698