| 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 "Benchmark.h" | 8 #include "Benchmark.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(const int loops, SkCanvas* canvas) { | 34 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
| 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 Benchmark 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 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 class IsFiniteScalarBench : public ScalarBench { | 95 class IsFiniteScalarBench : public ScalarBench { |
| 96 public: | 96 public: |
| 97 IsFiniteScalarBench() : INHERITED("isfinite") { | 97 IsFiniteScalarBench() : INHERITED("isfinite") { |
| 98 SkRandom rand; | 98 SkRandom rand; |
| 99 for (size_t i = 0; i < ARRAY_N; ++i) { | 99 for (size_t i = 0; i < ARRAY_N; ++i) { |
| 100 fArray[i] = rand.nextSScalar1(); | 100 fArray[i] = rand.nextSScalar1(); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 protected: | 103 protected: |
| 104 virtual int mulLoopCount() const { return 1; } | 104 virtual int mulLoopCount() const SK_OVERRIDE { return 1; } |
| 105 virtual void performTest() SK_OVERRIDE { | 105 virtual void performTest() SK_OVERRIDE { |
| 106 int sum = 0; | 106 int sum = 0; |
| 107 for (size_t i = 0; i < ARRAY_N; ++i) { | 107 for (size_t i = 0; i < ARRAY_N; ++i) { |
| 108 // We pass -fArray[i], so the compiler can't cheat and treat the | 108 // We pass -fArray[i], so the compiler can't cheat and treat the |
| 109 // value as an int (even though we tell it that it is a float) | 109 // value as an int (even though we tell it that it is a float) |
| 110 sum += SkScalarIsFinite(-fArray[i]); | 110 sum += SkScalarIsFinite(-fArray[i]); |
| 111 } | 111 } |
| 112 // we do this so the compiler won't optimize our loop away... | 112 // we do this so the compiler won't optimize our loop away... |
| 113 this->doSomething(fArray, sum); | 113 this->doSomething(fArray, sum); |
| 114 } | 114 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 private: | 159 private: |
| 160 typedef Benchmark 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(); ) |
| OLD | NEW |