aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-07 14:31:38 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-07 14:31:38 +0000
commit288ff33d06776d6b105f8056af30191510ca0e3f (patch)
tree80d23996280408f79ad316bb4dd99618cb44a47f /bench
parenta87e065870bf5144b1b5313c58552737e9aed7d4 (diff)
New benchmarks to determine performance of matrix-point multiplication for floating point vs. double matrices.
Over-the-shoulder review by reed@. git-svn-id: http://skia.googlecode.com/svn/trunk@1525 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r--bench/MatrixBench.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp
index d963bc7126..88e1538676 100644
--- a/bench/MatrixBench.cpp
+++ b/bench/MatrixBench.cpp
@@ -215,6 +215,89 @@ private:
typedef MatrixBench INHERITED;
};
+#ifdef SK_SCALAR_IS_FLOAT
+class ScaleTransMixedMatrixBench : public MatrixBench {
+ public:
+ ScaleTransMixedMatrixBench(void* p) : INHERITED(p, "scaletrans_mixed"), fCount (16) {
+ fMatrix.setAll(fRandom.nextS(), fRandom.nextS(), fRandom.nextS(),
+ fRandom.nextS(), fRandom.nextS(), fRandom.nextS(),
+ fRandom.nextS(), fRandom.nextS(), fRandom.nextS());
+ int i;
+ for (i = 0; i < fCount; i++) {
+ fSrc[i].fX = fRandom.nextS();
+ fSrc[i].fY = fRandom.nextS();
+ fDst[i].fX = fRandom.nextS();
+ fDst[i].fY = fRandom.nextS();
+ }
+ }
+ protected:
+ virtual void performTest() {
+ SkPoint* dst = fDst;
+ const SkPoint* src = fSrc;
+ int count = fCount;
+ float mx = fMatrix[SkMatrix::kMScaleX];
+ float my = fMatrix[SkMatrix::kMScaleY];
+ float tx = fMatrix[SkMatrix::kMTransX];
+ float ty = fMatrix[SkMatrix::kMTransY];
+ do {
+ dst->fY = SkScalarMulAdd(src->fY, my, ty);
+ dst->fX = SkScalarMulAdd(src->fX, mx, tx);
+ src += 1;
+ dst += 1;
+ } while (--count);
+ }
+ private:
+ SkMatrix fMatrix;
+ SkPoint fSrc [16];
+ SkPoint fDst [16];
+ int fCount;
+ SkRandom fRandom;
+ typedef MatrixBench INHERITED;
+};
+
+
+class ScaleTransDoubleMatrixBench : public MatrixBench {
+ public:
+ ScaleTransDoubleMatrixBench(void* p) : INHERITED(p, "scaletrans_double"), fCount (16) {
+ init9(fMatrix);
+ int i;
+ for (i = 0; i < fCount; i++) {
+ fSrc[i].fX = fRandom.nextS();
+ fSrc[i].fY = fRandom.nextS();
+ fDst[i].fX = fRandom.nextS();
+ fDst[i].fY = fRandom.nextS();
+ }
+ }
+ protected:
+ virtual void performTest() {
+ SkPoint* dst = fDst;
+ const SkPoint* src = fSrc;
+ int count = fCount;
+ // As doubles, on Z600 Linux systems this is 2.5x as expensive as mixed mode
+ float mx = fMatrix[SkMatrix::kMScaleX];
+ float my = fMatrix[SkMatrix::kMScaleY];
+ float tx = fMatrix[SkMatrix::kMTransX];
+ float ty = fMatrix[SkMatrix::kMTransY];
+ do {
+ dst->fY = src->fY * my + ty;
+ dst->fX = src->fX * mx + tx;
+ src += 1;
+ dst += 1;
+ } while (--count);
+ }
+ private:
+ double fMatrix [9];
+ SkPoint fSrc [16];
+ SkPoint fDst [16];
+ int fCount;
+ SkRandom fRandom;
+ typedef MatrixBench INHERITED;
+};
+#endif
+
+
+
+
static SkBenchmark* M0(void* p) { return new EqualsMatrixBench(p); }
static SkBenchmark* M1(void* p) { return new ScaleMatrixBench(p); }
@@ -227,3 +310,10 @@ static BenchRegistry gReg1(M1);
static BenchRegistry gReg2(M2);
static BenchRegistry gReg3(M3);
static BenchRegistry gReg4(M4);
+
+#ifdef SK_SCALAR_IS_FLOAT
+static SkBenchmark* FlM0(void* p) { return new ScaleTransMixedMatrixBench(p); }
+static SkBenchmark* FlM1(void* p) { return new ScaleTransDoubleMatrixBench(p); }
+static BenchRegistry gFlReg5(FlM0);
+static BenchRegistry gFlReg6(FlM1);
+#endif