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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkFixed.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/MathBench.cpp
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index 1fc5705be829946e2b4f00a55562985f796994d0..32a89d64efd9263033207ad9757c00d6361a1dc1 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -480,6 +480,48 @@ private:
///////////////////////////////////////////////////////////////////////////////
+class FixedMathBench : public SkBenchmark {
+ enum {
+ N = SkBENCHLOOP(1000),
+ NN = SkBENCHLOOP(1000),
+ };
+ float fData[N];
+ SkFixed fResult[N];
+public:
+
+ FixedMathBench(void* param) : INHERITED(param) {
+ SkRandom rand;
+ for (int i = 0; i < N; ++i) {
+ fData[i] = rand.nextSScalar1();
+ }
+
+ fIsRendering = false;
+ }
+
+protected:
+ virtual void onDraw(SkCanvas*) {
+ for (int j = 0; j < NN; ++j) {
+ for (int i = 0; i < N - 4; ++i) {
+ fResult[i] = SkFloatToFixed(fData[i]);
+ }
+ }
+
+ SkPaint paint;
+ if (paint.getAlpha() == 0) {
+ SkDebugf("%d\n", fResult[0]);
+ }
+ }
+
+ virtual const char* onGetName() {
+ return "float_to_fixed";
+ }
+
+private:
+ typedef SkBenchmark INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
DEF_BENCH( return new NoOpMathBench(p); )
DEF_BENCH( return new SlowISqrtMathBench(p); )
DEF_BENCH( return new FastISqrtMathBench(p); )
@@ -501,3 +543,5 @@ DEF_BENCH( return new CLZBench(p, false); )
DEF_BENCH( return new CLZBench(p, true); )
DEF_BENCH( return new NormalizeBench(p); )
+
+DEF_BENCH( return new FixedMathBench(p); )
« 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