Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 100k/1m uniform random benchmarks #8

Merged
merged 2 commits into from
Sep 18, 2018
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()