File tree 7 files changed +171
-115
lines changed
7 files changed +171
-115
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,5 @@ node_modules
14
14
mason_packages
15
15
.toolchain
16
16
.mason
17
- local.env
17
+ local.env
18
+ xcode-project
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7
7
include (${CMAKE_CURRENT_SOURCE_DIR} /cmake/mason.cmake)
8
8
9
9
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 )
12
+ option (BENCHMARK_10M "Run against 100M points" OFF )
10
13
11
14
# configure optimization
12
15
if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
@@ -50,6 +53,18 @@ add_executable(unit-tests ${TEST_SOURCES})
50
53
find_package (Threads REQUIRED)
51
54
file (GLOB BENCH_SOURCES bench/*.cpp)
52
55
add_executable (bench-tests ${BENCH_SOURCES} )
56
+ if (BENCHMARK_BIG_O)
57
+ message ("-- BENCHMARK_BIG_O=1" )
58
+ target_compile_definitions (bench-tests PUBLIC BENCHMARK_BIG_O=1)
59
+ endif ()
60
+ if (BENCHMARK_100M)
61
+ message ("-- BENCHMARK_100M=1" )
62
+ target_compile_definitions (bench-tests PUBLIC BENCHMARK_100M=1)
63
+ endif ()
64
+ if (BENCHMARK_10M)
65
+ message ("-- BENCHMARK_10M=1" )
66
+ target_compile_definitions (bench-tests PUBLIC BENCHMARK_10M=1)
67
+ endif ()
53
68
54
69
#examples
55
70
add_executable (triangulate-geojson examples/triangulate_geojson.cpp)
Original file line number Diff line number Diff line change 2
2
# Whether to turn compiler warnings into errors
3
3
export WERROR ?= true
4
4
export BUILD_DIR ?= cmake-build
5
+ export XCODE_PROJ_DIR ?= xcode-project
5
6
6
7
default : release
7
8
@@ -11,6 +12,9 @@ release:
11
12
debug :
12
13
mkdir -p ./$(BUILD_DIR ) && cd ./$(BUILD_DIR ) && cmake ../ -DCMAKE_BUILD_TYPE=Debug -DWERROR=$(WERROR ) && VERBOSE=1 cmake --build .
13
14
15
+ xcode :
16
+ mkdir -p ./$(XCODE_PROJ_DIR ) && cd ./$(XCODE_PROJ_DIR ) && cmake -G Xcode ../
17
+
14
18
test :
15
19
@if [ -f ./$( BUILD_DIR) /unit-tests ]; then ./$(BUILD_DIR ) /unit-tests; else echo " Please run 'make release' or 'make debug' first" && exit 1; fi
16
20
Original file line number Diff line number Diff line change @@ -48,16 +48,16 @@ int main() {
48
48
49
49
```
50
50
Run on (4 X 2300 MHz CPU s)
51
- 2018-09-26 09:28:34
51
+ 2018-09-29 09:27:28
52
52
------------------------------------------------------------
53
53
Benchmark Time CPU Iterations
54
54
------------------------------------------------------------
55
- BM_45K_geojson_nodes 24 ms 24 ms 29
56
- BM_uniform/2000 1 ms 1 ms 887
57
- BM_uniform/100000 66 ms 66 ms 9
58
- BM_uniform/200000 158 ms 155 ms 4
59
- BM_uniform/500000 441 ms 439 ms 2
60
- BM_uniform/1000000 1062 ms 1058 ms 1
55
+ BM_45K_geojson_nodes 22 ms 22 ms 32
56
+ BM_uniform/2000 1 ms 1 ms 982
57
+ BM_uniform/100000 63 ms 62 ms 9
58
+ BM_uniform/200000 140 ms 140 ms 4
59
+ BM_uniform/500000 400 ms 399 ms 2
60
+ BM_uniform/1000000 994 ms 993 ms 1
61
61
```
62
62
63
63
Library is ~ 10% faster then JS version for 1M uniform points ([ details] ( https://github.com/delfrrr/delaunator-cpp/pull/8#issuecomment-422690056 ) )
Original file line number Diff line number Diff line change 7
7
8
8
std::vector<double > generate_uniform (std::size_t n) {
9
9
std::vector<double > coords;
10
+ coords.reserve (2 * n);
10
11
std::srand (350 );
11
12
double norm = static_cast <double >(RAND_MAX) / 1e3 ;
12
13
for (size_t i = 0 ; i < n; i++) {
@@ -31,9 +32,20 @@ void BM_uniform(benchmark::State& state) {
31
32
while (state.KeepRunning ()) {
32
33
delaunator::Delaunator delaunator (coords);
33
34
}
35
+ state.SetComplexityN (state.range (0 ));
34
36
}
35
37
36
38
BENCHMARK (BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond );
37
39
BENCHMARK (BM_uniform)->Arg(2000 )->Arg(100000 )->Arg(200000 )->Arg(500000 )->Arg(1000000 )->Unit(benchmark::kMillisecond );
38
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_10M
45
+ BENCHMARK (BM_uniform)->Arg(1000000 * 10 )->Unit(benchmark::kMillisecond );
46
+ #endif
47
+ #if BENCHMARK_100M
48
+ BENCHMARK (BM_uniform)->Arg(1000000 * 100 )->Unit(benchmark::kMillisecond );
49
+ #endif
50
+
39
51
BENCHMARK_MAIN ()
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ inline std::string read_file(const char* filename) {
22
22
}
23
23
}
24
24
25
- inline std::vector<double > get_geo_json_points (std::string const & json) {
25
+ inline std::vector< double > get_geo_json_points (std::string const & json) {
26
26
rapidjson::Document document;
27
27
if (document.Parse (json.c_str ()).HasParseError ()) {
28
28
throw std::runtime_error (" Cannot parse JSON" );
You can’t perform that action at this time.
0 commit comments