mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 8 | #include "Benchmark.h" |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 9 | #include "SkColorPriv.h" |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 10 | #include "SkMatrix.h" |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 11 | #include "SkPaint.h" |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 12 | #include "SkRandom.h" |
| 13 | #include "SkString.h" |
| 14 | |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 15 | static float sk_fsel(float pred, float result_ge, float result_lt) { |
| 16 | return pred >= 0 ? result_ge : result_lt; |
| 17 | } |
| 18 | |
| 19 | static float fast_floor(float x) { |
reed@google.com | f3a8d8e | 2012-05-30 14:08:57 +0000 | [diff] [blame] | 20 | // float big = sk_fsel(x, 0x1.0p+23, -0x1.0p+23); |
| 21 | float big = sk_fsel(x, (float)(1 << 23), -(float)(1 << 23)); |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 22 | return (x + big) - big; |
| 23 | } |
| 24 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 25 | class MathBench : public Benchmark { |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 26 | enum { |
| 27 | kBuffer = 100, |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 28 | }; |
| 29 | SkString fName; |
| 30 | float fSrc[kBuffer], fDst[kBuffer]; |
| 31 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 32 | MathBench(const char name[]) { |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 33 | fName.printf("math_%s", name); |
| 34 | |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 35 | SkRandom rand; |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 36 | for (int i = 0; i < kBuffer; ++i) { |
| 37 | fSrc[i] = rand.nextSScalar1(); |
| 38 | } |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 39 | } |
tomhudson@google.com | 9dc2713 | 2012-09-13 15:50:24 +0000 | [diff] [blame] | 40 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 41 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 42 | return backend == kNonRendering_Backend; |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 43 | } |
| 44 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 45 | virtual void performTest(float* SK_RESTRICT dst, |
| 46 | const float* SK_RESTRICT src, |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 47 | int count) = 0; |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 48 | |
| 49 | protected: |
| 50 | virtual int mulLoopCount() const { return 1; } |
| 51 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 52 | const char* onGetName() override { |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 53 | return fName.c_str(); |
| 54 | } |
| 55 | |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 56 | void onDraw(int loops, SkCanvas*) override { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 57 | int n = loops * this->mulLoopCount(); |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 58 | for (int i = 0; i < n; i++) { |
| 59 | this->performTest(fDst, fSrc, kBuffer); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | private: |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 64 | typedef Benchmark INHERITED; |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 67 | class MathBenchU32 : public MathBench { |
| 68 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 69 | MathBenchU32(const char name[]) : INHERITED(name) {} |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 70 | |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 71 | protected: |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 72 | virtual void performITest(uint32_t* SK_RESTRICT dst, |
| 73 | const uint32_t* SK_RESTRICT src, |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 74 | int count) = 0; |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 75 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 76 | void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, int count) override { |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 77 | uint32_t* d = SkTCast<uint32_t*>(dst); |
| 78 | const uint32_t* s = SkTCast<const uint32_t*>(src); |
| 79 | this->performITest(d, s, count); |
| 80 | } |
| 81 | private: |
| 82 | typedef MathBench INHERITED; |
| 83 | }; |
| 84 | |
| 85 | /////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 86 | |
| 87 | class NoOpMathBench : public MathBench { |
| 88 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 89 | NoOpMathBench() : INHERITED("noOp") {} |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 90 | protected: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 91 | void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, int count) override { |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 92 | for (int i = 0; i < count; ++i) { |
| 93 | dst[i] = src[i] + 1; |
| 94 | } |
| 95 | } |
| 96 | private: |
| 97 | typedef MathBench INHERITED; |
| 98 | }; |
| 99 | |
commit-bot@chromium.org | 11e5b97 | 2013-11-08 20:14:16 +0000 | [diff] [blame] | 100 | class SkRSqrtMathBench : public MathBench { |
| 101 | public: |
| 102 | SkRSqrtMathBench() : INHERITED("sk_float_rsqrt") {} |
| 103 | protected: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 104 | void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, int count) override { |
commit-bot@chromium.org | 11e5b97 | 2013-11-08 20:14:16 +0000 | [diff] [blame] | 105 | for (int i = 0; i < count; ++i) { |
| 106 | dst[i] = sk_float_rsqrt(src[i]); |
| 107 | } |
| 108 | } |
| 109 | private: |
| 110 | typedef MathBench INHERITED; |
| 111 | }; |
| 112 | |
| 113 | |
robertphillips@google.com | 36bb270 | 2013-08-12 12:02:28 +0000 | [diff] [blame] | 114 | class SlowISqrtMathBench : public MathBench { |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 115 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 116 | SlowISqrtMathBench() : INHERITED("slowIsqrt") {} |
commit-bot@chromium.org | b3ecdc4 | 2013-08-12 08:37:51 +0000 | [diff] [blame] | 117 | protected: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 118 | void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, int count) override { |
robertphillips@google.com | 36bb270 | 2013-08-12 12:02:28 +0000 | [diff] [blame] | 119 | for (int i = 0; i < count; ++i) { |
| 120 | dst[i] = 1.0f / sk_float_sqrt(src[i]); |
commit-bot@chromium.org | b3ecdc4 | 2013-08-12 08:37:51 +0000 | [diff] [blame] | 121 | } |
commit-bot@chromium.org | b3ecdc4 | 2013-08-12 08:37:51 +0000 | [diff] [blame] | 122 | } |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 123 | private: |
robertphillips@google.com | 36bb270 | 2013-08-12 12:02:28 +0000 | [diff] [blame] | 124 | typedef MathBench INHERITED; |
| 125 | }; |
| 126 | |
| 127 | static inline float SkFastInvSqrt(float x) { |
| 128 | float xhalf = 0.5f*x; |
| 129 | int i = *SkTCast<int*>(&x); |
| 130 | i = 0x5f3759df - (i>>1); |
| 131 | x = *SkTCast<float*>(&i); |
| 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 |
| 134 | return x; |
| 135 | } |
| 136 | |
| 137 | class FastISqrtMathBench : public MathBench { |
| 138 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 139 | FastISqrtMathBench() : INHERITED("fastIsqrt") {} |
robertphillips@google.com | 36bb270 | 2013-08-12 12:02:28 +0000 | [diff] [blame] | 140 | protected: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 141 | void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, int count) override { |
robertphillips@google.com | 36bb270 | 2013-08-12 12:02:28 +0000 | [diff] [blame] | 142 | for (int i = 0; i < count; ++i) { |
| 143 | dst[i] = SkFastInvSqrt(src[i]); |
| 144 | } |
| 145 | } |
| 146 | private: |
| 147 | typedef MathBench INHERITED; |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 150 | static inline uint32_t QMul64(uint32_t value, U8CPU alpha) { |
| 151 | SkASSERT((uint8_t)alpha == alpha); |
| 152 | const uint32_t mask = 0xFF00FF; |
| 153 | |
| 154 | uint64_t tmp = value; |
| 155 | tmp = (tmp & mask) | ((tmp & ~mask) << 24); |
| 156 | tmp *= alpha; |
caryclark@google.com | 19069a2 | 2012-06-06 12:11:45 +0000 | [diff] [blame] | 157 | return (uint32_t) (((tmp >> 8) & mask) | ((tmp >> 32) & ~mask)); |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | class QMul64Bench : public MathBenchU32 { |
| 161 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 162 | QMul64Bench() : INHERITED("qmul64") {} |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 163 | protected: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 164 | void performITest(uint32_t* SK_RESTRICT dst, |
| 165 | const uint32_t* SK_RESTRICT src, |
| 166 | int count) override { |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 167 | for (int i = 0; i < count; ++i) { |
| 168 | dst[i] = QMul64(src[i], (uint8_t)i); |
| 169 | } |
| 170 | } |
| 171 | private: |
| 172 | typedef MathBenchU32 INHERITED; |
| 173 | }; |
| 174 | |
| 175 | class QMul32Bench : public MathBenchU32 { |
| 176 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 177 | QMul32Bench() : INHERITED("qmul32") {} |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 178 | protected: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 179 | void performITest(uint32_t* SK_RESTRICT dst, |
| 180 | const uint32_t* SK_RESTRICT src, |
| 181 | int count) override { |
reed@google.com | e05cc8e | 2011-10-10 14:19:40 +0000 | [diff] [blame] | 182 | for (int i = 0; i < count; ++i) { |
| 183 | dst[i] = SkAlphaMulQ(src[i], (uint8_t)i); |
| 184 | } |
| 185 | } |
| 186 | private: |
| 187 | typedef MathBenchU32 INHERITED; |
| 188 | }; |
| 189 | |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 190 | /////////////////////////////////////////////////////////////////////////////// |
| 191 | |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 192 | static bool isFinite_int(float x) { |
| 193 | uint32_t bits = SkFloat2Bits(x); // need unsigned for our shifts |
| 194 | int exponent = bits << 1 >> 24; |
| 195 | return exponent != 0xFF; |
| 196 | } |
| 197 | |
| 198 | static bool isFinite_float(float x) { |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 199 | return SkToBool(sk_float_isfinite(x)); |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | static bool isFinite_mulzero(float x) { |
| 203 | float y = x * 0; |
| 204 | return y == y; |
| 205 | } |
| 206 | |
| 207 | static bool isfinite_and_int(const float data[4]) { |
| 208 | return isFinite_int(data[0]) && isFinite_int(data[1]) && isFinite_int(data[2]) && isFinite_int(data[3]); |
| 209 | } |
| 210 | |
| 211 | static bool isfinite_and_float(const float data[4]) { |
| 212 | return isFinite_float(data[0]) && isFinite_float(data[1]) && isFinite_float(data[2]) && isFinite_float(data[3]); |
| 213 | } |
| 214 | |
| 215 | static bool isfinite_and_mulzero(const float data[4]) { |
| 216 | return isFinite_mulzero(data[0]) && isFinite_mulzero(data[1]) && isFinite_mulzero(data[2]) && isFinite_mulzero(data[3]); |
| 217 | } |
| 218 | |
| 219 | #define mulzeroadd(data) (data[0]*0 + data[1]*0 + data[2]*0 + data[3]*0) |
| 220 | |
| 221 | static bool isfinite_plus_int(const float data[4]) { |
| 222 | return isFinite_int(mulzeroadd(data)); |
| 223 | } |
| 224 | |
| 225 | static bool isfinite_plus_float(const float data[4]) { |
reed@google.com | 5ae777d | 2011-12-06 20:18:05 +0000 | [diff] [blame] | 226 | return !sk_float_isnan(mulzeroadd(data)); |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | static bool isfinite_plus_mulzero(const float data[4]) { |
| 230 | float x = mulzeroadd(data); |
| 231 | return x == x; |
| 232 | } |
| 233 | |
| 234 | typedef bool (*IsFiniteProc)(const float[]); |
| 235 | |
| 236 | #define MAKEREC(name) { name, #name } |
| 237 | |
| 238 | static const struct { |
| 239 | IsFiniteProc fProc; |
| 240 | const char* fName; |
| 241 | } gRec[] = { |
| 242 | MAKEREC(isfinite_and_int), |
| 243 | MAKEREC(isfinite_and_float), |
| 244 | MAKEREC(isfinite_and_mulzero), |
| 245 | MAKEREC(isfinite_plus_int), |
| 246 | MAKEREC(isfinite_plus_float), |
| 247 | MAKEREC(isfinite_plus_mulzero), |
| 248 | }; |
| 249 | |
| 250 | #undef MAKEREC |
| 251 | |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 252 | static bool isFinite(const SkRect& r) { |
| 253 | // x * 0 will be NaN iff x is infinity or NaN. |
| 254 | // a + b will be NaN iff either a or b is NaN. |
| 255 | float value = r.fLeft * 0 + r.fTop * 0 + r.fRight * 0 + r.fBottom * 0; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 256 | |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 257 | // value is either NaN or it is finite (zero). |
| 258 | // value==value will be true iff value is not NaN |
| 259 | return value == value; |
| 260 | } |
| 261 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 262 | class IsFiniteBench : public Benchmark { |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 263 | enum { |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 264 | N = 1000, |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 265 | }; |
| 266 | float fData[N]; |
| 267 | public: |
| 268 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 269 | IsFiniteBench(int index) { |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 270 | SkRandom rand; |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 271 | |
| 272 | for (int i = 0; i < N; ++i) { |
| 273 | fData[i] = rand.nextSScalar1(); |
| 274 | } |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 275 | |
| 276 | if (index < 0) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 277 | fProc = nullptr; |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 278 | fName = "isfinite_rect"; |
| 279 | } else { |
| 280 | fProc = gRec[index].fProc; |
| 281 | fName = gRec[index].fName; |
| 282 | } |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 283 | } |
| 284 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 285 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 286 | return backend == kNonRendering_Backend; |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | protected: |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 290 | void onDraw(int loops, SkCanvas*) override { |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 291 | IsFiniteProc proc = fProc; |
| 292 | const float* data = fData; |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 293 | // do this so the compiler won't throw away the function call |
| 294 | int counter = 0; |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 295 | |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 296 | if (proc) { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 297 | for (int j = 0; j < loops; ++j) { |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 298 | for (int i = 0; i < N - 4; ++i) { |
| 299 | counter += proc(&data[i]); |
| 300 | } |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 301 | } |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 302 | } else { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 303 | for (int j = 0; j < loops; ++j) { |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 304 | for (int i = 0; i < N - 4; ++i) { |
| 305 | const SkRect* r = reinterpret_cast<const SkRect*>(&data[i]); |
caryclark@google.com | 19069a2 | 2012-06-06 12:11:45 +0000 | [diff] [blame] | 306 | if (false) { // avoid bit rot, suppress warning |
| 307 | isFinite(*r); |
| 308 | } |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 309 | counter += r->isFinite(); |
| 310 | } |
| 311 | } |
| 312 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 313 | |
reed@google.com | 1607863 | 2011-12-06 18:56:37 +0000 | [diff] [blame] | 314 | SkPaint paint; |
| 315 | if (paint.getAlpha() == 0) { |
| 316 | SkDebugf("%d\n", counter); |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 317 | } |
| 318 | } |
| 319 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 320 | const char* onGetName() override { |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 321 | return fName; |
| 322 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 323 | |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 324 | private: |
| 325 | IsFiniteProc fProc; |
| 326 | const char* fName; |
| 327 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 328 | typedef Benchmark INHERITED; |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 329 | }; |
| 330 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 331 | class FloorBench : public Benchmark { |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 332 | enum { |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 333 | ARRAY = 1000, |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 334 | }; |
| 335 | float fData[ARRAY]; |
| 336 | bool fFast; |
| 337 | public: |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 338 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 339 | FloorBench(bool fast) : fFast(fast) { |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 340 | SkRandom rand; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 341 | |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 342 | for (int i = 0; i < ARRAY; ++i) { |
| 343 | fData[i] = rand.nextSScalar1(); |
| 344 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 345 | |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 346 | if (fast) { |
| 347 | fName = "floor_fast"; |
| 348 | } else { |
| 349 | fName = "floor_std"; |
| 350 | } |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 351 | } |
| 352 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 353 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 354 | return backend == kNonRendering_Backend; |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 355 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 356 | |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 357 | virtual void process(float) {} |
| 358 | |
| 359 | protected: |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 360 | void onDraw(int loops, SkCanvas*) override { |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 361 | SkRandom rand; |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 362 | float accum = 0; |
| 363 | const float* data = fData; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 364 | |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 365 | if (fFast) { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 366 | for (int j = 0; j < loops; ++j) { |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 367 | for (int i = 0; i < ARRAY; ++i) { |
| 368 | accum += fast_floor(data[i]); |
| 369 | } |
| 370 | this->process(accum); |
| 371 | } |
| 372 | } else { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 373 | for (int j = 0; j < loops; ++j) { |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 374 | for (int i = 0; i < ARRAY; ++i) { |
| 375 | accum += sk_float_floor(data[i]); |
| 376 | } |
| 377 | this->process(accum); |
| 378 | } |
| 379 | } |
| 380 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 381 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 382 | const char* onGetName() override { |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 383 | return fName; |
| 384 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 385 | |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 386 | private: |
| 387 | const char* fName; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 388 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 389 | typedef Benchmark INHERITED; |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 390 | }; |
| 391 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 392 | class CLZBench : public Benchmark { |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 393 | enum { |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 394 | ARRAY = 1000, |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 395 | }; |
| 396 | uint32_t fData[ARRAY]; |
| 397 | bool fUsePortable; |
| 398 | |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 399 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 400 | CLZBench(bool usePortable) : fUsePortable(usePortable) { |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 401 | |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 402 | SkRandom rand; |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 403 | for (int i = 0; i < ARRAY; ++i) { |
| 404 | fData[i] = rand.nextU(); |
| 405 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 406 | |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 407 | if (fUsePortable) { |
| 408 | fName = "clz_portable"; |
| 409 | } else { |
| 410 | fName = "clz_intrinsic"; |
| 411 | } |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 412 | } |
| 413 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 414 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 415 | return backend == kNonRendering_Backend; |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 416 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 417 | |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 418 | // just so the compiler doesn't remove our loops |
| 419 | virtual void process(int) {} |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 420 | |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 421 | protected: |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 422 | void onDraw(int loops, SkCanvas*) override { |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 423 | int accum = 0; |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 424 | |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 425 | if (fUsePortable) { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 426 | for (int j = 0; j < loops; ++j) { |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 427 | for (int i = 0; i < ARRAY; ++i) { |
| 428 | accum += SkCLZ_portable(fData[i]); |
| 429 | } |
| 430 | this->process(accum); |
| 431 | } |
| 432 | } else { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 433 | for (int j = 0; j < loops; ++j) { |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 434 | for (int i = 0; i < ARRAY; ++i) { |
| 435 | accum += SkCLZ(fData[i]); |
| 436 | } |
| 437 | this->process(accum); |
| 438 | } |
| 439 | } |
| 440 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 441 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 442 | const char* onGetName() override { |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 443 | return fName; |
| 444 | } |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 445 | |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 446 | private: |
| 447 | const char* fName; |
skia.committer@gmail.com | 8152113 | 2013-04-30 07:01:03 +0000 | [diff] [blame] | 448 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 449 | typedef Benchmark INHERITED; |
reed@google.com | 0d7aac9 | 2013-04-29 13:55:11 +0000 | [diff] [blame] | 450 | }; |
| 451 | |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 452 | /////////////////////////////////////////////////////////////////////////////// |
| 453 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 454 | class NormalizeBench : public Benchmark { |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 455 | enum { |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 456 | ARRAY =1000, |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 457 | }; |
| 458 | SkVector fVec[ARRAY]; |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 459 | |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 460 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 461 | NormalizeBench() { |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 462 | SkRandom rand; |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 463 | for (int i = 0; i < ARRAY; ++i) { |
| 464 | fVec[i].set(rand.nextSScalar1(), rand.nextSScalar1()); |
| 465 | } |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 466 | |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 467 | fName = "point_normalize"; |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 468 | } |
| 469 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 470 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 471 | return backend == kNonRendering_Backend; |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 472 | } |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 473 | |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 474 | // just so the compiler doesn't remove our loops |
| 475 | virtual void process(int) {} |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 476 | |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 477 | protected: |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 478 | void onDraw(int loops, SkCanvas*) override { |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 479 | int accum = 0; |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 480 | |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 481 | for (int j = 0; j < loops; ++j) { |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 482 | for (int i = 0; i < ARRAY; ++i) { |
| 483 | accum += fVec[i].normalize(); |
| 484 | } |
| 485 | this->process(accum); |
| 486 | } |
| 487 | } |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 488 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 489 | const char* onGetName() override { |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 490 | return fName; |
| 491 | } |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 492 | |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 493 | private: |
| 494 | const char* fName; |
skia.committer@gmail.com | ecc9d28 | 2013-05-04 07:01:15 +0000 | [diff] [blame] | 495 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 496 | typedef Benchmark INHERITED; |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 497 | }; |
| 498 | |
| 499 | /////////////////////////////////////////////////////////////////////////////// |
| 500 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 501 | class FixedMathBench : public Benchmark { |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 502 | enum { |
mtklein@google.com | c289743 | 2013-09-10 19:23:38 +0000 | [diff] [blame] | 503 | N = 1000, |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 504 | }; |
| 505 | float fData[N]; |
| 506 | SkFixed fResult[N]; |
| 507 | public: |
| 508 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 509 | FixedMathBench() { |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 510 | SkRandom rand; |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 511 | for (int i = 0; i < N; ++i) { |
| 512 | fData[i] = rand.nextSScalar1(); |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 513 | } |
| 514 | |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 515 | } |
| 516 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 517 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 518 | return backend == kNonRendering_Backend; |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | protected: |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 522 | void onDraw(int loops, SkCanvas*) override { |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 523 | for (int j = 0; j < loops; ++j) { |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 524 | for (int i = 0; i < N - 4; ++i) { |
| 525 | fResult[i] = SkFloatToFixed(fData[i]); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | SkPaint paint; |
| 530 | if (paint.getAlpha() == 0) { |
| 531 | SkDebugf("%d\n", fResult[0]); |
| 532 | } |
| 533 | } |
| 534 | |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 535 | const char* onGetName() override { |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 536 | return "float_to_fixed"; |
| 537 | } |
| 538 | |
| 539 | private: |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 540 | typedef Benchmark INHERITED; |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 541 | }; |
| 542 | |
| 543 | /////////////////////////////////////////////////////////////////////////////// |
| 544 | |
commit-bot@chromium.org | 2c86fbb | 2013-09-26 19:22:54 +0000 | [diff] [blame] | 545 | template <typename T> |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 546 | class DivModBench : public Benchmark { |
mtklein@google.com | 9cb5177 | 2013-09-27 13:39:14 +0000 | [diff] [blame] | 547 | SkString fName; |
commit-bot@chromium.org | 2c86fbb | 2013-09-26 19:22:54 +0000 | [diff] [blame] | 548 | public: |
mtklein@google.com | 9cb5177 | 2013-09-27 13:39:14 +0000 | [diff] [blame] | 549 | explicit DivModBench(const char* name) { |
| 550 | fName.printf("divmod_%s", name); |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 551 | } |
| 552 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 553 | bool isSuitableFor(Backend backend) override { |
commit-bot@chromium.org | 644629c | 2013-11-21 06:21:58 +0000 | [diff] [blame] | 554 | return backend == kNonRendering_Backend; |
commit-bot@chromium.org | 2c86fbb | 2013-09-26 19:22:54 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | protected: |
mtklein | f059900 | 2015-07-13 06:18:39 -0700 | [diff] [blame] | 558 | const char* onGetName() override { |
mtklein@google.com | 9cb5177 | 2013-09-27 13:39:14 +0000 | [diff] [blame] | 559 | return fName.c_str(); |
commit-bot@chromium.org | 2c86fbb | 2013-09-26 19:22:54 +0000 | [diff] [blame] | 560 | } |
| 561 | |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 562 | void onDraw(int loops, SkCanvas*) override { |
commit-bot@chromium.org | 2c86fbb | 2013-09-26 19:22:54 +0000 | [diff] [blame] | 563 | volatile T a = 0, b = 0; |
| 564 | T div = 0, mod = 0; |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 565 | for (int i = 0; i < loops; i++) { |
commit-bot@chromium.org | 2c86fbb | 2013-09-26 19:22:54 +0000 | [diff] [blame] | 566 | if ((T)i == 0) continue; // Small T will wrap around. |
| 567 | SkTDivMod((T)(i+1), (T)i, &div, &mod); |
| 568 | a ^= div; |
| 569 | b ^= mod; |
| 570 | } |
| 571 | } |
| 572 | }; |
| 573 | DEF_BENCH(return new DivModBench<uint8_t>("uint8_t")) |
| 574 | DEF_BENCH(return new DivModBench<uint16_t>("uint16_t")) |
| 575 | DEF_BENCH(return new DivModBench<uint32_t>("uint32_t")) |
| 576 | DEF_BENCH(return new DivModBench<uint64_t>("uint64_t")) |
| 577 | |
| 578 | DEF_BENCH(return new DivModBench<int8_t>("int8_t")) |
| 579 | DEF_BENCH(return new DivModBench<int16_t>("int16_t")) |
| 580 | DEF_BENCH(return new DivModBench<int32_t>("int32_t")) |
| 581 | DEF_BENCH(return new DivModBench<int64_t>("int64_t")) |
| 582 | |
| 583 | /////////////////////////////////////////////////////////////////////////////// |
| 584 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 585 | DEF_BENCH( return new NoOpMathBench(); ) |
commit-bot@chromium.org | 11e5b97 | 2013-11-08 20:14:16 +0000 | [diff] [blame] | 586 | DEF_BENCH( return new SkRSqrtMathBench(); ) |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 587 | DEF_BENCH( return new SlowISqrtMathBench(); ) |
| 588 | DEF_BENCH( return new FastISqrtMathBench(); ) |
| 589 | DEF_BENCH( return new QMul64Bench(); ) |
| 590 | DEF_BENCH( return new QMul32Bench(); ) |
reed@google.com | ddc518b | 2011-08-29 17:49:23 +0000 | [diff] [blame] | 591 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 592 | DEF_BENCH( return new IsFiniteBench(-1); ) |
| 593 | DEF_BENCH( return new IsFiniteBench(0); ) |
| 594 | DEF_BENCH( return new IsFiniteBench(1); ) |
| 595 | DEF_BENCH( return new IsFiniteBench(2); ) |
| 596 | DEF_BENCH( return new IsFiniteBench(3); ) |
| 597 | DEF_BENCH( return new IsFiniteBench(4); ) |
| 598 | DEF_BENCH( return new IsFiniteBench(5); ) |
reed@google.com | 0be5eb7 | 2011-12-05 21:53:22 +0000 | [diff] [blame] | 599 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 600 | DEF_BENCH( return new FloorBench(false); ) |
| 601 | DEF_BENCH( return new FloorBench(true); ) |
reed@google.com | 7f19241 | 2012-05-30 12:26:52 +0000 | [diff] [blame] | 602 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 603 | DEF_BENCH( return new CLZBench(false); ) |
| 604 | DEF_BENCH( return new CLZBench(true); ) |
reed@google.com | 0889f68 | 2013-05-03 12:56:39 +0000 | [diff] [blame] | 605 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 606 | DEF_BENCH( return new NormalizeBench(); ) |
djsollen@google.com | 25a11e4 | 2013-07-18 19:11:30 +0000 | [diff] [blame] | 607 | |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 608 | DEF_BENCH( return new FixedMathBench(); ) |