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

Side by Side Diff: bench/RTreeBench.cpp

Issue 622773003: Demote getCount, getDepth, and clear to RTree-only methods. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: dox Created 6 years, 2 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 | src/core/SkBBoxHierarchy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "Benchmark.h" 9 #include "Benchmark.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkRTree.h" 11 #include "SkRTree.h"
12 #include "SkRandom.h" 12 #include "SkRandom.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 14
15 // confine rectangles to a smallish area, so queries generally hit something, an d overlap occurs: 15 // confine rectangles to a smallish area, so queries generally hit something, an d overlap occurs:
16 static const SkScalar GENERATE_EXTENTS = 1000.0f; 16 static const SkScalar GENERATE_EXTENTS = 1000.0f;
17 static const int NUM_BUILD_RECTS = 500; 17 static const int NUM_BUILD_RECTS = 500;
18 static const int NUM_QUERY_RECTS = 5000; 18 static const int NUM_QUERY_RECTS = 5000;
19 static const int GRID_WIDTH = 100; 19 static const int GRID_WIDTH = 100;
20 20
21 typedef SkRect (*MakeRectProc)(SkRandom&, int, int); 21 typedef SkRect (*MakeRectProc)(SkRandom&, int, int);
22 22
23 // Time how long it takes to build an R-Tree either bulk-loaded or not 23 // Time how long it takes to build an R-Tree either bulk-loaded or not
24 class RTreeBuildBench : public Benchmark { 24 class RTreeBuildBench : public Benchmark {
25 public: 25 public:
26 RTreeBuildBench(const char* name, MakeRectProc proc, bool bulkLoad, 26 RTreeBuildBench(const char* name, MakeRectProc proc, bool bulkLoad,
27 SkBBoxHierarchy* tree) 27 SkRTree* tree)
28 : fTree(tree) 28 : fTree(tree)
29 , fProc(proc) 29 , fProc(proc)
30 , fBulkLoad(bulkLoad) { 30 , fBulkLoad(bulkLoad) {
31 fName.append("rtree_"); 31 fName.append("rtree_");
32 fName.append(name); 32 fName.append(name);
33 fName.append("_build"); 33 fName.append("_build");
34 if (fBulkLoad) { 34 if (fBulkLoad) {
35 fName.append("_bulk"); 35 fName.append("_bulk");
36 } 36 }
37 } 37 }
(...skipping 13 matching lines...) Expand all
51 SkRandom rand; 51 SkRandom rand;
52 for (int i = 0; i < loops; ++i) { 52 for (int i = 0; i < loops; ++i) {
53 for (int j = 0; j < NUM_BUILD_RECTS; ++j) { 53 for (int j = 0; j < NUM_BUILD_RECTS; ++j) {
54 fTree->insert(j, fProc(rand, j, NUM_BUILD_RECTS), fBulkLoad); 54 fTree->insert(j, fProc(rand, j, NUM_BUILD_RECTS), fBulkLoad);
55 } 55 }
56 fTree->flushDeferredInserts(); 56 fTree->flushDeferredInserts();
57 fTree->clear(); 57 fTree->clear();
58 } 58 }
59 } 59 }
60 private: 60 private:
61 SkBBoxHierarchy* fTree; 61 SkRTree* fTree;
62 MakeRectProc fProc; 62 MakeRectProc fProc;
63 SkString fName; 63 SkString fName;
64 bool fBulkLoad; 64 bool fBulkLoad;
65 typedef Benchmark INHERITED; 65 typedef Benchmark INHERITED;
66 }; 66 };
67 67
68 // Time how long it takes to perform queries on an R-Tree, bulk-loaded or not 68 // Time how long it takes to perform queries on an R-Tree, bulk-loaded or not
69 class RTreeQueryBench : public Benchmark { 69 class RTreeQueryBench : public Benchmark {
70 public: 70 public:
71 enum QueryType { 71 enum QueryType {
72 kSmall_QueryType, // small queries 72 kSmall_QueryType, // small queries
73 kLarge_QueryType, // large queries 73 kLarge_QueryType, // large queries
74 kRandom_QueryType,// randomly sized queries 74 kRandom_QueryType,// randomly sized queries
75 kFull_QueryType // queries that cover everything 75 kFull_QueryType // queries that cover everything
76 }; 76 };
77 77
78 RTreeQueryBench(const char* name, MakeRectProc proc, bool bulkLoad, 78 RTreeQueryBench(const char* name, MakeRectProc proc, bool bulkLoad,
79 QueryType q, SkBBoxHierarchy* tree) 79 QueryType q, SkRTree* tree)
80 : fTree(tree) 80 : fTree(tree)
81 , fProc(proc) 81 , fProc(proc)
82 , fBulkLoad(bulkLoad) 82 , fBulkLoad(bulkLoad)
83 , fQuery(q) { 83 , fQuery(q) {
84 fName.append("rtree_"); 84 fName.append("rtree_");
85 fName.append(name); 85 fName.append(name);
86 fName.append("_query"); 86 fName.append("_query");
87 if (fBulkLoad) { 87 if (fBulkLoad) {
88 fName.append("_bulk"); 88 fName.append("_bulk");
89 } 89 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 &make_concentric_rects_increasing, true, SkRTree::Create(5 , 16, 1, false))); 257 &make_concentric_rects_increasing, true, SkRTree::Create(5 , 16, 1, false)));
258 ) 258 )
259 DEF_BENCH( 259 DEF_BENCH(
260 return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects_inc reasing, true, 260 return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects_inc reasing, true,
261 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16) )); 261 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16) ));
262 ) 262 )
263 DEF_BENCH( 263 DEF_BENCH(
264 return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)concentric", &make_concentric _rects_increasing, true, 264 return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)concentric", &make_concentric _rects_increasing, true,
265 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false))); 265 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false)));
266 ) 266 )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBBoxHierarchy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698