OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFixed.h" | 10 #include "SkFixed.h" |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 600 |
601 DEF_BENCH( return new FloorBench(false); ) | 601 DEF_BENCH( return new FloorBench(false); ) |
602 DEF_BENCH( return new FloorBench(true); ) | 602 DEF_BENCH( return new FloorBench(true); ) |
603 | 603 |
604 DEF_BENCH( return new CLZBench(false); ) | 604 DEF_BENCH( return new CLZBench(false); ) |
605 DEF_BENCH( return new CLZBench(true); ) | 605 DEF_BENCH( return new CLZBench(true); ) |
606 | 606 |
607 DEF_BENCH( return new NormalizeBench(); ) | 607 DEF_BENCH( return new NormalizeBench(); ) |
608 | 608 |
609 DEF_BENCH( return new FixedMathBench(); ) | 609 DEF_BENCH( return new FixedMathBench(); ) |
| 610 |
| 611 |
| 612 struct FloatToIntBench : public Benchmark { |
| 613 enum { N = 1000000 }; |
| 614 float fFloats[N]; |
| 615 int fInts [N]; |
| 616 |
| 617 const char* onGetName() override { return "float_to_int"; } |
| 618 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } |
| 619 |
| 620 void onDelayedSetup() override { |
| 621 const auto f32 = 4294967296.0f; |
| 622 for (int i = 0; i < N; ++i) { |
| 623 fFloats[i] = -f32 + i*(2*f32/N); |
| 624 } |
| 625 } |
| 626 |
| 627 void onDraw(int loops, SkCanvas*) override { |
| 628 while (loops --> 0) { |
| 629 for (int i = 0; i < N; i++) { |
| 630 fInts[i] = SkFloatToIntFloor(fFloats[i]); |
| 631 } |
| 632 } |
| 633 } |
| 634 }; |
| 635 DEF_BENCH( return new FloatToIntBench; ) |
OLD | NEW |