Skip to content

Commit b6a57e2

Browse files
authored
Merge pull request #10 from flippmoke/flippmoke/bm_update
Updated google benchmark to use args
2 parents cc0108c + f7d3114 commit b6a57e2

File tree

1 file changed

+4
-38
lines changed

1 file changed

+4
-38
lines changed

bench/run.cpp

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#include <string>
66
#include <vector>
77

8-
namespace {
9-
std::vector<double> generate_uniform(size_t n) {
8+
std::vector<double> generate_uniform(std::size_t n) {
109
std::vector<double> coords;
1110
std::srand(350);
1211
double norm = static_cast<double>(RAND_MAX) / 1e3;
@@ -27,47 +26,14 @@ void BM_45K_geojson_nodes(benchmark::State& state) {
2726
}
2827
}
2928

30-
void BM_2K_uniform(benchmark::State& state) {
31-
std::vector<double> coords = generate_uniform(2000);
29+
void BM_uniform(benchmark::State& state) {
30+
std::vector<double> coords = generate_uniform(static_cast<std::size_t>(state.range(0)));
3231
while (state.KeepRunning()) {
3332
delaunator::Delaunator delaunator(coords);
3433
}
3534
}
3635

37-
void BM_100K_uniform(benchmark::State& state) {
38-
std::vector<double> coords = generate_uniform(100000);
39-
while (state.KeepRunning()) {
40-
delaunator::Delaunator delaunator(coords);
41-
}
42-
}
43-
44-
void BM_200K_uniform(benchmark::State& state) {
45-
std::vector<double> coords = generate_uniform(200000);
46-
while (state.KeepRunning()) {
47-
delaunator::Delaunator delaunator(coords);
48-
}
49-
}
50-
51-
void BM_500K_uniform(benchmark::State& state) {
52-
std::vector<double> coords = generate_uniform(500000);
53-
while (state.KeepRunning()) {
54-
delaunator::Delaunator delaunator(coords);
55-
}
56-
}
57-
58-
void BM_1M_uniform(benchmark::State& state) {
59-
std::vector<double> coords = generate_uniform(1000000);
60-
while (state.KeepRunning()) {
61-
delaunator::Delaunator delaunator(coords);
62-
}
63-
}
64-
} // namespace
65-
6636
BENCHMARK(BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond);
67-
BENCHMARK(BM_2K_uniform)->Unit(benchmark::kMillisecond);
68-
BENCHMARK(BM_100K_uniform)->Unit(benchmark::kMillisecond);
69-
BENCHMARK(BM_200K_uniform)->Unit(benchmark::kMillisecond);
70-
BENCHMARK(BM_500K_uniform)->Unit(benchmark::kMillisecond);
71-
BENCHMARK(BM_1M_uniform)->Unit(benchmark::kMillisecond);
37+
BENCHMARK(BM_uniform)->Arg(2000)->Arg(100000)->Arg(200000)->Arg(500000)->Arg(1000000)->Unit(benchmark::kMillisecond);
7238

7339
BENCHMARK_MAIN()

0 commit comments

Comments
 (0)