diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-10 14:19:40 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-10 14:19:40 +0000 |
commit | e05cc8e94ee2ad853233262d74047119939111f2 (patch) | |
tree | 50d39b53258eb3b22ef5371e3d6c20ba7627979c /bench/MathBench.cpp | |
parent | 58f511989f08a0af74f041cfae657740b008da86 (diff) |
explicitly set opt level for mac-release
delete obsolete FPS bench
git-svn-id: http://skia.googlecode.com/svn/trunk@2442 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/MathBench.cpp')
-rw-r--r-- | bench/MathBench.cpp | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp index a8eb43eb4c..5726f38ede 100644 --- a/bench/MathBench.cpp +++ b/bench/MathBench.cpp @@ -1,4 +1,5 @@ #include "SkBenchmark.h" +#include "SkColorPriv.h" #include "SkMatrix.h" #include "SkRandom.h" #include "SkString.h" @@ -40,14 +41,24 @@ private: typedef SkBenchmark INHERITED; }; -int gMathBench_NonStaticGlobal; +class MathBenchU32 : public MathBench { +public: + MathBenchU32(void* param, const char name[]) : INHERITED(param, name) {} + +protected: + virtual void performITest(uint32_t* dst, const uint32_t* src, int count) = 0; + + virtual void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, + int count) SK_OVERRIDE { + uint32_t* d = SkTCast<uint32_t*>(dst); + const uint32_t* s = SkTCast<const uint32_t*>(src); + this->performITest(d, s, count); + } +private: + typedef MathBench INHERITED; +}; -#define always_do(pred) \ - do { \ - if (pred) { \ - ++gMathBench_NonStaticGlobal; \ - } \ - } while (0) +/////////////////////////////////////////////////////////////////////////////// class NoOpMathBench : public MathBench { public: @@ -98,12 +109,56 @@ private: typedef MathBench INHERITED; }; +static inline uint32_t QMul64(uint32_t value, U8CPU alpha) { + SkASSERT((uint8_t)alpha == alpha); + const uint32_t mask = 0xFF00FF; + + uint64_t tmp = value; + tmp = (tmp & mask) | ((tmp & ~mask) << 24); + tmp *= alpha; + return ((tmp >> 8) & mask) | ((tmp >> 32) & ~mask); +} + +class QMul64Bench : public MathBenchU32 { +public: + QMul64Bench(void* param) : INHERITED(param, "qmul64") {} +protected: + virtual void performITest(uint32_t* SK_RESTRICT dst, + const uint32_t* SK_RESTRICT src, + int count) SK_OVERRIDE { + for (int i = 0; i < count; ++i) { + dst[i] = QMul64(src[i], (uint8_t)i); + } + } +private: + typedef MathBenchU32 INHERITED; +}; + +class QMul32Bench : public MathBenchU32 { +public: + QMul32Bench(void* param) : INHERITED(param, "qmul32") {} +protected: + virtual void performITest(uint32_t* SK_RESTRICT dst, + const uint32_t* SK_RESTRICT src, + int count) SK_OVERRIDE { + for (int i = 0; i < count; ++i) { + dst[i] = SkAlphaMulQ(src[i], (uint8_t)i); + } + } +private: + typedef MathBenchU32 INHERITED; +}; + /////////////////////////////////////////////////////////////////////////////// static SkBenchmark* M0(void* p) { return new NoOpMathBench(p); } static SkBenchmark* M1(void* p) { return new SlowISqrtMathBench(p); } static SkBenchmark* M2(void* p) { return new FastISqrtMathBench(p); } +static SkBenchmark* M3(void* p) { return new QMul64Bench(p); } +static SkBenchmark* M4(void* p) { return new QMul32Bench(p); } static BenchRegistry gReg0(M0); static BenchRegistry gReg1(M1); static BenchRegistry gReg2(M2); +static BenchRegistry gReg3(M3); +static BenchRegistry gReg4(M4); |