diff --git a/benchmark/build.py b/benchmark/build.py index 4a058dd3a..8b2049e24 100644 --- a/benchmark/build.py +++ b/benchmark/build.py @@ -45,6 +45,7 @@ benchmarks = [ "test_rendering_shared_map.cpp", "test_offset_converter.cpp", "test_marker_cache.cpp", + "test_quad_tree.cpp", # "test_numeric_cast_vs_static_cast.cpp", ] for cpp_test in benchmarks: diff --git a/benchmark/run b/benchmark/run index c2dffcaf8..542b0241f 100755 --- a/benchmark/run +++ b/benchmark/run @@ -49,3 +49,11 @@ run test_offset_converter 10 1000 --height 600 \ --iterations 20 \ --threads 10 + +./benchmark/out/test_quad_tree \ + --iterations 1000000 \ + --threads 1 + +./benchmark/out/test_quad_tree \ + --iterations 10000 \ + --threads 100 diff --git a/benchmark/test_quad_tree.cpp b/benchmark/test_quad_tree.cpp new file mode 100644 index 000000000..591c47f12 --- /dev/null +++ b/benchmark/test_quad_tree.cpp @@ -0,0 +1,40 @@ +#include "bench_framework.hpp" +#include +#include + +using quad_tree_type = mapnik::quad_tree; + +class test : public benchmark::test_case +{ +public: + test(mapnik::parameters const& params) + : test_case(params) {} + + bool validate() const + { + return true; + } + + bool operator()() const + { + 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)); + for (size_t i = 0; i < iterations_; ++i) + { + int cx = uniform_dist(engine); + int cy = uniform_dist(engine); + int sx = 0.2 * uniform_dist(engine); + int sy = 0.2 * uniform_dist(engine); + mapnik::box2d box(cx - sx,cy - sy, cx + sx, cy + sy); + tree.insert(i, box); + count++; + } + + return true; + } +}; + +BENCHMARK(test,"quad_tree creation")