GeoInterface.jl
GeoInterface.jl copied to clipboard
Extents are somehow very slow
On Julia 1.12
Setup
using Extents, GADM, Chairmarks
import GeometryOps as GO
switzerland = GI.geometry(GI.getfeature(GADM.get("CHE"), 1)) |> GO.tuples
Result
julia> @be GO.prepare_naturally($(switzerland.geom[1]))
Benchmark: 17 samples with 1 evaluation
min 74.916 μs (29 allocs: 1.349 MiB)
median 143.375 μs (29 allocs: 1.349 MiB)
mean 12.350 ms (29.24 allocs: 1.349 MiB, 11.73% gc time)
max 149.128 ms (33 allocs: 1.349 MiB, 99.86% gc time)
julia> @be GI.extent($(switzerland.geom[1].geom[1].geom |> GI.LinearRing); fallback = true)
Benchmark: 416 samples with 1 evaluation
min 200.292 μs
median 207.834 μs
mean 225.360 μs
max 384.791 μs
This means that creating a natural tree which allocates etc. is 1.3x faster than gettting the extent which is pretty insane. We should try to fix this somehow, because that means that any geometry without cached extent is getting clobbered in benchmarks.