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

Side by Side Diff: bench/MathBench.cpp

Issue 19773006: Add bench to test float to fixed conversion (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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/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 "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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 474
475 private: 475 private:
476 const char* fName; 476 const char* fName;
477 477
478 typedef SkBenchmark INHERITED; 478 typedef SkBenchmark INHERITED;
479 }; 479 };
480 480
481 /////////////////////////////////////////////////////////////////////////////// 481 ///////////////////////////////////////////////////////////////////////////////
482 482
483 class FixedMathBench : public SkBenchmark {
484 enum {
485 N = SkBENCHLOOP(1000),
486 NN = SkBENCHLOOP(1000),
487 };
488 float fData[N];
489 SkFixed fResult[N];
490 public:
491
492 FixedMathBench(void* param) : INHERITED(param) {
493 SkRandom rand;
494 for (int i = 0; i < N; ++i) {
495 fData[i] = rand.nextSScalar1();
496 }
497
498 fIsRendering = false;
499 }
500
501 protected:
502 virtual void onDraw(SkCanvas*) {
503 for (int j = 0; j < NN; ++j) {
504 for (int i = 0; i < N - 4; ++i) {
505 fResult[i] = SkFloatToFixed(fData[i]);
506 }
507 }
508
509 SkPaint paint;
510 if (paint.getAlpha() == 0) {
511 SkDebugf("%d\n", fResult[0]);
512 }
513 }
514
515 virtual const char* onGetName() {
516 return "float_to_fixed";
517 }
518
519 private:
520 typedef SkBenchmark INHERITED;
521 };
522
523 ///////////////////////////////////////////////////////////////////////////////
524
483 DEF_BENCH( return new NoOpMathBench(p); ) 525 DEF_BENCH( return new NoOpMathBench(p); )
484 DEF_BENCH( return new SlowISqrtMathBench(p); ) 526 DEF_BENCH( return new SlowISqrtMathBench(p); )
485 DEF_BENCH( return new FastISqrtMathBench(p); ) 527 DEF_BENCH( return new FastISqrtMathBench(p); )
486 DEF_BENCH( return new QMul64Bench(p); ) 528 DEF_BENCH( return new QMul64Bench(p); )
487 DEF_BENCH( return new QMul32Bench(p); ) 529 DEF_BENCH( return new QMul32Bench(p); )
488 530
489 DEF_BENCH( return new IsFiniteBench(p, -1); ) 531 DEF_BENCH( return new IsFiniteBench(p, -1); )
490 DEF_BENCH( return new IsFiniteBench(p, 0); ) 532 DEF_BENCH( return new IsFiniteBench(p, 0); )
491 DEF_BENCH( return new IsFiniteBench(p, 1); ) 533 DEF_BENCH( return new IsFiniteBench(p, 1); )
492 DEF_BENCH( return new IsFiniteBench(p, 2); ) 534 DEF_BENCH( return new IsFiniteBench(p, 2); )
493 DEF_BENCH( return new IsFiniteBench(p, 3); ) 535 DEF_BENCH( return new IsFiniteBench(p, 3); )
494 DEF_BENCH( return new IsFiniteBench(p, 4); ) 536 DEF_BENCH( return new IsFiniteBench(p, 4); )
495 DEF_BENCH( return new IsFiniteBench(p, 5); ) 537 DEF_BENCH( return new IsFiniteBench(p, 5); )
496 538
497 DEF_BENCH( return new FloorBench(p, false); ) 539 DEF_BENCH( return new FloorBench(p, false); )
498 DEF_BENCH( return new FloorBench(p, true); ) 540 DEF_BENCH( return new FloorBench(p, true); )
499 541
500 DEF_BENCH( return new CLZBench(p, false); ) 542 DEF_BENCH( return new CLZBench(p, false); )
501 DEF_BENCH( return new CLZBench(p, true); ) 543 DEF_BENCH( return new CLZBench(p, true); )
502 544
503 DEF_BENCH( return new NormalizeBench(p); ) 545 DEF_BENCH( return new NormalizeBench(p); )
546
547 DEF_BENCH( return new FixedMathBench(p); )
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