benchmark (quad_tree) - add bbox query

This commit is contained in:
artemp 2015-06-19 17:08:19 +02:00
parent 6107ef8be0
commit 7f3b88b11e
2 changed files with 19 additions and 5 deletions

View file

@ -51,9 +51,9 @@ run test_offset_converter 10 1000
--threads 10
./benchmark/out/test_quad_tree \
--iterations 1000000 \
--iterations 10000 \
--threads 1
./benchmark/out/test_quad_tree \
--iterations 10000 \
--threads 100
--threads 10

View file

@ -20,8 +20,8 @@ public:
std::random_device rd;
std::default_random_engine engine(rd());
std::uniform_int_distribution<int> uniform_dist(0, 2048);
std::size_t count = 0;
quad_tree_type tree(mapnik::box2d<double>(0,0,2048,2048));
//populate
for (size_t i = 0; i < iterations_; ++i)
{
int cx = uniform_dist(engine);
@ -30,9 +30,23 @@ public:
int sy = 0.2 * uniform_dist(engine);
mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
tree.insert(i, box);
count++;
}
// bounding box query
std::size_t count=0;
for (size_t i = 0; i < iterations_; ++i)
{
int cx = uniform_dist(engine);
int cy = uniform_dist(engine);
int sx = 0.4 * uniform_dist(engine);
int sy = 0.4 * uniform_dist(engine);
mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
auto itr = tree.query_in_box(box);
auto end = tree.query_end();
for ( ;itr != end; ++itr)
{
++count;
}
}
return true;
}
};