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

Side by Side Diff: bench/MathBench.cpp

Issue 24159009: Add SkDivMod with a special case for ARM. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: appease gcc on 10.6 Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | include/core/SkMath.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 "SkBenchmark.h" 1 #include "SkBenchmark.h"
2 #include "SkColorPriv.h" 2 #include "SkColorPriv.h"
3 #include "SkMatrix.h" 3 #include "SkMatrix.h"
4 #include "SkRandom.h" 4 #include "SkRandom.h"
5 #include "SkString.h" 5 #include "SkString.h"
6 #include "SkPaint.h" 6 #include "SkPaint.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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 virtual const char* onGetName() { 505 virtual const char* onGetName() {
506 return "float_to_fixed"; 506 return "float_to_fixed";
507 } 507 }
508 508
509 private: 509 private:
510 typedef SkBenchmark INHERITED; 510 typedef SkBenchmark INHERITED;
511 }; 511 };
512 512
513 /////////////////////////////////////////////////////////////////////////////// 513 ///////////////////////////////////////////////////////////////////////////////
514 514
515 template <typename T>
516 class DivModBench : public SkBenchmark {
517 const char* fName;
518 public:
519 explicit DivModBench(const char* name) : fName(name) {
520 fIsRendering = false;
521 }
522
523 protected:
524 virtual const char* onGetName() {
525 return SkStringPrintf("divmod_%s", fName).c_str();
526 }
527
528 virtual void onDraw(SkCanvas*) {
529 volatile T a = 0, b = 0;
530 T div = 0, mod = 0;
531 for (int i = 0; i < this->getLoops(); i++) {
532 if ((T)i == 0) continue; // Small T will wrap around.
533 SkTDivMod((T)(i+1), (T)i, &div, &mod);
534 a ^= div;
535 b ^= mod;
536 }
537 }
538 };
539 DEF_BENCH(return new DivModBench<uint8_t>("uint8_t"))
540 DEF_BENCH(return new DivModBench<uint16_t>("uint16_t"))
541 DEF_BENCH(return new DivModBench<uint32_t>("uint32_t"))
542 DEF_BENCH(return new DivModBench<uint64_t>("uint64_t"))
543
544 DEF_BENCH(return new DivModBench<int8_t>("int8_t"))
545 DEF_BENCH(return new DivModBench<int16_t>("int16_t"))
546 DEF_BENCH(return new DivModBench<int32_t>("int32_t"))
547 DEF_BENCH(return new DivModBench<int64_t>("int64_t"))
548
549 ///////////////////////////////////////////////////////////////////////////////
550
515 DEF_BENCH( return new NoOpMathBench(); ) 551 DEF_BENCH( return new NoOpMathBench(); )
516 DEF_BENCH( return new SlowISqrtMathBench(); ) 552 DEF_BENCH( return new SlowISqrtMathBench(); )
517 DEF_BENCH( return new FastISqrtMathBench(); ) 553 DEF_BENCH( return new FastISqrtMathBench(); )
518 DEF_BENCH( return new QMul64Bench(); ) 554 DEF_BENCH( return new QMul64Bench(); )
519 DEF_BENCH( return new QMul32Bench(); ) 555 DEF_BENCH( return new QMul32Bench(); )
520 556
521 DEF_BENCH( return new IsFiniteBench(-1); ) 557 DEF_BENCH( return new IsFiniteBench(-1); )
522 DEF_BENCH( return new IsFiniteBench(0); ) 558 DEF_BENCH( return new IsFiniteBench(0); )
523 DEF_BENCH( return new IsFiniteBench(1); ) 559 DEF_BENCH( return new IsFiniteBench(1); )
524 DEF_BENCH( return new IsFiniteBench(2); ) 560 DEF_BENCH( return new IsFiniteBench(2); )
525 DEF_BENCH( return new IsFiniteBench(3); ) 561 DEF_BENCH( return new IsFiniteBench(3); )
526 DEF_BENCH( return new IsFiniteBench(4); ) 562 DEF_BENCH( return new IsFiniteBench(4); )
527 DEF_BENCH( return new IsFiniteBench(5); ) 563 DEF_BENCH( return new IsFiniteBench(5); )
528 564
529 DEF_BENCH( return new FloorBench(false); ) 565 DEF_BENCH( return new FloorBench(false); )
530 DEF_BENCH( return new FloorBench(true); ) 566 DEF_BENCH( return new FloorBench(true); )
531 567
532 DEF_BENCH( return new CLZBench(false); ) 568 DEF_BENCH( return new CLZBench(false); )
533 DEF_BENCH( return new CLZBench(true); ) 569 DEF_BENCH( return new CLZBench(true); )
534 570
535 DEF_BENCH( return new NormalizeBench(); ) 571 DEF_BENCH( return new NormalizeBench(); )
536 572
537 DEF_BENCH( return new FixedMathBench(); ) 573 DEF_BENCH( return new FixedMathBench(); )
OLDNEW
« no previous file with comments | « no previous file | include/core/SkMath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698