OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkRTree.h" | 10 #include "SkRTree.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 bool isSuitableFor(Backend backend) override { | 29 bool isSuitableFor(Backend backend) override { |
30 return backend == kNonRendering_Backend; | 30 return backend == kNonRendering_Backend; |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 const char* onGetName() override { | 34 const char* onGetName() override { |
35 return fName.c_str(); | 35 return fName.c_str(); |
36 } | 36 } |
37 void onDraw(const int loops, SkCanvas* canvas) override { | 37 void onDraw(int loops, SkCanvas* canvas) override { |
38 SkRandom rand; | 38 SkRandom rand; |
39 SkAutoTMalloc<SkRect> rects(NUM_BUILD_RECTS); | 39 SkAutoTMalloc<SkRect> rects(NUM_BUILD_RECTS); |
40 for (int i = 0; i < NUM_BUILD_RECTS; ++i) { | 40 for (int i = 0; i < NUM_BUILD_RECTS; ++i) { |
41 rects[i] = fProc(rand, i, NUM_BUILD_RECTS); | 41 rects[i] = fProc(rand, i, NUM_BUILD_RECTS); |
42 } | 42 } |
43 | 43 |
44 for (int i = 0; i < loops; ++i) { | 44 for (int i = 0; i < loops; ++i) { |
45 SkRTree tree; | 45 SkRTree tree; |
46 tree.insert(rects.get(), NUM_BUILD_RECTS); | 46 tree.insert(rects.get(), NUM_BUILD_RECTS); |
47 SkASSERT(rects != nullptr); // It'd break this bench if the tree to
ok ownership of rects. | 47 SkASSERT(rects != nullptr); // It'd break this bench if the tree to
ok ownership of rects. |
(...skipping 21 matching lines...) Expand all Loading... |
69 } | 69 } |
70 void onDelayedSetup() override { | 70 void onDelayedSetup() override { |
71 SkRandom rand; | 71 SkRandom rand; |
72 SkAutoTMalloc<SkRect> rects(NUM_QUERY_RECTS); | 72 SkAutoTMalloc<SkRect> rects(NUM_QUERY_RECTS); |
73 for (int i = 0; i < NUM_QUERY_RECTS; ++i) { | 73 for (int i = 0; i < NUM_QUERY_RECTS; ++i) { |
74 rects[i] = fProc(rand, i, NUM_QUERY_RECTS); | 74 rects[i] = fProc(rand, i, NUM_QUERY_RECTS); |
75 } | 75 } |
76 fTree.insert(rects.get(), NUM_QUERY_RECTS); | 76 fTree.insert(rects.get(), NUM_QUERY_RECTS); |
77 } | 77 } |
78 | 78 |
79 void onDraw(const int loops, SkCanvas* canvas) override { | 79 void onDraw(int loops, SkCanvas* canvas) override { |
80 SkRandom rand; | 80 SkRandom rand; |
81 for (int i = 0; i < loops; ++i) { | 81 for (int i = 0; i < loops; ++i) { |
82 SkTDArray<int> hits; | 82 SkTDArray<int> hits; |
83 SkRect query; | 83 SkRect query; |
84 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS); | 84 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS); |
85 query.fTop = rand.nextRangeF(0, GENERATE_EXTENTS); | 85 query.fTop = rand.nextRangeF(0, GENERATE_EXTENTS); |
86 query.fRight = query.fLeft + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); | 86 query.fRight = query.fLeft + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); |
87 query.fBottom = query.fTop + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); | 87 query.fBottom = query.fTop + 1 + rand.nextRangeF(0, GENERATE_EXTENT
S/2); |
88 fTree.search(query, &hits); | 88 fTree.search(query, &hits); |
89 } | 89 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 DEF_BENCH(return new RTreeBuildBench("XY", &make_XYordered_rects)); | 130 DEF_BENCH(return new RTreeBuildBench("XY", &make_XYordered_rects)); |
131 DEF_BENCH(return new RTreeBuildBench("YX", &make_YXordered_rects)); | 131 DEF_BENCH(return new RTreeBuildBench("YX", &make_YXordered_rects)); |
132 DEF_BENCH(return new RTreeBuildBench("random", &make_random_rects)); | 132 DEF_BENCH(return new RTreeBuildBench("random", &make_random_rects)); |
133 DEF_BENCH(return new RTreeBuildBench("concentric", &make_concentric_rects)); | 133 DEF_BENCH(return new RTreeBuildBench("concentric", &make_concentric_rects)); |
134 | 134 |
135 DEF_BENCH(return new RTreeQueryBench("XY", &make_XYordered_rects)); | 135 DEF_BENCH(return new RTreeQueryBench("XY", &make_XYordered_rects)); |
136 DEF_BENCH(return new RTreeQueryBench("YX", &make_YXordered_rects)); | 136 DEF_BENCH(return new RTreeQueryBench("YX", &make_YXordered_rects)); |
137 DEF_BENCH(return new RTreeQueryBench("random", &make_random_rects)); | 137 DEF_BENCH(return new RTreeQueryBench("random", &make_random_rects)); |
138 DEF_BENCH(return new RTreeQueryBench("concentric", &make_concentric_rects)); | 138 DEF_BENCH(return new RTreeQueryBench("concentric", &make_concentric_rects)); |
OLD | NEW |