Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions bench/run.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
#include "../examples/utils.hpp"
#include <benchmark/benchmark.h>
#include <delaunator.hpp>
#include <random>
#include <string>
#include <vector>

std::vector<double> generate_uniform(size_t n) {
std::vector<double> coords;
std::srand(350);

for (size_t i = 0; i < n; i++) {
coords.push_back(double(std::rand()) / RAND_MAX);
coords.push_back(double(std::rand()) / RAND_MAX);
}

return coords;
}

namespace {
void BM_45K_geojson_nodes(benchmark::State& state) {
Expand All @@ -12,8 +26,24 @@ void BM_45K_geojson_nodes(benchmark::State& state) {
delaunator::Delaunator delaunator(coords);
}
}

void BM_100K_uniform(benchmark::State& state) {
std::vector<double> coords = generate_uniform(100000);
while (state.KeepRunning()) {
delaunator::Delaunator delaunator(coords);
}
}

void BM_1M_uniform(benchmark::State& state) {
std::vector<double> coords = generate_uniform(1000000);
while (state.KeepRunning()) {
delaunator::Delaunator delaunator(coords);
}
}
} // namespace

BENCHMARK(BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond);
BENCHMARK(BM_100K_uniform)->Unit(benchmark::kMillisecond);
BENCHMARK(BM_1M_uniform)->Unit(benchmark::kMillisecond);

BENCHMARK_MAIN()