OLD | NEW |
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" |
11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
12 #include "SkString.h" | 12 #include "SkString.h" |
13 | 13 |
14 class MatrixBench : public Benchmark { | 14 class MatrixBench : public Benchmark { |
15 SkString fName; | 15 SkString fName; |
16 public: | 16 public: |
17 MatrixBench(const char name[]) { | 17 MatrixBench(const char name[]) { |
18 fName.printf("matrix_%s", name); | 18 fName.printf("matrix_%s", name); |
19 } | 19 } |
20 | 20 |
21 bool isSuitableFor(Backend backend) SK_OVERRIDE { | 21 bool isSuitableFor(Backend backend) override { |
22 return backend == kNonRendering_Backend; | 22 return backend == kNonRendering_Backend; |
23 } | 23 } |
24 | 24 |
25 virtual void performTest() = 0; | 25 virtual void performTest() = 0; |
26 | 26 |
27 protected: | 27 protected: |
28 virtual int mulLoopCount() const { return 1; } | 28 virtual int mulLoopCount() const { return 1; } |
29 | 29 |
30 virtual const char* onGetName() { | 30 virtual const char* onGetName() { |
31 return fName.c_str(); | 31 return fName.c_str(); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 public: | 283 public: |
284 MapPointsMatrixBench(const char name[], const SkMatrix& m, bool newWay) | 284 MapPointsMatrixBench(const char name[], const SkMatrix& m, bool newWay) |
285 : MatrixBench(name), fM(m), fNewWay(newWay) | 285 : MatrixBench(name), fM(m), fNewWay(newWay) |
286 { | 286 { |
287 SkRandom rand; | 287 SkRandom rand; |
288 for (int i = 0; i < N; ++i) { | 288 for (int i = 0; i < N; ++i) { |
289 fSrc[i].set(rand.nextSScalar1(), rand.nextSScalar1()); | 289 fSrc[i].set(rand.nextSScalar1(), rand.nextSScalar1()); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 void performTest() SK_OVERRIDE { | 293 void performTest() override { |
294 if (fNewWay) { | 294 if (fNewWay) { |
295 for (int i = 0; i < 1000000; ++i) { | 295 for (int i = 0; i < 1000000; ++i) { |
296 fM.mapPts(fDst, fSrc, N); | 296 fM.mapPts(fDst, fSrc, N); |
297 } | 297 } |
298 } else { | 298 } else { |
299 for (int i = 0; i < 1000000; ++i) { | 299 for (int i = 0; i < 1000000; ++i) { |
300 fM.mapPoints(fDst, fSrc, N); | 300 fM.mapPoints(fDst, fSrc, N); |
301 } | 301 } |
302 } | 302 } |
303 } | 303 } |
304 }; | 304 }; |
305 DEF_BENCH( return new MapPointsMatrixBench("mappts_ident0", make_ident(), false)
; ) | 305 DEF_BENCH( return new MapPointsMatrixBench("mappts_ident0", make_ident(), false)
; ) |
306 DEF_BENCH( return new MapPointsMatrixBench("mappts_ident1", make_ident(), true);
) | 306 DEF_BENCH( return new MapPointsMatrixBench("mappts_ident1", make_ident(), true);
) |
307 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans0", make_trans(), false)
; ) | 307 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans0", make_trans(), false)
; ) |
308 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans1", make_trans(), true);
) | 308 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans1", make_trans(), true);
) |
309 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale0", make_scale(), false)
; ) | 309 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale0", make_scale(), false)
; ) |
310 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale1", make_scale(), true);
) | 310 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale1", make_scale(), true);
) |
311 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine0", make_afine(), false)
; ) | 311 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine0", make_afine(), false)
; ) |
312 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine1", make_afine(), true);
) | 312 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine1", make_afine(), true);
) |
313 | 313 |
OLD | NEW |