diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-13 12:30:35 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-13 12:30:35 +0000 |
commit | 357818cb76d9f8a6a74d1b2f9c91fb4c0b7a288c (patch) | |
tree | da8d80c63c5f9d357b1c8448c880c9830bd0f642 /bench/ScalarBench.cpp | |
parent | bb0b67f6596e669f8cc38a0f2bd7b00bb27f8fe2 (diff) |
fix bogus assert
git-svn-id: http://skia.googlecode.com/svn/trunk@4242 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/ScalarBench.cpp')
-rw-r--r-- | bench/ScalarBench.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/bench/ScalarBench.cpp b/bench/ScalarBench.cpp index 8889d7b74f..2d547b7883 100644 --- a/bench/ScalarBench.cpp +++ b/bench/ScalarBench.cpp @@ -24,7 +24,7 @@ public: protected: virtual int mulLoopCount() const { return 1; } - virtual const char* onGetName() { + virtual const char* onGetName() SK_OVERRIDE { return fName.c_str(); } @@ -80,7 +80,7 @@ private: class ForcedIntComparisonBench : public ScalarBench { public: ForcedIntComparisonBench(void* param) - : INHERITED(param, "compare_forced_int") { + : INHERITED(param, "compare_forced_int") { init9(fArray); } protected: @@ -98,6 +98,37 @@ private: typedef ScalarBench INHERITED; }; +class IsFiniteScalarBench : public ScalarBench { +public: + IsFiniteScalarBench(void* param) : INHERITED(param, "isfinite") { + SkRandom rand; + for (size_t i = 0; i < ARRAY_N; ++i) { + fArray[i] = rand.nextSScalar1(); + } + } +protected: + virtual int mulLoopCount() const { return 1; } + virtual void performTest() SK_OVERRIDE { + int sum = 0; + for (size_t i = 0; i < ARRAY_N; ++i) { + // We pass -fArray[i], so the compiler can't cheat and treat the + // value as an int (even though we tell it that it is a float) + sum += SkScalarIsFinite(-fArray[i]); + } + // we do this so the compiler won't optimize our loop away... + this->doSomething(fArray, sum); + } + + virtual void doSomething(SkScalar array[], int sum) {} +private: + enum { + ARRAY_N = 64 + }; + SkScalar fArray[ARRAY_N]; + + typedef ScalarBench INHERITED; +}; + /////////////////////////////////////////////////////////////////////////////// class RectBoundsBench : public SkBenchmark { @@ -137,7 +168,9 @@ private: static SkBenchmark* S0(void* p) { return new FloatComparisonBench(p); } static SkBenchmark* S1(void* p) { return new ForcedIntComparisonBench(p); } static SkBenchmark* S2(void* p) { return new RectBoundsBench(p); } +static SkBenchmark* S3(void* p) { return new IsFiniteScalarBench(p); } static BenchRegistry gReg0(S0); static BenchRegistry gReg1(S1); static BenchRegistry gReg2(S2); +static BenchRegistry gReg3(S3); |