File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 11#include " ../examples/utils.hpp"
22#include < benchmark/benchmark.h>
33#include < delaunator.hpp>
4+ #include < random>
45#include < string>
6+ #include < vector>
7+
8+ std::vector<double > generate_uniform (size_t n) {
9+ std::vector<double > coords;
10+ std::srand (350 );
11+
12+ for (size_t i = 0 ; i < n; i++) {
13+ coords.push_back (double (std::rand ()) / RAND_MAX);
14+ coords.push_back (double (std::rand ()) / RAND_MAX);
15+ }
16+
17+ return coords;
18+ }
519
620namespace {
721void BM_45K_geojson_nodes (benchmark::State& state) {
@@ -12,8 +26,24 @@ void BM_45K_geojson_nodes(benchmark::State& state) {
1226 delaunator::Delaunator delaunator (coords);
1327 }
1428}
29+
30+ void BM_100K_uniform (benchmark::State& state) {
31+ std::vector<double > coords = generate_uniform (100000 );
32+ while (state.KeepRunning ()) {
33+ delaunator::Delaunator delaunator (coords);
34+ }
35+ }
36+
37+ void BM_1M_uniform (benchmark::State& state) {
38+ std::vector<double > coords = generate_uniform (1000000 );
39+ while (state.KeepRunning ()) {
40+ delaunator::Delaunator delaunator (coords);
41+ }
42+ }
1543} // namespace
1644
1745BENCHMARK (BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond );
46+ BENCHMARK (BM_100K_uniform)->Unit(benchmark::kMillisecond );
47+ BENCHMARK (BM_1M_uniform)->Unit(benchmark::kMillisecond );
1848
1949BENCHMARK_MAIN ()
You can’t perform that action at this time.
0 commit comments