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

Unified Diff: bench/HalfBench.cpp

Issue 1686543003: skeleton for float <-> half optimized procs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bench Created 4 years, 10 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 | src/core/SkOpts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/HalfBench.cpp
diff --git a/bench/HalfBench.cpp b/bench/HalfBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1c76c572a4b7f6f883c7c681343061c04d4f4d4b
--- /dev/null
+++ b/bench/HalfBench.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Benchmark.h"
+#include "SkOpts.h"
+#include "SkRandom.h"
+
+struct FloatToHalfBench : public Benchmark {
+ const char* onGetName() override { return "float_to_half"; }
+ bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
+
+ void onDraw(int loops, SkCanvas* canvas) override {
+ SkRandom rand;
+ float fs[1023];
+ for (float& f : fs) {
+ f = rand.nextF();
+ }
+
+ uint16_t hs[1023];
+ while (loops --> 0) {
+ SkOpts::float_to_half(hs, fs, 1023);
+ }
+ }
+};
+DEF_BENCH(return new FloatToHalfBench;)
+
+struct HalfToFloatBench : public Benchmark {
+ const char* onGetName() override { return "half_to_float"; }
+ bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
+
+ void onDraw(int loops, SkCanvas* canvas) override {
+ SkRandom rand;
+ uint16_t hs[1023];
+ for (uint16_t& h : hs) {
+ h = rand.nextU16();
+ }
+
+ float fs[1023];
+ while (loops --> 0) {
+ SkOpts::half_to_float(fs, hs, 1023);
+ }
+ }
+};
+DEF_BENCH(return new HalfToFloatBench;)
« no previous file with comments | « no previous file | src/core/SkOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698