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

Side by Side Diff: bench/RTreeBench.cpp

Issue 617393004: BBHs: void* data -> unsigned data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: The rest 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 | gyp/tests.gypi » ('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"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 fTree->unref(); 44 fTree->unref();
45 } 45 }
46 protected: 46 protected:
47 virtual const char* onGetName() SK_OVERRIDE { 47 virtual const char* onGetName() SK_OVERRIDE {
48 return fName.c_str(); 48 return fName.c_str();
49 } 49 }
50 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 50 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
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(reinterpret_cast<void*>(j), fProc(rand, j, NUM_BUI LD_RECTS), 54 fTree->insert(j, fProc(rand, j, NUM_BUILD_RECTS), fBulkLoad);
55 fBulkLoad);
56 } 55 }
57 fTree->flushDeferredInserts(); 56 fTree->flushDeferredInserts();
58 fTree->clear(); 57 fTree->clear();
59 } 58 }
60 } 59 }
61 private: 60 private:
62 SkBBoxHierarchy* fTree; 61 SkBBoxHierarchy* fTree;
63 MakeRectProc fProc; 62 MakeRectProc fProc;
64 SkString fName; 63 SkString fName;
65 bool fBulkLoad; 64 bool fBulkLoad;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 virtual ~RTreeQueryBench() { 96 virtual ~RTreeQueryBench() {
98 fTree->unref(); 97 fTree->unref();
99 } 98 }
100 protected: 99 protected:
101 virtual const char* onGetName() SK_OVERRIDE { 100 virtual const char* onGetName() SK_OVERRIDE {
102 return fName.c_str(); 101 return fName.c_str();
103 } 102 }
104 virtual void onPreDraw() SK_OVERRIDE { 103 virtual void onPreDraw() SK_OVERRIDE {
105 SkRandom rand; 104 SkRandom rand;
106 for (int j = 0; j < NUM_QUERY_RECTS; ++j) { 105 for (int j = 0; j < NUM_QUERY_RECTS; ++j) {
107 fTree->insert(reinterpret_cast<void*>(j), 106 fTree->insert(j, fProc(rand, j, NUM_QUERY_RECTS), fBulkLoad);
108 fProc(rand, j, NUM_QUERY_RECTS),
109 fBulkLoad);
110 } 107 }
111 fTree->flushDeferredInserts(); 108 fTree->flushDeferredInserts();
112 } 109 }
113 110
114 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 111 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
115 SkRandom rand; 112 SkRandom rand;
116 for (int i = 0; i < loops; ++i) { 113 for (int i = 0; i < loops; ++i) {
117 SkTDArray<void*> hits; 114 SkTDArray<unsigned> hits;
118 SkRect query; 115 SkRect query;
119 switch(fQuery) { 116 switch(fQuery) {
120 case kSmall_QueryType: 117 case kSmall_QueryType:
121 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS); 118 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS);
122 query.fTop = rand.nextRangeF(0, GENERATE_EXTENTS); 119 query.fTop = rand.nextRangeF(0, GENERATE_EXTENTS);
123 query.fRight = query.fLeft + (GENERATE_EXTENTS / 20); 120 query.fRight = query.fLeft + (GENERATE_EXTENTS / 20);
124 query.fBottom = query.fTop + (GENERATE_EXTENTS / 20); 121 query.fBottom = query.fTop + (GENERATE_EXTENTS / 20);
125 break; 122 break;
126 case kLarge_QueryType: 123 case kLarge_QueryType:
127 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS); 124 query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 &make_concentric_rects_increasing, true, SkRTree::Create(5 , 16, 1, false))); 257 &make_concentric_rects_increasing, true, SkRTree::Create(5 , 16, 1, false)));
261 ) 258 )
262 DEF_BENCH( 259 DEF_BENCH(
263 return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects_inc reasing, true, 260 return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects_inc reasing, true,
264 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16) )); 261 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16) ));
265 ) 262 )
266 DEF_BENCH( 263 DEF_BENCH(
267 return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)concentric", &make_concentric _rects_increasing, true, 264 return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)concentric", &make_concentric _rects_increasing, true,
268 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false))); 265 RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false)));
269 ) 266 )
OLDNEW
« no previous file with comments | « no previous file | gyp/tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698