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

Unified Diff: bench/QuickRejectBench.cpp

Issue 2225393002: Optimized implementation of quickReject() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix NX_NOSIMD and Chrome assert Created 4 years, 4 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 | include/core/SkCanvas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/QuickRejectBench.cpp
diff --git a/bench/QuickRejectBench.cpp b/bench/QuickRejectBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1feade41f5d4264c61b1cf334ecd6f278e517a3d
--- /dev/null
+++ b/bench/QuickRejectBench.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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 "SkCanvas.h"
+#include "SkRandom.h"
+
+class QuickRejectBench : public Benchmark {
+ enum { N = 1000000 };
+ float fFloats[N];
+ int fInts [N];
+
+ const char* onGetName() override { return "quick_reject"; }
+ bool isSuitableFor(Backend backend) override { return backend != kNonRendering_Backend; }
+
+ void onDelayedSetup() override {
+ SkRandom rand;
+ for (int i = 0; i < N; ++i) {
+ fFloats[i] = 300.0f * (rand.nextSScalar1() + 0.5f);
+ }
+ }
+
+ void onDraw(int loops, SkCanvas* canvas) override {
+ while (loops --> 0) {
+ for (int i = 0; i < N - 4; i++) {
+ if (canvas->quickReject(*(SkRect*)(fFloats+i))) {
+ fInts[i] = 11;
+ } else {
+ fInts[i] = 24;
+ }
+ }
+ }
+ }
+};
+DEF_BENCH( return new QuickRejectBench; )
+
+class ConcatBench : public Benchmark {
+ SkMatrix fMatrix;
+
+ const char* onGetName() override { return "concat"; }
+ bool isSuitableFor(Backend backend) override { return backend != kNonRendering_Backend; }
+
+ void onDelayedSetup() override {
+ SkRandom r;
+ fMatrix.setScale(5.0f, 5.0f);
+ fMatrix.setTranslateX(10.0f);
+ fMatrix.setTranslateY(10.0f);
+ }
+
+ void onDraw(int loops, SkCanvas* canvas) override {
+ while (loops --> 0) {
+ canvas->setMatrix(SkMatrix::MakeScale(3.0f));
+ canvas->concat(fMatrix);
+ }
+ }
+};
+DEF_BENCH( return new ConcatBench; )
« no previous file with comments | « no previous file | include/core/SkCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698