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

Side by Side Diff: bench/ScalarBench.cpp

Issue 347823004: Remove Sk prefix from some bench classes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkGMBench -> GMBench Created 6 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
« no previous file with comments | « bench/ResultsWriter.h ('k') | bench/ShaderMaskBench.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 "Benchmark.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 Benchmark {
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 } 19 }
20 20
21 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 21 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
22 return backend == kNonRendering_Backend; 22 return backend == kNonRendering_Backend;
23 } 23 }
24 24
25 virtual void performTest() = 0; 25 virtual void performTest() = 0;
26 26
27 protected: 27 protected:
28 virtual int mulLoopCount() const { return 1; } 28 virtual int mulLoopCount() const { return 1; }
29 29
30 virtual const char* onGetName() SK_OVERRIDE { 30 virtual const char* onGetName() SK_OVERRIDE {
31 return fName.c_str(); 31 return fName.c_str();
32 } 32 }
33 33
34 virtual void onDraw(const int loops, SkCanvas* canvas) { 34 virtual void onDraw(const int loops, SkCanvas* canvas) {
35 for (int i = 0; i < loops; i++) { 35 for (int i = 0; i < loops; i++) {
36 this->performTest(); 36 this->performTest();
37 } 37 }
38 } 38 }
39 39
40 private: 40 private:
41 typedef SkBenchmark INHERITED; 41 typedef Benchmark INHERITED;
42 }; 42 };
43 43
44 // having unknown values in our arrays can throw off the timing a lot, perhaps 44 // having unknown values in our arrays can throw off the timing a lot, perhaps
45 // handling NaN values is a lot slower. Anyway, this guy is just meant to put 45 // handling NaN values is a lot slower. Anyway, this guy is just meant to put
46 // reasonable values in our arrays. 46 // reasonable values in our arrays.
47 template <typename T> void init9(T array[9]) { 47 template <typename T> void init9(T array[9]) {
48 SkRandom rand; 48 SkRandom rand;
49 for (int i = 0; i < 9; i++) { 49 for (int i = 0; i < 9; i++) {
50 array[i] = rand.nextSScalar1(); 50 array[i] = rand.nextSScalar1();
51 } 51 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 enum { 118 enum {
119 ARRAY_N = 64 119 ARRAY_N = 64
120 }; 120 };
121 SkScalar fArray[ARRAY_N]; 121 SkScalar fArray[ARRAY_N];
122 122
123 typedef ScalarBench INHERITED; 123 typedef ScalarBench INHERITED;
124 }; 124 };
125 125
126 /////////////////////////////////////////////////////////////////////////////// 126 ///////////////////////////////////////////////////////////////////////////////
127 127
128 class RectBoundsBench : public SkBenchmark { 128 class RectBoundsBench : public Benchmark {
129 enum { 129 enum {
130 PTS = 100, 130 PTS = 100,
131 }; 131 };
132 SkPoint fPts[PTS]; 132 SkPoint fPts[PTS];
133 133
134 public: 134 public:
135 RectBoundsBench() { 135 RectBoundsBench() {
136 SkRandom rand; 136 SkRandom rand;
137 for (int i = 0; i < PTS; ++i) { 137 for (int i = 0; i < PTS; ++i) {
138 fPts[i].fX = rand.nextSScalar1(); 138 fPts[i].fX = rand.nextSScalar1();
(...skipping 11 matching lines...) Expand all
150 } 150 }
151 151
152 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 152 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
153 SkRect r; 153 SkRect r;
154 for (int i = 0; i < loops; ++i) { 154 for (int i = 0; i < loops; ++i) {
155 r.set(fPts, PTS); 155 r.set(fPts, PTS);
156 } 156 }
157 } 157 }
158 158
159 private: 159 private:
160 typedef SkBenchmark INHERITED; 160 typedef Benchmark INHERITED;
161 }; 161 };
162 162
163 /////////////////////////////////////////////////////////////////////////////// 163 ///////////////////////////////////////////////////////////////////////////////
164 164
165 DEF_BENCH( return new FloatComparisonBench(); ) 165 DEF_BENCH( return new FloatComparisonBench(); )
166 DEF_BENCH( return new ForcedIntComparisonBench(); ) 166 DEF_BENCH( return new ForcedIntComparisonBench(); )
167 DEF_BENCH( return new RectBoundsBench(); ) 167 DEF_BENCH( return new RectBoundsBench(); )
168 DEF_BENCH( return new IsFiniteScalarBench(); ) 168 DEF_BENCH( return new IsFiniteScalarBench(); )
OLDNEW
« no previous file with comments | « bench/ResultsWriter.h ('k') | bench/ShaderMaskBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698