Added benchmarks vs S2, Boost.Geometry, GeographicLib#14
Open
Added benchmarks vs S2, Boost.Geometry, GeographicLib#14
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
benchmarks/directory with Google Benchmark micro-benchmarks for:distance_between;heading;contains;area;path_length.The benchmarks compare
geo-utils-cppagainst:Conversion policy is documented and normalized across libraries: streams of points are converted inside the timed loop (the realistic cost when the input is lat/lng), long-lived polygons are pre-built once outside the loop (matches the geofence-loaded-once-queried-many-times pattern).
Also adds disk-footprint measurement via
benchmarks/size/measure.sh. The script builds minimal consumer programs against each library and reports:Documentation changes:
docs/benchmarks.mdwith methodology, full results per operation, and a "when to use which library" guide;Headline numbers on Apple M1, clang 17,
-O2 -DNDEBUG:distance_between, showing zero header-only overhead;distance/headingwithin ~5% noise; ahead on every polygon operation;contains(depending on polygon size);distance,heading,area,path_length, and oncontainsagainst ~10-vertex polygons. S2 winscontainsfrom ~100 vertices onward via its bounding-rectangle prefilter — the documented caveat;geometrysubset alone;That makes
geo-utils-cpproughly 130× to 900× smaller, depending on the comparison target.Build / CI hygiene:
URL_HASH SHA256=...pinned for the Google Benchmark FetchContent;strtod(not the UB-on-bad-inputatof);measure.shpersists failed build logs tobuild-bench/size-logs/and reports failure status via a sentinel file (works correctly across command-substitution boundaries);find_package(s2 NAMES s2 S2)accepts both casings of the installed config file.Benchmarks are off by default via
GEO_UTILS_CPP_BUILD_BENCHMARKS=OFFand are not run in CI (would require S2 / Boost / GeographicLib installs). A small smoke-build job in CI compilesbench_geo_utilsandbench_naive(the dependency-free portion) so the benchmark plumbing can't bitrot silently.