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

Side by Side Diff: bench/Matrix44Bench.cpp

Issue 1146953003: Split SetConcatMatrix44Bench to cover both internal paths. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: slow -> general Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | 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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkMatrix44.h" 9 #include "SkMatrix44.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 } 242 }
243 private: 243 private:
244 SkMatrix44 fM0; 244 SkMatrix44 fM0;
245 SkMScalar fX, fY, fZ; 245 SkMScalar fX, fY, fZ;
246 typedef Matrix44Bench INHERITED; 246 typedef Matrix44Bench INHERITED;
247 }; 247 };
248 248
249 class SetConcatMatrix44Bench : public Matrix44Bench { 249 class SetConcatMatrix44Bench : public Matrix44Bench {
250 public: 250 public:
251 SetConcatMatrix44Bench() 251 // SkMatrix44::setConcat() has a fast path for matrices that are at most sca le+translate.
252 : INHERITED("setconcat") 252 SetConcatMatrix44Bench(bool fastPath)
253 : INHERITED(fastPath ? "setconcat_fast" : "setconcat_general")
253 , fM0(SkMatrix44::kUninitialized_Constructor) 254 , fM0(SkMatrix44::kUninitialized_Constructor)
254 , fM1(SkMatrix44::kUninitialized_Constructor) 255 , fM1(SkMatrix44::kUninitialized_Constructor)
255 , fM2(SkMatrix44::kUninitialized_Constructor) 256 , fM2(SkMatrix44::kUninitialized_Constructor)
256 { 257 {
257 fX = fY = fZ = SkDoubleToMScalar(1.5); 258 if (fastPath) {
258 fM1.setScale(fX, fY, fZ); 259 const SkMScalar v = SkDoubleToMScalar(1.5);
259 fM2.setTranslate(fX, fY, fZ); 260 fM1.setScale(v,v,v);
261 fM2.setTranslate(v,v,v);
262 } else {
263 SkRandom rand;
264 for (int x = 0; x < 4; x++) {
265 for (int y = 0; y < 4; y++) {
266 fM1.setFloat(x,y, rand.nextF());
267 fM2.setFloat(x,y, rand.nextF());
268 }}
269 }
260 } 270 }
261 protected: 271 protected:
262 virtual void performTest() { 272 virtual void performTest() {
263 fM0.reset(); // just to normalize this test with prescale/postscale 273 fM0.reset(); // just to normalize this test with prescale/postscale
264 for (int i = 0; i < 10; ++i) { 274 for (int i = 0; i < 10; ++i) {
265 fM0.setConcat(fM1, fM2); 275 fM0.setConcat(fM1, fM2);
266 } 276 }
267 } 277 }
268 private: 278 private:
269 SkMatrix44 fM0, fM1, fM2; 279 SkMatrix44 fM0, fM1, fM2;
270 SkMScalar fX, fY, fZ;
271 typedef Matrix44Bench INHERITED; 280 typedef Matrix44Bench INHERITED;
272 }; 281 };
273 282
274 class GetTypeMatrix44Bench : public Matrix44Bench { 283 class GetTypeMatrix44Bench : public Matrix44Bench {
275 public: 284 public:
276 GetTypeMatrix44Bench() 285 GetTypeMatrix44Bench()
277 : INHERITED("gettype") 286 : INHERITED("gettype")
278 , fMatrix(SkMatrix44::kIdentity_Constructor) 287 , fMatrix(SkMatrix44::kIdentity_Constructor)
279 {} 288 {}
280 protected: 289 protected:
(...skipping 12 matching lines...) Expand all
293 }; 302 };
294 303
295 DEF_BENCH( return new SetIdentityMatrix44Bench(); ) 304 DEF_BENCH( return new SetIdentityMatrix44Bench(); )
296 DEF_BENCH( return new EqualsMatrix44Bench(); ) 305 DEF_BENCH( return new EqualsMatrix44Bench(); )
297 DEF_BENCH( return new PreScaleMatrix44Bench(); ) 306 DEF_BENCH( return new PreScaleMatrix44Bench(); )
298 DEF_BENCH( return new PostScaleMatrix44Bench(); ) 307 DEF_BENCH( return new PostScaleMatrix44Bench(); )
299 DEF_BENCH( return new InvertMatrix44Bench(); ) 308 DEF_BENCH( return new InvertMatrix44Bench(); )
300 DEF_BENCH( return new InvertAffineMatrix44Bench(); ) 309 DEF_BENCH( return new InvertAffineMatrix44Bench(); )
301 DEF_BENCH( return new InvertScaleTranslateMatrix44Bench(); ) 310 DEF_BENCH( return new InvertScaleTranslateMatrix44Bench(); )
302 DEF_BENCH( return new InvertTranslateMatrix44Bench(); ) 311 DEF_BENCH( return new InvertTranslateMatrix44Bench(); )
303 DEF_BENCH( return new SetConcatMatrix44Bench(); ) 312 DEF_BENCH( return new SetConcatMatrix44Bench(true); )
313 DEF_BENCH( return new SetConcatMatrix44Bench(false); )
304 DEF_BENCH( return new GetTypeMatrix44Bench(); ) 314 DEF_BENCH( return new GetTypeMatrix44Bench(); )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698