OLD | NEW |
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 Loading... |
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 Loading... |
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(); ) |
OLD | NEW |