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 |
548 template <typename T> | 592 template <typename T> |
549 class DivModBench : public Benchmark { | 593 class DivModBench : public Benchmark { |
550 SkString fName; | 594 SkString fName; |
551 public: | 595 public: |
552 explicit DivModBench(const char* name) { | 596 explicit DivModBench(const char* name) { |
553 fName.printf("divmod_%s", name); | 597 fName.printf("divmod_%s", name); |
554 } | 598 } |
555 | 599 |
556 bool isSuitableFor(Backend backend) SK_OVERRIDE { | 600 bool isSuitableFor(Backend backend) SK_OVERRIDE { |
557 return backend == kNonRendering_Backend; | 601 return backend == kNonRendering_Backend; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 646 |
603 DEF_BENCH( return new FloorBench(false); ) | 647 DEF_BENCH( return new FloorBench(false); ) |
604 DEF_BENCH( return new FloorBench(true); ) | 648 DEF_BENCH( return new FloorBench(true); ) |
605 | 649 |
606 DEF_BENCH( return new CLZBench(false); ) | 650 DEF_BENCH( return new CLZBench(false); ) |
607 DEF_BENCH( return new CLZBench(true); ) | 651 DEF_BENCH( return new CLZBench(true); ) |
608 | 652 |
609 DEF_BENCH( return new NormalizeBench(); ) | 653 DEF_BENCH( return new NormalizeBench(); ) |
610 | 654 |
611 DEF_BENCH( return new FixedMathBench(); ) | 655 DEF_BENCH( return new FixedMathBench(); ) |
OLD | NEW |