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

Side by Side Diff: bench/MatrixBench.cpp

Issue 2111703002: speed up maprect for scale+trans case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: apply comments from #14 Created 4 years, 5 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 #include "Benchmark.h" 7 #include "Benchmark.h"
8 #include "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "SkMatrixUtils.h" 9 #include "SkMatrixUtils.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void performTest() override { 290 void performTest() override {
291 for (int i = 0; i < 1000000; ++i) { 291 for (int i = 0; i < 1000000; ++i) {
292 fM.mapPoints(fDst, fSrc, N); 292 fM.mapPoints(fDst, fSrc, N);
293 } 293 }
294 } 294 }
295 }; 295 };
296 DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I()); ) 296 DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I()); )
297 DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); ) 297 DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); )
298 DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); ) 298 DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); )
299 DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); ) 299 DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); )
300
301 ///////////////////////////////////////////////////////////////////////////////
302
303 class MapRectMatrixBench : public MatrixBench {
304 SkMatrix fM;
305 SkRect fR;
306 bool fScaleTrans;
307
308 enum { MEGA_LOOP = 1000 * 1000 };
309 public:
310 MapRectMatrixBench(const char name[], bool scale_trans)
311 : MatrixBench(name), fScaleTrans(scale_trans)
312 {
313 fM.setScale(2, 3);
314 fM.postTranslate(1, 2);
315
316 fR.set(10, 10, 100, 200);
317 }
318
319 void performTest() override {
320 SkRect dst;
321 if (fScaleTrans) {
322 for (int i = 0; i < MEGA_LOOP; ++i) {
323 fM.mapRectScaleTranslate(&dst, fR);
324 }
325 } else {
326 for (int i = 0; i < MEGA_LOOP; ++i) {
327 fM.mapRect(&dst, fR);
328 }
329 }
330 }
331 };
332 DEF_BENCH( return new MapRectMatrixBench("maprect", false); )
333 DEF_BENCH( return new MapRectMatrixBench("maprectscaletrans", true); )
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