From e0dcde73991a13be48f2aed9829d5e744d7fe508 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 6 Jun 2011 13:20:29 +0000 Subject: make concat_float distinguishable using -match init our float/double arrays, so we get reliable timings (NaNs are slow) git-svn-id: http://skia.googlecode.com/svn/trunk@1509 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/MatrixBench.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'bench/MatrixBench.cpp') diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp index 783bf51940..eb7d39f5db 100644 --- a/bench/MatrixBench.cpp +++ b/bench/MatrixBench.cpp @@ -83,12 +83,24 @@ private: typedef MatrixBench INHERITED; }; +// having unknown values in our arrays can throw off the timing a lot, perhaps +// handling NaN values is a lot slower. Anyway, this guy is just meant to put +// reasonable values in our arrays. +template void init9(T array[9]) { + SkRandom rand; + for (int i = 0; i < 9; i++) { + array[i] = rand.nextSScalar1(); + } +} + // Test the performance of setConcat() non-perspective case: // using floating point precision only. class FloatConcatMatrixBench : public MatrixBench { public: - FloatConcatMatrixBench(void* param) - : INHERITED(param, "concat_float") { + FloatConcatMatrixBench(void* p) : INHERITED(p, "concat_floatfloat") { + init9(mya); + init9(myb); + init9(myr); } protected: static inline void muladdmul(float a, float b, float c, float d, @@ -126,8 +138,10 @@ static inline float SkDoubleToFloat(double x) { // intermediate results during computations. class FloatDoubleConcatMatrixBench : public MatrixBench { public: - FloatDoubleConcatMatrixBench(void* param) - : INHERITED(param, "concat_floatdouble") { + FloatDoubleConcatMatrixBench(void* p) : INHERITED(p, "concat_floatdouble") { + init9(mya); + init9(myb); + init9(myr); } protected: static inline void muladdmul(float a, float b, float c, float d, @@ -160,8 +174,10 @@ private: // using double precision only. class DoubleConcatMatrixBench : public MatrixBench { public: - DoubleConcatMatrixBench(void* param) - : INHERITED(param, "concat_double") { + DoubleConcatMatrixBench(void* p) : INHERITED(p, "concat_double") { + init9(mya); + init9(myb); + init9(myr); } protected: static inline void muladdmul(double a, double b, double c, double d, -- cgit v1.2.3