diff options
author | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-22 17:16:35 +0000 |
---|---|---|
committer | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-22 17:16:35 +0000 |
commit | 6e8d335b458ac2416bc5d09bab40e503384d102d (patch) | |
tree | d012a4dd758a1cb8ef3b5ab8087ff81fb5ebdf79 /bench | |
parent | d3aed39ab1ad88b05b9423ee1329c227d1f8f612 (diff) |
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
Diffstat (limited to 'bench')
-rw-r--r-- | bench/PathBench.cpp | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp index 19e3aae873..beaa9ab1f8 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 @@ public: 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 @@ protected: 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 @@ public: 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* FactO11(void* p) { return new OvalPathBench(p, FLAGS11); } 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 gRegO11(FactO11); static BenchRegistry gRegS00(FactS00); static BenchRegistry gRegS01(FactS01); +static BenchRegistry gRegLC00(FactLC00); +static BenchRegistry gRegLC01(FactLC01); + |