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

Unified Diff: bench/SwizzleBench.cpp

Issue 1564233002: test+bench new swizzle SkOpts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nah, that is dumb Created 4 years, 11 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 | tests/SwizzlerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SwizzleBench.cpp
diff --git a/bench/SwizzleBench.cpp b/bench/SwizzleBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..13b2003f9a8b10b253020746762f602c84e77588
--- /dev/null
+++ b/bench/SwizzleBench.cpp
@@ -0,0 +1,32 @@
+/*
+ * 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"
+
+class SwizzleBench : public Benchmark {
+public:
+ SwizzleBench(const char* name, SkOpts::Swizzle_8888_8888 fn) : fName(name), fFn(fn) {}
+
+ bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
+ const char* onGetName() override { return fName; }
+ void onDraw(int loops, SkCanvas*) override {
+ static const int K = 1023; // Arbitrary, but nice to be a non-power-of-two to trip up SIMD.
+ uint32_t dst[K], src[K];
+ while (loops --> 0) {
+ fFn(dst, src, K);
+ }
+ }
+private:
+ const char* fName;
+ SkOpts::Swizzle_8888_8888 fFn;
+};
+
+
+DEF_BENCH(return new SwizzleBench("SkOpts::premul_xxxa", SkOpts::premul_xxxa));
+DEF_BENCH(return new SwizzleBench("SkOpts::swaprb_xxxa", SkOpts::swaprb_xxxa));
+DEF_BENCH(return new SwizzleBench("SkOpts::premul_swaprb_xxxa", SkOpts::premul_swaprb_xxxa));
« no previous file with comments | « no previous file | tests/SwizzlerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698