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

Side by Side Diff: bench/RTreeBench.cpp

Issue 347823004: Remove Sk prefix from some bench classes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkGMBench -> GMBench Created 6 years, 6 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 | « bench/QuadTreeBench.cpp ('k') | bench/ReadPixBench.cpp » ('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 "SkBenchmark.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 int GENERATE_EXTENTS = 1000; 16 static const int GENERATE_EXTENTS = 1000;
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 SkIRect (*MakeRectProc)(SkRandom&, int, int); 21 typedef SkIRect (*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 SkBenchmark { 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 SkBBoxHierarchy* 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) {
(...skipping 21 matching lines...) Expand all
56 } 56 }
57 fTree->flushDeferredInserts(); 57 fTree->flushDeferredInserts();
58 fTree->clear(); 58 fTree->clear();
59 } 59 }
60 } 60 }
61 private: 61 private:
62 SkBBoxHierarchy* fTree; 62 SkBBoxHierarchy* fTree;
63 MakeRectProc fProc; 63 MakeRectProc fProc;
64 SkString fName; 64 SkString fName;
65 bool fBulkLoad; 65 bool fBulkLoad;
66 typedef SkBenchmark INHERITED; 66 typedef Benchmark INHERITED;
67 }; 67 };
68 68
69 // Time how long it takes to perform queries on an R-Tree, bulk-loaded or not 69 // Time how long it takes to perform queries on an R-Tree, bulk-loaded or not
70 class RTreeQueryBench : public SkBenchmark { 70 class RTreeQueryBench : public Benchmark {
71 public: 71 public:
72 enum QueryType { 72 enum QueryType {
73 kSmall_QueryType, // small queries 73 kSmall_QueryType, // small queries
74 kLarge_QueryType, // large queries 74 kLarge_QueryType, // large queries
75 kRandom_QueryType,// randomly sized queries 75 kRandom_QueryType,// randomly sized queries
76 kFull_QueryType // queries that cover everything 76 kFull_QueryType // queries that cover everything
77 }; 77 };
78 78
79 RTreeQueryBench(const char* name, MakeRectProc proc, bool bulkLoad, 79 RTreeQueryBench(const char* name, MakeRectProc proc, bool bulkLoad,
80 QueryType q, SkBBoxHierarchy* tree) 80 QueryType q, SkBBoxHierarchy* tree)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 }; 145 };
146 fTree->search(query, &hits); 146 fTree->search(query, &hits);
147 } 147 }
148 } 148 }
149 private: 149 private:
150 SkBBoxHierarchy* fTree; 150 SkBBoxHierarchy* fTree;
151 MakeRectProc fProc; 151 MakeRectProc fProc;
152 SkString fName; 152 SkString fName;
153 bool fBulkLoad; 153 bool fBulkLoad;
154 QueryType fQuery; 154 QueryType fQuery;
155 typedef SkBenchmark INHERITED; 155 typedef Benchmark INHERITED;
156 }; 156 };
157 157
158 static inline SkIRect make_concentric_rects_increasing(SkRandom&, int index, int numRects) { 158 static inline SkIRect make_concentric_rects_increasing(SkRandom&, int index, int numRects) {
159 SkIRect out = {0, 0, index + 1, index + 1}; 159 SkIRect out = {0, 0, index + 1, index + 1};
160 return out; 160 return out;
161 } 161 }
162 162
163 static inline SkIRect make_XYordered_rects(SkRandom& rand, int index, int numRec ts) { 163 static inline SkIRect make_XYordered_rects(SkRandom& rand, int index, int numRec ts) {
164 SkIRect out; 164 SkIRect out;
165 out.fLeft = index % GRID_WIDTH; 165 out.fLeft = index % GRID_WIDTH;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 &make_concentric_rects_increasing, true, SkRTree::Create(5 , 16, 1, false))); 260 &make_concentric_rects_increasing, true, SkRTree::Create(5 , 16, 1, false)));
261 ) 261 )
262 DEF_BENCH( 262 DEF_BENCH(
263 return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects_inc reasing, true, 263 return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects_inc reasing, true,
264 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16) )); 264 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16) ));
265 ) 265 )
266 DEF_BENCH( 266 DEF_BENCH(
267 return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)concentric", &make_concentric _rects_increasing, true, 267 return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)concentric", &make_concentric _rects_increasing, true,
268 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false))); 268 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false)));
269 ) 269 )
OLDNEW
« no previous file with comments | « bench/QuadTreeBench.cpp ('k') | bench/ReadPixBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698