Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: bench/Matrix44Bench.cpp

Issue 22886010: Add perf benchmarks and more unit tests for matrix inversion (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/Matrix44Test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkMatrix44.h" 9 #include "SkMatrix44.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 private: 73 private:
74 SkMatrix44 fM0; 74 SkMatrix44 fM0;
75 SkMScalar fX, fY, fZ; 75 SkMScalar fX, fY, fZ;
76 typedef Matrix44Bench INHERITED; 76 typedef Matrix44Bench INHERITED;
77 }; 77 };
78 78
79 class InvertMatrix44Bench : public Matrix44Bench { 79 class InvertMatrix44Bench : public Matrix44Bench {
80 public: 80 public:
81 InvertMatrix44Bench(void* param) : INHERITED(param, "invert") { 81 InvertMatrix44Bench(void* param) : INHERITED(param, "invert") {
82 fM0.set(0, 0, -1.1); 82 fM0.set(0, 0, -1.1);
83 fM0.set(0, 1, 2.1); 83 fM0.set(0, 1, 2.1);
84 fM0.set(0, 2, -3.1); 84 fM0.set(0, 2, -3.1);
85 fM0.set(0, 3, 4.1); 85 fM0.set(0, 3, 4.1);
86 fM0.set(1, 0, 5.1); 86 fM0.set(1, 0, 5.1);
87 fM0.set(1, 1, -6.1); 87 fM0.set(1, 1, -6.1);
88 fM0.set(1, 2, 7.1); 88 fM0.set(1, 2, 7.1);
89 fM0.set(1, 3, 8.1); 89 fM0.set(1, 3, 8.1);
90 fM0.set(2, 0, -9.1); 90 fM0.set(2, 0, -9.1);
91 fM0.set(2, 1, 10.1); 91 fM0.set(2, 1, 10.1);
92 fM0.set(2, 2, 11.1); 92 fM0.set(2, 2, 11.1);
93 fM0.set(2, 3, -12.1); 93 fM0.set(2, 3, -12.1);
94 fM0.set(3, 0, -13.1); 94 fM0.set(3, 0, -13.1);
95 fM0.set(3, 1, 14.1); 95 fM0.set(3, 1, 14.1);
96 fM0.set(3, 2, -15.1); 96 fM0.set(3, 2, -15.1);
97 fM0.set(3, 3, 16.1); 97 fM0.set(3, 3, 16.1);
98 } 98 }
99 protected: 99 protected:
100 virtual void performTest() { 100 virtual void performTest() {
101 for (int i = 0; i < 10; ++i) { 101 for (int i = 0; i < 10; ++i) {
102 fM0.invert(&fM1); 102 fM0.invert(&fM1);
103 } 103 }
104 } 104 }
105 private: 105 private:
106 SkMatrix44 fM0, fM1; 106 SkMatrix44 fM0, fM1;
107 typedef Matrix44Bench INHERITED; 107 typedef Matrix44Bench INHERITED;
108 }; 108 };
109 109
110 class InvertAffineMatrix44Bench : public Matrix44Bench {
111 public:
112 InvertAffineMatrix44Bench(void* param) : INHERITED(param, "invertaffine") {
113 fM0.set(0, 0, -1.1);
114 fM0.set(0, 1, 2.1);
115 fM0.set(0, 2, -3.1);
116 fM0.set(0, 3, 4.1);
117 fM0.set(1, 0, 5.1);
118 fM0.set(1, 1, -6.1);
119 fM0.set(1, 2, 7.1);
120 fM0.set(1, 3, 8.1);
121 fM0.set(2, 0, -9.1);
122 fM0.set(2, 1, 10.1);
123 fM0.set(2, 2, 11.1);
124 fM0.set(2, 3, -12.1);
125 // bottom row (perspective component) remains (0, 0, 0, 1).
126 }
127 protected:
128 virtual void performTest() {
129 for (int i = 0; i < 10; ++i) {
130 fM0.invert(&fM1);
131 }
132 }
133 private:
134 SkMatrix44 fM0, fM1;
135 typedef Matrix44Bench INHERITED;
136 };
137
138 class InvertScaleTranslateMatrix44Bench : public Matrix44Bench {
139 public:
140 InvertScaleTranslateMatrix44Bench(void* param) : INHERITED(param, "invertsca letranslate") {
141 fM0.set(0, 0, -1.1);
142 fM0.set(0, 3, 4.1);
143
144 fM0.set(1, 1, -6.1);
145 fM0.set(1, 3, 8.1);
146
147 fM0.set(2, 2, 11.1);
148 fM0.set(2, 3, -12.1);
149 }
150 protected:
151 virtual void performTest() {
152 for (int i = 0; i < 10; ++i) {
153 fM0.invert(&fM1);
154 }
155 }
156 private:
157 SkMatrix44 fM0, fM1;
158 typedef Matrix44Bench INHERITED;
159 };
160
161 class InvertTranslateMatrix44Bench : public Matrix44Bench {
162 public:
163 InvertTranslateMatrix44Bench(void* param) : INHERITED(param, "inverttranslat e") {
164 fM0.set(0, 3, 4.1);
165 fM0.set(1, 3, 8.1);
166 fM0.set(2, 3, -12.1);
167 }
168 protected:
169 virtual void performTest() {
170 for (int i = 0; i < 10; ++i) {
171 fM0.invert(&fM1);
172 }
173 }
174 private:
175 SkMatrix44 fM0, fM1;
176 typedef Matrix44Bench INHERITED;
177 };
178
110 class PostScaleMatrix44Bench : public Matrix44Bench { 179 class PostScaleMatrix44Bench : public Matrix44Bench {
111 public: 180 public:
112 PostScaleMatrix44Bench(void* param) : INHERITED(param, "postscale") { 181 PostScaleMatrix44Bench(void* param) : INHERITED(param, "postscale") {
113 fX = fY = fZ = SkDoubleToMScalar(1.5); 182 fX = fY = fZ = SkDoubleToMScalar(1.5);
114 } 183 }
115 protected: 184 protected:
116 virtual void performTest() { 185 virtual void performTest() {
117 fM0.reset(); 186 fM0.reset();
118 for (int i = 0; i < 10; ++i) { 187 for (int i = 0; i < 10; ++i) {
119 fM0.postScale(fX, fY, fZ); 188 fM0.postScale(fX, fY, fZ);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 229 }
161 private: 230 private:
162 SkMatrix44 fMatrix; 231 SkMatrix44 fMatrix;
163 typedef Matrix44Bench INHERITED; 232 typedef Matrix44Bench INHERITED;
164 }; 233 };
165 234
166 DEF_BENCH( return new EqualsMatrix44Bench(p); ) 235 DEF_BENCH( return new EqualsMatrix44Bench(p); )
167 DEF_BENCH( return new PreScaleMatrix44Bench(p); ) 236 DEF_BENCH( return new PreScaleMatrix44Bench(p); )
168 DEF_BENCH( return new PostScaleMatrix44Bench(p); ) 237 DEF_BENCH( return new PostScaleMatrix44Bench(p); )
169 DEF_BENCH( return new InvertMatrix44Bench(p); ) 238 DEF_BENCH( return new InvertMatrix44Bench(p); )
239 DEF_BENCH( return new InvertAffineMatrix44Bench(p); )
240 DEF_BENCH( return new InvertScaleTranslateMatrix44Bench(p); )
241 DEF_BENCH( return new InvertTranslateMatrix44Bench(p); )
170 DEF_BENCH( return new SetConcatMatrix44Bench(p); ) 242 DEF_BENCH( return new SetConcatMatrix44Bench(p); )
171 DEF_BENCH( return new GetTypeMatrix44Bench(p); ) 243 DEF_BENCH( return new GetTypeMatrix44Bench(p); )
OLDNEW
« no previous file with comments | « no previous file | tests/Matrix44Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698