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

Side by Side Diff: bench/MatrixBench.cpp

Issue 1045493002: use Sk4f for matrix math (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | include/core/SkMatrix.h » ('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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkMatrix.h" 9 #include "SkMatrix.h"
10 #include "SkMatrixUtils.h" 10 #include "SkMatrixUtils.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 static SkMatrix make_scale() { SkMatrix m(make_trans()); m.postScale(1.5f, 0.5f) ; return m; } 271 static SkMatrix make_scale() { SkMatrix m(make_trans()); m.postScale(1.5f, 0.5f) ; return m; }
272 static SkMatrix make_afine() { SkMatrix m(make_trans()); m.postRotate(15); retur n m; } 272 static SkMatrix make_afine() { SkMatrix m(make_trans()); m.postRotate(15); retur n m; }
273 273
274 class MapPointsMatrixBench : public MatrixBench { 274 class MapPointsMatrixBench : public MatrixBench {
275 protected: 275 protected:
276 SkMatrix fM; 276 SkMatrix fM;
277 enum { 277 enum {
278 N = 32 278 N = 32
279 }; 279 };
280 SkPoint fSrc[N], fDst[N]; 280 SkPoint fSrc[N], fDst[N];
281 const bool fNewWay;
282 public: 281 public:
283 MapPointsMatrixBench(const char name[], const SkMatrix& m, bool newWay) 282 MapPointsMatrixBench(const char name[], const SkMatrix& m)
284 : MatrixBench(name), fM(m), fNewWay(newWay) 283 : MatrixBench(name), fM(m)
285 { 284 {
286 SkRandom rand; 285 SkRandom rand;
287 for (int i = 0; i < N; ++i) { 286 for (int i = 0; i < N; ++i) {
288 fSrc[i].set(rand.nextSScalar1(), rand.nextSScalar1()); 287 fSrc[i].set(rand.nextSScalar1(), rand.nextSScalar1());
289 } 288 }
290 } 289 }
291 290
292 void performTest() override { 291 void performTest() override {
293 if (fNewWay) { 292 for (int i = 0; i < 1000000; ++i) {
294 for (int i = 0; i < 1000000; ++i) { 293 fM.mapPoints(fDst, fSrc, N);
295 fM.mapPts(fDst, fSrc, N);
296 }
297 } else {
298 for (int i = 0; i < 1000000; ++i) {
299 fM.mapPoints(fDst, fSrc, N);
300 }
301 } 294 }
302 } 295 }
303 }; 296 };
304 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans0", make_trans(), false) ; ) 297 DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I()); )
305 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans1", make_trans(), true); ) 298 DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); )
306 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale0", make_scale(), false) ; ) 299 DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); )
307 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale1", make_scale(), true); ) 300 DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); )
308 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine0", make_afine(), false) ; )
309 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine1", make_afine(), true); )
310 301
OLDNEW
« no previous file with comments | « no previous file | include/core/SkMatrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698