aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-03 12:56:39 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-03 12:56:39 +0000
commit0889f682fbbf19878fd43fc406b21c8639edce1c (patch)
tree35ea57aa5f7b5057b665fb5dcd48777fa596212e
parent2fd42c471c77f54ace35c13975651e17d5b2e8c6 (diff)
add bench for SkPoint::normalize()
git-svn-id: http://skia.googlecode.com/svn/trunk@8977 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/MathBench.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index 90cc4b81fe..1e4f2818e3 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -433,6 +433,55 @@ private:
///////////////////////////////////////////////////////////////////////////////
+class NormalizeBench : public SkBenchmark {
+ enum {
+ ARRAY = SkBENCHLOOP(1000),
+ LOOP = SkBENCHLOOP(1000),
+ };
+ SkVector fVec[ARRAY];
+ bool fUsePortable;
+
+public:
+ NormalizeBench(void* param, bool usePortable)
+ : INHERITED(param)
+ , fUsePortable(usePortable) {
+
+ SkRandom rand;
+ for (int i = 0; i < ARRAY; ++i) {
+ fVec[i].set(rand.nextSScalar1(), rand.nextSScalar1());
+ }
+
+ fName = "point_normalize";
+ fIsRendering = false;
+ }
+
+ // just so the compiler doesn't remove our loops
+ virtual void process(int) {}
+
+protected:
+ virtual void onDraw(SkCanvas*) {
+ int accum = 0;
+
+ for (int j = 0; j < LOOP; ++j) {
+ for (int i = 0; i < ARRAY; ++i) {
+ accum += fVec[i].normalize();
+ }
+ this->process(accum);
+ }
+ }
+
+ virtual const char* onGetName() {
+ return fName;
+ }
+
+private:
+ const char* fName;
+
+ typedef SkBenchmark INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
DEF_BENCH( return new NoOpMathBench(p); )
DEF_BENCH( return new SlowISqrtMathBench(p); )
DEF_BENCH( return new FastISqrtMathBench(p); )
@@ -452,3 +501,5 @@ DEF_BENCH( return new FloorBench(p, true); )
DEF_BENCH( return new CLZBench(p, false); )
DEF_BENCH( return new CLZBench(p, true); )
+
+DEF_BENCH( return new NormalizeBench(p, false); )