aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/MathBench.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-03-18 19:04:43 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-18 19:04:43 -0700
commit7c44ca926bf42b3b2e56131f250c0fd58f87ac71 (patch)
treef763c7c62cb8b37e65660702a2de7a7e49587559 /bench/MathBench.cpp
parent1a5041e446bda33e7f5e18f0df8d0be77c0a2349 (diff)
replace SkFixedDiv impl with native 64bit math
BUG=skia: TBR= Review URL: https://codereview.chromium.org/1022543003
Diffstat (limited to 'bench/MathBench.cpp')
-rw-r--r--bench/MathBench.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index 5b46d1c704..e0d519407f 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -545,6 +545,50 @@ private:
///////////////////////////////////////////////////////////////////////////////
+class DivBitsBench : public Benchmark {
+protected:
+ enum {
+ N = 1000
+ };
+ volatile int32_t fSrc[N], fDst[N];
+public:
+ DivBitsBench() {
+ SkRandom rand;
+ for (int i = 0; i < N; ++i) {
+ fSrc[i] = rand.nextU();
+ }
+ }
+protected:
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int j = 0; j < loops; ++j) {
+ for (int i = 0; i < N - 4; ++i) {
+ fDst[i] = SkDivBits(fSrc[i], fSrc[i] >> 3, 16);
+ }
+ }
+ }
+ virtual const char* onGetName() {
+ return "divbits";
+ }
+};
+DEF_BENCH( return new DivBitsBench; )
+
+class FixedDivBench : public DivBitsBench {
+protected:
+ virtual void onDraw(const int loops, SkCanvas*) {
+ for (int j = 0; j < loops; ++j) {
+ for (int i = 0; i < N - 4; ++i) {
+ fDst[i] = SkFixedDiv(fSrc[i], fSrc[i] >> 3);
+ }
+ }
+ }
+ virtual const char* onGetName() {
+ return "fixeddiv";
+ }
+};
+DEF_BENCH( return new FixedDivBench; )
+
+///////////////////////////////////////////////////////////////////////////////
+
template <typename T>
class DivModBench : public Benchmark {
SkString fName;