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

Side by Side Diff: bench/RTreeBench.cpp

Issue 23478013: Major bench refactoring. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: merge with head agani Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « bench/PremulAndUnpremulAlphaOpsBench.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 "SkBenchmark.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 NUM_QUERIES = 1000;
20 static const int GRID_WIDTH = 100; 19 static const int GRID_WIDTH = 100;
21 20
22 typedef SkIRect (*MakeRectProc)(SkRandom&, int, int); 21 typedef SkIRect (*MakeRectProc)(SkRandom&, int, int);
23 22
24 // 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
25 class BBoxBuildBench : public SkBenchmark { 24 class BBoxBuildBench : public SkBenchmark {
26 public: 25 public:
27 BBoxBuildBench(void* param, const char* name, MakeRectProc proc, bool bulkLo ad, 26 BBoxBuildBench(void* param, const char* name, MakeRectProc proc, bool bulkLo ad,
28 SkBBoxHierarchy* tree) 27 SkBBoxHierarchy* tree)
29 : INHERITED(param) 28 : INHERITED(param)
(...skipping 10 matching lines...) Expand all
40 } 39 }
41 virtual ~BBoxBuildBench() { 40 virtual ~BBoxBuildBench() {
42 fTree->unref(); 41 fTree->unref();
43 } 42 }
44 protected: 43 protected:
45 virtual const char* onGetName() SK_OVERRIDE { 44 virtual const char* onGetName() SK_OVERRIDE {
46 return fName.c_str(); 45 return fName.c_str();
47 } 46 }
48 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 47 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
49 SkRandom rand; 48 SkRandom rand;
50 for (int i = 0; i < SkBENCHLOOP(100); ++i) { 49 for (int i = 0; i < this->getLoops(); ++i) {
51 for (int j = 0; j < NUM_BUILD_RECTS; ++j) { 50 for (int j = 0; j < NUM_BUILD_RECTS; ++j) {
52 fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j, NUM_BUI LD_RECTS), 51 fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j, NUM_BUI LD_RECTS),
53 fBulkLoad); 52 fBulkLoad);
54 } 53 }
55 fTree->flushDeferredInserts(); 54 fTree->flushDeferredInserts();
56 fTree->clear(); 55 fTree->clear();
57 } 56 }
58 } 57 }
59 private: 58 private:
60 SkBBoxHierarchy* fTree; 59 SkBBoxHierarchy* fTree;
(...skipping 30 matching lines...) Expand all
91 } 90 }
92 virtual ~BBoxQueryBench() { 91 virtual ~BBoxQueryBench() {
93 fTree->unref(); 92 fTree->unref();
94 } 93 }
95 protected: 94 protected:
96 virtual const char* onGetName() SK_OVERRIDE { 95 virtual const char* onGetName() SK_OVERRIDE {
97 return fName.c_str(); 96 return fName.c_str();
98 } 97 }
99 virtual void onPreDraw() SK_OVERRIDE { 98 virtual void onPreDraw() SK_OVERRIDE {
100 SkRandom rand; 99 SkRandom rand;
101 for (int j = 0; j < SkBENCHLOOP(NUM_QUERY_RECTS); ++j) { 100 for (int j = 0; j < NUM_QUERY_RECTS; ++j) {
102 fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j, 101 fTree->insert(reinterpret_cast<void*>(j),
103 SkBENCHLOOP(NUM_QUERY_RECTS)), fBulkLoad); 102 fProc(rand, j, NUM_QUERY_RECTS),
103 fBulkLoad);
104 } 104 }
105 fTree->flushDeferredInserts(); 105 fTree->flushDeferredInserts();
106 } 106 }
107 107
108 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 108 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
109 SkRandom rand; 109 SkRandom rand;
110 for (int i = 0; i < SkBENCHLOOP(NUM_QUERIES); ++i) { 110 for (int i = 0; i < this->getLoops(); ++i) {
111 SkTDArray<void*> hits; 111 SkTDArray<void*> hits;
112 SkIRect query; 112 SkIRect query;
113 switch(fQuery) { 113 switch(fQuery) {
114 case kSmall_QueryType: 114 case kSmall_QueryType:
115 query.fLeft = rand.nextU() % GENERATE_EXTENTS; 115 query.fLeft = rand.nextU() % GENERATE_EXTENTS;
116 query.fTop = rand.nextU() % GENERATE_EXTENTS; 116 query.fTop = rand.nextU() % GENERATE_EXTENTS;
117 query.fRight = query.fLeft + (GENERATE_EXTENTS / 20); 117 query.fRight = query.fLeft + (GENERATE_EXTENTS / 20);
118 query.fBottom = query.fTop + (GENERATE_EXTENTS / 20); 118 query.fBottom = query.fTop + (GENERATE_EXTENTS / 20);
119 break; 119 break;
120 case kLarge_QueryType: 120 case kLarge_QueryType:
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 static BenchRegistry gReg9(Fact9); 302 static BenchRegistry gReg9(Fact9);
303 static BenchRegistry gReg8(Fact8); 303 static BenchRegistry gReg8(Fact8);
304 static BenchRegistry gReg7(Fact7); 304 static BenchRegistry gReg7(Fact7);
305 static BenchRegistry gReg6(Fact6); 305 static BenchRegistry gReg6(Fact6);
306 static BenchRegistry gReg5(Fact5); 306 static BenchRegistry gReg5(Fact5);
307 static BenchRegistry gReg4(Fact4); 307 static BenchRegistry gReg4(Fact4);
308 static BenchRegistry gReg3(Fact3); 308 static BenchRegistry gReg3(Fact3);
309 static BenchRegistry gReg2(Fact2); 309 static BenchRegistry gReg2(Fact2);
310 static BenchRegistry gReg1(Fact1); 310 static BenchRegistry gReg1(Fact1);
311 static BenchRegistry gReg0(Fact0); 311 static BenchRegistry gReg0(Fact0);
OLDNEW
« no previous file with comments | « bench/PremulAndUnpremulAlphaOpsBench.cpp ('k') | bench/ReadPixBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698