Rename benchmark classes, hopefully less confusing to valgrid?

I was able to reproduce the problem, but Valgrind was giving me a very odd
report, pointing to a particular line in QuadTreeBench.cpp from a stack that
was running RTreeBench.

Whenever Valgrind complains, it's always about switch(fQuery), line 109 in
QuadTreeBench or 119 in RTreeBench.  I can't see any way that fQuery is not
initialized.

I believe we've just confused Valgrind by linking together  classes with
identical names.  This CL gives them all unique names.

BUG=skia:2455
R=bungeman@google.com, mtklein@google.com, bsalomon@google.com, borenet@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/247913003

git-svn-id: http://skia.googlecode.com/svn/trunk@14338 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-04-23 21:03:45 +00:00
parent 034c66b57f
commit b2db44376e
3 changed files with 51 additions and 67 deletions

View File

@ -22,9 +22,9 @@ static const SkIRect QUAD_TREE_BOUNDS = SkIRect::MakeLTRB(
typedef SkIRect (*MakeRectProc)(SkRandom&, int, int); typedef SkIRect (*MakeRectProc)(SkRandom&, int, int);
// Time how long it takes to build an QuadTree // Time how long it takes to build an QuadTree
class BBoxBuildBench : public SkBenchmark { class QuadTreeBuildBench : public SkBenchmark {
public: public:
BBoxBuildBench(const char* name, MakeRectProc proc, SkBBoxHierarchy* tree) QuadTreeBuildBench(const char* name, MakeRectProc proc, SkBBoxHierarchy* tree)
: fTree(tree) : fTree(tree)
, fProc(proc) { , fProc(proc) {
fName.append("quadtree_"); fName.append("quadtree_");
@ -36,7 +36,7 @@ public:
return backend == kNonRendering_Backend; return backend == kNonRendering_Backend;
} }
virtual ~BBoxBuildBench() { virtual ~QuadTreeBuildBench() {
fTree->unref(); fTree->unref();
} }
protected: protected:
@ -61,7 +61,7 @@ private:
}; };
// Time how long it takes to perform queries on an QuadTree // Time how long it takes to perform queries on an QuadTree
class BBoxQueryBench : public SkBenchmark { class QuadTreeQueryBench : public SkBenchmark {
public: public:
enum QueryType { enum QueryType {
kSmall_QueryType, // small queries kSmall_QueryType, // small queries
@ -70,7 +70,7 @@ public:
kFull_QueryType // queries that cover everything kFull_QueryType // queries that cover everything
}; };
BBoxQueryBench(const char* name, MakeRectProc proc, QuadTreeQueryBench(const char* name, MakeRectProc proc,
QueryType q, SkBBoxHierarchy* tree) QueryType q, SkBBoxHierarchy* tree)
: fTree(tree) : fTree(tree)
, fProc(proc) , fProc(proc)
@ -84,7 +84,7 @@ public:
return backend == kNonRendering_Backend; return backend == kNonRendering_Backend;
} }
virtual ~BBoxQueryBench() { virtual ~QuadTreeQueryBench() {
fTree->unref(); fTree->unref();
} }
protected: protected:
@ -179,38 +179,38 @@ static inline SkIRect make_random_rects(SkRandom& rand, int index, int numRects)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("XYordered", &make_XYordered_rects, return SkNEW_ARGS(QuadTreeBuildBench, ("XYordered", &make_XYordered_rects,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("XYordered", &make_XYordered_rects, return SkNEW_ARGS(QuadTreeQueryBench, ("XYordered", &make_XYordered_rects,
BBoxQueryBench::kRandom_QueryType, QuadTreeQueryBench::kRandom_QueryType,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("YXordered", &make_YXordered_rects, return SkNEW_ARGS(QuadTreeBuildBench, ("YXordered", &make_YXordered_rects,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("YXordered", &make_YXordered_rects, return SkNEW_ARGS(QuadTreeQueryBench, ("YXordered", &make_YXordered_rects,
BBoxQueryBench::kRandom_QueryType, QuadTreeQueryBench::kRandom_QueryType,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("random", &make_random_rects, return SkNEW_ARGS(QuadTreeBuildBench, ("random", &make_random_rects,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("random", &make_random_rects, return SkNEW_ARGS(QuadTreeQueryBench, ("random", &make_random_rects,
BBoxQueryBench::kRandom_QueryType, QuadTreeQueryBench::kRandom_QueryType,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("concentric", &make_concentric_rects_increasing, return SkNEW_ARGS(QuadTreeBuildBench, ("concentric", &make_concentric_rects_increasing,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("concentric", &make_concentric_rects_increasing, return SkNEW_ARGS(QuadTreeQueryBench, ("concentric", &make_concentric_rects_increasing,
BBoxQueryBench::kRandom_QueryType, QuadTreeQueryBench::kRandom_QueryType,
SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS)))); SkNEW_ARGS(SkQuadTree, (QUAD_TREE_BOUNDS))));
) )

View File

@ -21,9 +21,9 @@ static const int GRID_WIDTH = 100;
typedef SkIRect (*MakeRectProc)(SkRandom&, int, int); typedef SkIRect (*MakeRectProc)(SkRandom&, int, int);
// Time how long it takes to build an R-Tree either bulk-loaded or not // Time how long it takes to build an R-Tree either bulk-loaded or not
class BBoxBuildBench : public SkBenchmark { class RTreeBuildBench : public SkBenchmark {
public: public:
BBoxBuildBench(const char* name, MakeRectProc proc, bool bulkLoad, RTreeBuildBench(const char* name, MakeRectProc proc, bool bulkLoad,
SkBBoxHierarchy* tree) SkBBoxHierarchy* tree)
: fTree(tree) : fTree(tree)
, fProc(proc) , fProc(proc)
@ -40,7 +40,7 @@ public:
return backend == kNonRendering_Backend; return backend == kNonRendering_Backend;
} }
virtual ~BBoxBuildBench() { virtual ~RTreeBuildBench() {
fTree->unref(); fTree->unref();
} }
protected: protected:
@ -67,7 +67,7 @@ private:
}; };
// Time how long it takes to perform queries on an R-Tree, bulk-loaded or not // Time how long it takes to perform queries on an R-Tree, bulk-loaded or not
class BBoxQueryBench : public SkBenchmark { class RTreeQueryBench : public SkBenchmark {
public: public:
enum QueryType { enum QueryType {
kSmall_QueryType, // small queries kSmall_QueryType, // small queries
@ -76,7 +76,7 @@ public:
kFull_QueryType // queries that cover everything kFull_QueryType // queries that cover everything
}; };
BBoxQueryBench(const char* name, MakeRectProc proc, bool bulkLoad, RTreeQueryBench(const char* name, MakeRectProc proc, bool bulkLoad,
QueryType q, SkBBoxHierarchy* tree) QueryType q, SkBBoxHierarchy* tree)
: fTree(tree) : fTree(tree)
, fProc(proc) , fProc(proc)
@ -94,7 +94,7 @@ public:
return backend == kNonRendering_Backend; return backend == kNonRendering_Backend;
} }
virtual ~BBoxQueryBench() { virtual ~RTreeQueryBench() {
fTree->unref(); fTree->unref();
} }
protected: protected:
@ -189,81 +189,81 @@ static inline SkIRect make_random_rects(SkRandom& rand, int index, int numRects)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("XYordered", &make_XYordered_rects, false, return SkNEW_ARGS(RTreeBuildBench, ("XYordered", &make_XYordered_rects, false,
SkRTree::Create(5, 16))); SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("XYordered", &make_XYordered_rects, true, return SkNEW_ARGS(RTreeBuildBench, ("XYordered", &make_XYordered_rects, true,
SkRTree::Create(5, 16))); SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("(unsorted)XYordered", &make_XYordered_rects, true, return SkNEW_ARGS(RTreeBuildBench, ("(unsorted)XYordered", &make_XYordered_rects, true,
SkRTree::Create(5, 16, 1, false))); SkRTree::Create(5, 16, 1, false)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("XYordered", &make_XYordered_rects, true, return SkNEW_ARGS(RTreeQueryBench, ("XYordered", &make_XYordered_rects, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("(unsorted)XYordered", &make_XYordered_rects, true, return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)XYordered", &make_XYordered_rects, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("YXordered", &make_YXordered_rects, false, return SkNEW_ARGS(RTreeBuildBench, ("YXordered", &make_YXordered_rects, false,
SkRTree::Create(5, 16))); SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("YXordered", &make_YXordered_rects, true, return SkNEW_ARGS(RTreeBuildBench, ("YXordered", &make_YXordered_rects, true,
SkRTree::Create(5, 16))); SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("(unsorted)YXordered", &make_YXordered_rects, true, return SkNEW_ARGS(RTreeBuildBench, ("(unsorted)YXordered", &make_YXordered_rects, true,
SkRTree::Create(5, 16, 1, false))); SkRTree::Create(5, 16, 1, false)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("YXordered", &make_YXordered_rects, true, return SkNEW_ARGS(RTreeQueryBench, ("YXordered", &make_YXordered_rects, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("(unsorted)YXordered", &make_YXordered_rects, true, return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)YXordered", &make_YXordered_rects, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("random", &make_random_rects, false, return SkNEW_ARGS(RTreeBuildBench, ("random", &make_random_rects, false,
SkRTree::Create(5, 16))); SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("random", &make_random_rects, true, return SkNEW_ARGS(RTreeBuildBench, ("random", &make_random_rects, true,
SkRTree::Create(5, 16))); SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("(unsorted)random", &make_random_rects, true, return SkNEW_ARGS(RTreeBuildBench, ("(unsorted)random", &make_random_rects, true,
SkRTree::Create(5, 16, 1, false))); SkRTree::Create(5, 16, 1, false)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("random", &make_random_rects, true, return SkNEW_ARGS(RTreeQueryBench, ("random", &make_random_rects, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("(unsorted)random", &make_random_rects, true, return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)random", &make_random_rects, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("concentric", return SkNEW_ARGS(RTreeBuildBench, ("concentric",
&make_concentric_rects_increasing, true, SkRTree::Create(5, 16))); &make_concentric_rects_increasing, true, SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxBuildBench, ("(unsorted)concentric", return SkNEW_ARGS(RTreeBuildBench, ("(unsorted)concentric",
&make_concentric_rects_increasing, true, SkRTree::Create(5, 16, 1, false))); &make_concentric_rects_increasing, true, SkRTree::Create(5, 16, 1, false)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("concentric", &make_concentric_rects_increasing, true, return SkNEW_ARGS(RTreeQueryBench, ("concentric", &make_concentric_rects_increasing, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16)));
) )
DEF_BENCH( DEF_BENCH(
return SkNEW_ARGS(BBoxQueryBench, ("(unsorted)concentric", &make_concentric_rects_increasing, true, return SkNEW_ARGS(RTreeQueryBench, ("(unsorted)concentric", &make_concentric_rects_increasing, true,
BBoxQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false))); RTreeQueryBench::kRandom_QueryType, SkRTree::Create(5, 16, 1, false)));
) )

View File

@ -211,20 +211,4 @@
fun:_Z9tool_mainiPPc fun:_Z9tool_mainiPPc
fun:(below main) fun:(below main)
} }
{
rtree_(unsorted)* http://skbug.com/2455
Memcheck:Cond
fun:_ZN14BBoxQueryBench6onDrawEiP8SkCanvas
fun:_ZN11SkBenchmark4drawEiP8SkCanvas
fun:_Z9tool_mainiPPc
fun:main
}
{
rtree_(unsorted)* 2 http://skbug.com/2455
Memcheck:Cond
fun:_ZN14BBoxQueryBench6onDrawEiP8SkCanvas
fun:_Z9tool_mainiPPc
fun:(below main)
}