Skip to content

Commit

Permalink
change per review, change cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbrodsky committed Nov 2, 2023
1 parent 20793d2 commit 0465733
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ endif()

option(ENABLE_COVERAGE "Enable compiling tests with coverage." OFF)
option(BUILD_BENCHMARKS "Build benchmarking applications." ON)
option(ENABLE_COUNTRY_BENCHMARKS "Build benchmarking applications with Natural Earth geometries." ON)
option(BUILD_FUZZERS "Build fuzzer applications (for use with afl)." ON)
option(BUILD_FILTERS "Build filter applications." ON)
option(BUILD_GENERATORS "Build code generation applications." ON)
Expand Down Expand Up @@ -578,14 +579,14 @@ if(BUILD_BENCHMARKS)
add_h3_benchmark(benchmarkPolygon src/apps/benchmarks/benchmarkPolygon.c)
endif()

# Country benchmark: Downloads country geometry and generates the benchmark file
add_custom_target(generate_country_benchmark
COMMAND node ${CMAKE_CURRENT_SOURCE_DIR}/scripts/make_countries.js src/apps/benchmarks/benchmarkCountries.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/apps/benchmarks/benchmarkCountries.c")
add_h3_benchmark(benchmarkCountries src/apps/benchmarks/benchmarkCountries.c)
if(ENABLE_COUNTRY_BENCHMARKS)
# Country benchmark: Downloads country geometry and generates the benchmark file
add_custom_command(OUTPUT src/apps/benchmarks/benchmarkCountries.c
COMMAND node ${CMAKE_CURRENT_SOURCE_DIR}/scripts/make_countries.js ${CMAKE_CURRENT_BINARY_DIR}/src/apps/benchmarks/benchmarkCountries.c
)

add_h3_benchmark(benchmarkCountries ${CMAKE_CURRENT_BINARY_DIR}/src/apps/benchmarks/benchmarkCountries.c)
# add_dependencies(bench_benchmarkCountries )
endif()
endif()

Expand Down
12 changes: 6 additions & 6 deletions scripts/make_countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function formatCoord([lng, lat]) {
function formatGeoLoop(loop) {
return `{
.numVerts = ${loop.length},
.verts = (LatLng[]){
.verts = (LatLng[]) {
${loop.map(formatCoord).join(',\n')}
}
}`
Expand Down Expand Up @@ -147,13 +147,13 @@ for (int res = 0; res < MAX_RES + 1; res++) {
printf("Res %d", res);
BENCHMARK(polygonToCells_AllCountries, 5, {
BENCHMARK(polygonToCells_AllCountries1, 5, {
for (int index = 0; index < ${polygons.length}; index++) {
H3_EXPORT(polygonToCells)(&COUNTRIES[index], res, 0, hexagons);
}
});
BENCHMARK(polygonToCells_AllCountries, 5, {
BENCHMARK(polygonToCells_AllCountries2, 5, {
for (int index = 0; index < ${polygons.length}; index++) {
H3_EXPORT(polygonToCellsExperimental)(&COUNTRIES[index], res, 0, hexagons);
}
Expand All @@ -166,10 +166,10 @@ free(hexagons);
END_BENCHMARKS();
`

const outPath = path.join(__dirname, '..', targetPath);
fs.writeFileSync(outPath, out, 'utf-8');
fs.mkdirSync(path.dirname(targetPath), { recursive:true });
fs.writeFileSync(targetPath, out, 'utf-8');

console.log(`Wrote fixture to ${outPath}`);
console.log(`Wrote fixture to ${targetPath}`);
}

makeCountries(SOURCE_URL, TARGET);
Expand Down

0 comments on commit 0465733

Please sign in to comment.