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 26 matching lines...) Expand all Loading... |
37 void onDraw(const int loops, SkCanvas* canvas) override { | 37 void onDraw(const 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 != NULL); // It'd break this bench if the tree took
ownership of rects. | 47 SkASSERT(rects != nullptr); // It'd break this bench if the tree to
ok ownership of rects. |
48 } | 48 } |
49 } | 49 } |
50 private: | 50 private: |
51 MakeRectProc fProc; | 51 MakeRectProc fProc; |
52 SkString fName; | 52 SkString fName; |
53 typedef Benchmark INHERITED; | 53 typedef Benchmark INHERITED; |
54 }; | 54 }; |
55 | 55 |
56 // Time how long it takes to perform queries on an R-Tree. | 56 // Time how long it takes to perform queries on an R-Tree. |
57 class RTreeQueryBench : public Benchmark { | 57 class RTreeQueryBench : public Benchmark { |
(...skipping 71 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 |