File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
77include (${CMAKE_CURRENT_SOURCE_DIR} /cmake/mason.cmake)
88
99option (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
1214if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
@@ -50,6 +52,14 @@ add_executable(unit-tests ${TEST_SOURCES})
5052find_package (Threads REQUIRED)
5153file (GLOB BENCH_SOURCES bench/*.cpp)
5254add_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
5565add_executable (triangulate-geojson examples/triangulate_geojson.cpp)
Original file line number Diff line number Diff 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
3738BENCHMARK (BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond );
3839BENCHMARK (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
4148BENCHMARK_MAIN ()
You can’t perform that action at this time.
0 commit comments