aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/RTreeBench.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-01 15:58:07 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-01 15:58:07 +0000
commit7fb83c8c72f2a035e84a4ee4ee6abcf5a4872166 (patch)
treea47ea30d8bb00b811e7360992602e14bed7987c6 /bench/RTreeBench.cpp
parentab44a17f376039cdcaba74f9fb8f282ea4caa63c (diff)
When skia run bench cases to test performance, it will run constructors for all cases one by one, then getName to skip unnecessary cases according to command line parameters, so these constructors should be lightweight enough to avoid redundant computing. Unfortunately, some constructors contain intensive computing/rendering. They are very heavy, maybe much heavier than need-to-run bench case itself. And these redundant computation will be run every time you run bench, even you just test a single simple case. Moreover, it will mislead the real hotspot/bottleneck of the case itself.
For example, run a lightweight case, say, region_intersectsrgn_16, the hot spots are gles operation, SuperBlitter, SkRTree... introduced by irrelevant cases' constructors. These redundant computation will mislead performance tuning. So we can move these intensive computation to onPreDraw() of these case. They will be executed only if this case should be run. R=reed@google.com, robertphillips@google.com, humper@google.com, tomhudson@chromium.org Author: yunchao.he@intel.com Review URL: https://chromiumcodereview.appspot.com/20997003 git-svn-id: http://skia.googlecode.com/svn/trunk@10486 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/RTreeBench.cpp')
-rw-r--r--bench/RTreeBench.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp
index 53dbe28982..bce1b67513 100644
--- a/bench/RTreeBench.cpp
+++ b/bench/RTreeBench.cpp
@@ -18,7 +18,7 @@ static const int NUM_BUILD_RECTS = 500;
static const int NUM_QUERY_RECTS = 5000;
static const int NUM_QUERIES = 1000;
-typedef SkIRect (*MakeRectProc)(SkRandom&, int, int);
+typedef SkIRect (*MakeRectProc)(SkMWCRandom&, int, int);
// Time how long it takes to build an R-Tree either bulk-loaded or not
class BBoxBuildBench : public SkBenchmark {
@@ -41,11 +41,11 @@ public:
fTree->unref();
}
protected:
- virtual const char* onGetName() {
+ virtual const char* onGetName() SK_OVERRIDE {
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
- SkRandom rand;
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkMWCRandom rand;
for (int i = 0; i < SkBENCHLOOP(100); ++i) {
for (int j = 0; j < NUM_BUILD_RECTS; ++j) {
fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j, NUM_BUILD_RECTS),
@@ -86,23 +86,26 @@ public:
if (fBulkLoad) {
fName.append("_bulk");
}
- SkRandom rand;
- for (int j = 0; j < SkBENCHLOOP(NUM_QUERY_RECTS); ++j) {
- fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j,
- SkBENCHLOOP(NUM_QUERY_RECTS)), fBulkLoad);
- }
- fTree->flushDeferredInserts();
fIsRendering = false;
}
virtual ~BBoxQueryBench() {
fTree->unref();
}
protected:
- virtual const char* onGetName() {
+ virtual const char* onGetName() SK_OVERRIDE {
return fName.c_str();
}
- virtual void onDraw(SkCanvas* canvas) {
- SkRandom rand;
+ virtual void onPreDraw() SK_OVERRIDE {
+ SkMWCRandom rand;
+ for (int j = 0; j < SkBENCHLOOP(NUM_QUERY_RECTS); ++j) {
+ fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j,
+ SkBENCHLOOP(NUM_QUERY_RECTS)), fBulkLoad);
+ }
+ fTree->flushDeferredInserts();
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkMWCRandom rand;
for (int i = 0; i < SkBENCHLOOP(NUM_QUERIES); ++i) {
SkTDArray<void*> hits;
SkIRect query;
@@ -145,22 +148,22 @@ private:
typedef SkBenchmark INHERITED;
};
-static inline SkIRect make_simple_rect(SkRandom&, int index, int numRects) {
+static inline SkIRect make_simple_rect(SkMWCRandom&, int index, int numRects) {
SkIRect out = {0, 0, GENERATE_EXTENTS, GENERATE_EXTENTS};
return out;
}
-static inline SkIRect make_concentric_rects_increasing(SkRandom&, int index, int numRects) {
+static inline SkIRect make_concentric_rects_increasing(SkMWCRandom&, int index, int numRects) {
SkIRect out = {0, 0, index + 1, index + 1};
return out;
}
-static inline SkIRect make_concentric_rects_decreasing(SkRandom&, int index, int numRects) {
+static inline SkIRect make_concentric_rects_decreasing(SkMWCRandom&, int index, int numRects) {
SkIRect out = {0, 0, numRects - index, numRects - index};
return out;
}
-static inline SkIRect make_point_rects(SkRandom& rand, int index, int numRects) {
+static inline SkIRect make_point_rects(SkMWCRandom& rand, int index, int numRects) {
SkIRect out;
out.fLeft = rand.nextU() % GENERATE_EXTENTS;
out.fTop = rand.nextU() % GENERATE_EXTENTS;
@@ -169,7 +172,7 @@ static inline SkIRect make_point_rects(SkRandom& rand, int index, int numRects)
return out;
}
-static inline SkIRect make_random_rects(SkRandom& rand, int index, int numRects) {
+static inline SkIRect make_random_rects(SkMWCRandom& rand, int index, int numRects) {
SkIRect out;
out.fLeft = rand.nextS() % GENERATE_EXTENTS;
out.fTop = rand.nextS() % GENERATE_EXTENTS;
@@ -178,7 +181,7 @@ static inline SkIRect make_random_rects(SkRandom& rand, int index, int numRects)
return out;
}
-static inline SkIRect make_large_rects(SkRandom& rand, int index, int numRects) {
+static inline SkIRect make_large_rects(SkMWCRandom& rand, int index, int numRects) {
SkIRect out;
out.fLeft = rand.nextU() % GENERATE_EXTENTS;
out.fTop = rand.nextU() % GENERATE_EXTENTS;