From 7f3b88b11ea242aa699cbe986558c09d34ec6bb6 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Jun 2015 17:08:19 +0200 Subject: [PATCH] benchmark (quad_tree) - add bbox query --- benchmark/run | 4 ++-- benchmark/test_quad_tree.cpp | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/benchmark/run b/benchmark/run index 542b0241f..b17f82ad3 100755 --- a/benchmark/run +++ b/benchmark/run @@ -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 diff --git a/benchmark/test_quad_tree.cpp b/benchmark/test_quad_tree.cpp index 591c47f12..e3aabac7c 100644 --- a/benchmark/test_quad_tree.cpp +++ b/benchmark/test_quad_tree.cpp @@ -20,8 +20,8 @@ public: std::random_device rd; std::default_random_engine engine(rd()); std::uniform_int_distribution uniform_dist(0, 2048); - std::size_t count = 0; quad_tree_type tree(mapnik::box2d(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 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 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; } };