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