| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 for (int i = 0; i < count; ++i) { | 119 for (int i = 0; i < count; ++i) { |
| 120 dst[i] = 1.0f / sk_float_sqrt(src[i]); | 120 dst[i] = 1.0f / sk_float_sqrt(src[i]); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 private: | 123 private: |
| 124 typedef MathBench INHERITED; | 124 typedef MathBench INHERITED; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 static inline float SkFastInvSqrt(float x) { | 127 static inline float SkFastInvSqrt(float x) { |
| 128 float xhalf = 0.5f*x; | 128 float xhalf = 0.5f*x; |
| 129 int i = *SkTCast<int*>(&x); | 129 uint32_t i = *SkTCast<uint32_t*>(&x); |
| 130 i = 0x5f3759df - (i>>1); | 130 i = 0x5f3759df - (i>>1); |
| 131 x = *SkTCast<float*>(&i); | 131 x = *SkTCast<float*>(&i); |
| 132 x = x*(1.5f-xhalf*x*x); | 132 x = x*(1.5f-xhalf*x*x); |
| 133 // x = x*(1.5f-xhalf*x*x); // this line takes err from 10^-3 to 10^-6 | 133 // x = x*(1.5f-xhalf*x*x); // this line takes err from 10^-3 to 10^-6 |
| 134 return x; | 134 return x; |
| 135 } | 135 } |
| 136 | 136 |
| 137 class FastISqrtMathBench : public MathBench { | 137 class FastISqrtMathBench : public MathBench { |
| 138 public: | 138 public: |
| 139 FastISqrtMathBench() : INHERITED("fastIsqrt") {} | 139 FastISqrtMathBench() : INHERITED("fastIsqrt") {} |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 599 |
| 600 DEF_BENCH( return new FloorBench(false); ) | 600 DEF_BENCH( return new FloorBench(false); ) |
| 601 DEF_BENCH( return new FloorBench(true); ) | 601 DEF_BENCH( return new FloorBench(true); ) |
| 602 | 602 |
| 603 DEF_BENCH( return new CLZBench(false); ) | 603 DEF_BENCH( return new CLZBench(false); ) |
| 604 DEF_BENCH( return new CLZBench(true); ) | 604 DEF_BENCH( return new CLZBench(true); ) |
| 605 | 605 |
| 606 DEF_BENCH( return new NormalizeBench(); ) | 606 DEF_BENCH( return new NormalizeBench(); ) |
| 607 | 607 |
| 608 DEF_BENCH( return new FixedMathBench(); ) | 608 DEF_BENCH( return new FixedMathBench(); ) |
| OLD | NEW |