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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkCanvas.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Benchmark.h"
9 #include "SkCanvas.h"
10 #include "SkRandom.h"
11
12 class QuickRejectBench : public Benchmark {
13 enum { N = 1000000 };
14 float fFloats[N];
15 int fInts [N];
16
17 const char* onGetName() override { return "quick_reject"; }
18 bool isSuitableFor(Backend backend) override { return backend != kNonRenderi ng_Backend; }
19
20 void onDelayedSetup() override {
21 SkRandom rand;
22 for (int i = 0; i < N; ++i) {
23 fFloats[i] = 300.0f * (rand.nextSScalar1() + 0.5f);
24 }
25 }
26
27 void onDraw(int loops, SkCanvas* canvas) override {
28 while (loops --> 0) {
29 for (int i = 0; i < N - 4; i++) {
30 if (canvas->quickReject(*(SkRect*)(fFloats+i))) {
31 fInts[i] = 11;
32 } else {
33 fInts[i] = 24;
34 }
35 }
36 }
37 }
38 };
39 DEF_BENCH( return new QuickRejectBench; )
40
41 class ConcatBench : public Benchmark {
42 SkMatrix fMatrix;
43
44 const char* onGetName() override { return "concat"; }
45 bool isSuitableFor(Backend backend) override { return backend != kNonRenderi ng_Backend; }
46
47 void onDelayedSetup() override {
48 SkRandom r;
49 fMatrix.setScale(5.0f, 5.0f);
50 fMatrix.setTranslateX(10.0f);
51 fMatrix.setTranslateY(10.0f);
52 }
53
54 void onDraw(int loops, SkCanvas* canvas) override {
55 while (loops --> 0) {
56 canvas->setMatrix(SkMatrix::MakeScale(3.0f));
57 canvas->concat(fMatrix);
58 }
59 }
60 };
61 DEF_BENCH( return new ConcatBench; )
OLDNEW
« 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