benchmark - add quad_tree creation test
This commit is contained in:
parent
ca491d8aa9
commit
6107ef8be0
3 changed files with 49 additions and 0 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
40
benchmark/test_quad_tree.cpp
Normal file
40
benchmark/test_quad_tree.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "bench_framework.hpp"
|
||||
#include <mapnik/quad_tree.hpp>
|
||||
#include <random>
|
||||
|
||||
using quad_tree_type = mapnik::quad_tree<std::size_t>;
|
||||
|
||||
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<int> uniform_dist(0, 2048);
|
||||
std::size_t count = 0;
|
||||
quad_tree_type tree(mapnik::box2d<double>(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<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
|
||||
tree.insert(i, box);
|
||||
count++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
BENCHMARK(test,"quad_tree creation")
|
Loading…
Reference in a new issue