Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: bench/MathBench.cpp

Issue 1018523008: Revert of replace SkFixedDiv impl with native 64bit math (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkFixed.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Benchmark.h" 1 #include "Benchmark.h"
2 #include "SkColorPriv.h" 2 #include "SkColorPriv.h"
3 #include "SkMatrix.h" 3 #include "SkMatrix.h"
4 #include "SkPaint.h" 4 #include "SkPaint.h"
5 #include "SkRandom.h" 5 #include "SkRandom.h"
6 #include "SkString.h" 6 #include "SkString.h"
7 7
8 static float sk_fsel(float pred, float result_ge, float result_lt) { 8 static float sk_fsel(float pred, float result_ge, float result_lt) {
9 return pred >= 0 ? result_ge : result_lt; 9 return pred >= 0 ? result_ge : result_lt;
10 } 10 }
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 virtual const char* onGetName() { 538 virtual const char* onGetName() {
539 return "float_to_fixed"; 539 return "float_to_fixed";
540 } 540 }
541 541
542 private: 542 private:
543 typedef Benchmark INHERITED; 543 typedef Benchmark INHERITED;
544 }; 544 };
545 545
546 /////////////////////////////////////////////////////////////////////////////// 546 ///////////////////////////////////////////////////////////////////////////////
547 547
548 class DivBitsBench : public Benchmark {
549 protected:
550 enum {
551 N = 1000
552 };
553 volatile int32_t fSrc[N], fDst[N];
554 public:
555 DivBitsBench() {
556 SkRandom rand;
557 for (int i = 0; i < N; ++i) {
558 fSrc[i] = rand.nextU();
559 }
560 }
561 protected:
562 virtual void onDraw(const int loops, SkCanvas*) {
563 for (int j = 0; j < loops; ++j) {
564 for (int i = 0; i < N - 4; ++i) {
565 fDst[i] = SkDivBits(fSrc[i], fSrc[i] >> 3, 16);
566 }
567 }
568 }
569 virtual const char* onGetName() {
570 return "divbits";
571 }
572 };
573 DEF_BENCH( return new DivBitsBench; )
574
575 class FixedDivBench : public DivBitsBench {
576 protected:
577 virtual void onDraw(const int loops, SkCanvas*) {
578 for (int j = 0; j < loops; ++j) {
579 for (int i = 0; i < N - 4; ++i) {
580 fDst[i] = SkFixedDiv(fSrc[i], fSrc[i] >> 3);
581 }
582 }
583 }
584 virtual const char* onGetName() {
585 return "fixeddiv";
586 }
587 };
588 DEF_BENCH( return new FixedDivBench; )
589
590 ///////////////////////////////////////////////////////////////////////////////
591
592 template <typename T> 548 template <typename T>
593 class DivModBench : public Benchmark { 549 class DivModBench : public Benchmark {
594 SkString fName; 550 SkString fName;
595 public: 551 public:
596 explicit DivModBench(const char* name) { 552 explicit DivModBench(const char* name) {
597 fName.printf("divmod_%s", name); 553 fName.printf("divmod_%s", name);
598 } 554 }
599 555
600 bool isSuitableFor(Backend backend) SK_OVERRIDE { 556 bool isSuitableFor(Backend backend) SK_OVERRIDE {
601 return backend == kNonRendering_Backend; 557 return backend == kNonRendering_Backend;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 602
647 DEF_BENCH( return new FloorBench(false); ) 603 DEF_BENCH( return new FloorBench(false); )
648 DEF_BENCH( return new FloorBench(true); ) 604 DEF_BENCH( return new FloorBench(true); )
649 605
650 DEF_BENCH( return new CLZBench(false); ) 606 DEF_BENCH( return new CLZBench(false); )
651 DEF_BENCH( return new CLZBench(true); ) 607 DEF_BENCH( return new CLZBench(true); )
652 608
653 DEF_BENCH( return new NormalizeBench(); ) 609 DEF_BENCH( return new NormalizeBench(); )
654 610
655 DEF_BENCH( return new FixedMathBench(); ) 611 DEF_BENCH( return new FixedMathBench(); )
OLDNEW
« no previous file with comments | « no previous file | include/core/SkFixed.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698