New benchmark to create many random quadratic paths.
Added to try to get a handle on the cost of CPU-side changes to GPU rendering, but probably too noisy to be useful.



git-svn-id: http://skia.googlecode.com/svn/trunk@1674 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp
index 19e3aae..beaa9ab 100644
--- a/bench/PathBench.cpp
+++ b/bench/PathBench.cpp
@@ -3,6 +3,7 @@
 #include "SkCanvas.h"
 #include "SkColorPriv.h"
 #include "SkPaint.h"
+#include "SkRandom.h"
 #include "SkShader.h"
 #include "SkString.h"
 
@@ -31,7 +32,7 @@
 
     virtual void appendName(SkString*) = 0;
     virtual void makePath(SkPath*) = 0;
-    virtual bool iscomplex() { return false; }
+    virtual int complexity() { return 0; }
 
 protected:
     virtual const char* onGetName() {
@@ -58,9 +59,7 @@
         if (fFlags & kBig_Flag) {
             count >>= 2;
         }
-        if (this->iscomplex()) {
-            count >>= 3;
-        }
+        count >>= (3 * complexity());
 
         for (int i = 0; i < count; i++) {
             canvas->drawPath(path, paint);
@@ -146,11 +145,38 @@
         path->lineTo(x0, y + 2 * dy);
         path->close();
     }
-    virtual bool iscomplex() { return true; }
+    virtual int complexity() { return 1; }
 private:
     typedef PathBench INHERITED;
 };
 
+class LongCurvedPathBench : public PathBench {
+public:
+    LongCurvedPathBench(void * param, Flags flags)
+        : INHERITED(param, flags) {
+    }
+
+    virtual void appendName(SkString* name) {
+        name->append("long_curved");
+    }
+    virtual void makePath(SkPath* path) {
+        SkRandom rand (12);
+        int i;
+        for (i = 0; i < 100; i++) {
+            path->quadTo(SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)),
+                         SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480)),
+                         SkScalarMul(rand.nextUScalar1(), SkIntToScalar(640)),
+                         SkScalarMul(rand.nextUScalar1(), SkIntToScalar(480)));
+        }
+        path->close();
+    }
+    virtual int complexity() { return 2; }
+private:
+    typedef PathBench INHERITED;
+};
+
+
+
 static SkBenchmark* FactT00(void* p) { return new TrianglePathBench(p, FLAGS00); }
 static SkBenchmark* FactT01(void* p) { return new TrianglePathBench(p, FLAGS01); }
 static SkBenchmark* FactT10(void* p) { return new TrianglePathBench(p, FLAGS10); }
@@ -169,6 +195,13 @@
 static SkBenchmark* FactS00(void* p) { return new SawToothPathBench(p, FLAGS00); }
 static SkBenchmark* FactS01(void* p) { return new SawToothPathBench(p, FLAGS01); }
 
+static SkBenchmark* FactLC00(void* p) {
+    return new LongCurvedPathBench(p, FLAGS00);
+}
+static SkBenchmark* FactLC01(void* p) {
+    return new LongCurvedPathBench(p, FLAGS01);
+}
+
 static BenchRegistry gRegT00(FactT00);
 static BenchRegistry gRegT01(FactT01);
 static BenchRegistry gRegT10(FactT10);
@@ -187,3 +220,6 @@
 static BenchRegistry gRegS00(FactS00);
 static BenchRegistry gRegS01(FactS01);
 
+static BenchRegistry gRegLC00(FactLC00);
+static BenchRegistry gRegLC01(FactLC01);
+