| OLD | NEW |
| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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(SkCanvas* canvas) { | 34 virtual void onDraw(const int loops, SkCanvas* canvas) { |
| 35 for (int i = 0; i < this->getLoops(); 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 SkBenchmark INHERITED; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // we want to stop the compiler from eliminating code that it thinks is a no-op | 44 // we want to stop the compiler from eliminating code that it thinks is a no-op |
| 45 // so we have a non-static global we increment, hoping that will convince the | 45 // so we have a non-static global we increment, hoping that will convince the |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 151 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
| 152 return backend == kNonRendering_Backend; | 152 return backend == kNonRendering_Backend; |
| 153 } | 153 } |
| 154 | 154 |
| 155 protected: | 155 protected: |
| 156 virtual const char* onGetName() SK_OVERRIDE { | 156 virtual const char* onGetName() SK_OVERRIDE { |
| 157 return "rect_bounds"; | 157 return "rect_bounds"; |
| 158 } | 158 } |
| 159 | 159 |
| 160 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 160 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
| 161 SkRect r; | 161 SkRect r; |
| 162 for (int i = 0; i < this->getLoops(); ++i) { | 162 for (int i = 0; i < loops; ++i) { |
| 163 r.set(fPts, PTS); | 163 r.set(fPts, PTS); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 typedef SkBenchmark INHERITED; | 168 typedef SkBenchmark INHERITED; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 /////////////////////////////////////////////////////////////////////////////// | 171 /////////////////////////////////////////////////////////////////////////////// |
| 172 | 172 |
| 173 DEF_BENCH( return new FloatComparisonBench(); ) | 173 DEF_BENCH( return new FloatComparisonBench(); ) |
| 174 DEF_BENCH( return new ForcedIntComparisonBench(); ) | 174 DEF_BENCH( return new ForcedIntComparisonBench(); ) |
| 175 DEF_BENCH( return new RectBoundsBench(); ) | 175 DEF_BENCH( return new RectBoundsBench(); ) |
| 176 DEF_BENCH( return new IsFiniteScalarBench(); ) | 176 DEF_BENCH( return new IsFiniteScalarBench(); ) |
| OLD | NEW |