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

Unified Diff: bench/MathBench.cpp

Issue 2012333003: Clean up SkFloatBits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: member Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; )
« no previous file with comments | « no previous file | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698