| Index: bench/MathBench.cpp
|
| diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
|
| index 77ba2f04be78ae62f91eb2c90c834ddc5137f60b..877d42663cb2bbdb4781f0e6941bc73ccddeb133 100644
|
| --- a/bench/MathBench.cpp
|
| +++ b/bench/MathBench.cpp
|
| @@ -607,3 +607,29 @@ DEF_BENCH( return new CLZBench(true); )
|
| DEF_BENCH( return new NormalizeBench(); )
|
|
|
| DEF_BENCH( return new FixedMathBench(); )
|
| +
|
| +
|
| +struct FloatToIntBench : public Benchmark {
|
| + enum { N = 1000000 };
|
| + float fFloats[N];
|
| + int fInts [N];
|
| +
|
| + const char* onGetName() override { return "float_to_int"; }
|
| + bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
|
| +
|
| + void onDelayedSetup() override {
|
| + const auto f32 = 4294967296.0f;
|
| + for (int i = 0; i < N; ++i) {
|
| + fFloats[i] = -f32 + i*(2*f32/N);
|
| + }
|
| + }
|
| +
|
| + void onDraw(int loops, SkCanvas*) override {
|
| + while (loops --> 0) {
|
| + for (int i = 0; i < N; i++) {
|
| + fInts[i] = SkFloatToIntFloor(fFloats[i]);
|
| + }
|
| + }
|
| + }
|
| +};
|
| +DEF_BENCH( return new FloatToIntBench; )
|
|
|