Skip to content

Commit 373c725

Browse files
committed
add optional benchmarks
1 parent 444c2c4 commit 373c725

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
77
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mason.cmake)
88

99
option(WERROR "Add -Werror flag to build (turns warnings into errors)" ON)
10+
option(BENCHMARK_BIG_O "Calculate Big O in benchmark" OFF)
11+
option(BENCHMARK_100M "Run against 100M points" OFF)
1012

1113
# configure optimization
1214
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -50,6 +52,14 @@ add_executable(unit-tests ${TEST_SOURCES})
5052
find_package(Threads REQUIRED)
5153
file(GLOB BENCH_SOURCES bench/*.cpp)
5254
add_executable(bench-tests ${BENCH_SOURCES})
55+
if(BENCHMARK_BIG_O)
56+
message("-- BENCHMARK_BIG_O=1")
57+
target_compile_definitions(bench-tests PRIVAT BENCHMARK_BIG_O=1)
58+
endif()
59+
if(BENCHMARK_100M)
60+
message("-- BENCHMARK_100M=1")
61+
target_compile_definitions(bench-tests PRIVAT BENCHMARK_100M=1)
62+
endif()
5363

5464
#examples
5565
add_executable(triangulate-geojson examples/triangulate_geojson.cpp)

bench/run.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@ void BM_uniform(benchmark::State& state) {
3232
while (state.KeepRunning()) {
3333
delaunator::Delaunator delaunator(coords);
3434
}
35+
state.SetComplexityN(state.range(0));
3536
}
3637

3738
BENCHMARK(BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond);
3839
BENCHMARK(BM_uniform)->Arg(2000)->Arg(100000)->Arg(200000)->Arg(500000)->Arg(1000000)->Unit(benchmark::kMillisecond);
39-
// BENCHMARK(BM_uniform)->Arg(1000000 * 100)->Unit(benchmark::kMillisecond);
40+
41+
#if BENCHMARK_BIG_O
42+
BENCHMARK(BM_uniform)->RangeMultiplier(2)->Range(1<<12, 1<<22)->Unit(benchmark::kMillisecond)->Complexity();
43+
#endif
44+
#if BENCHMARK_100M
45+
BENCHMARK(BM_uniform)->Arg(1000000 * 100)->Unit(benchmark::kMillisecond);
46+
#endif
4047

4148
BENCHMARK_MAIN()

0 commit comments

Comments
 (0)