paleolimbot / geos

Open Source Geometry Engine ('GEOS') R API
https://paleolimbot.github.io/geos/
Other
61 stars 8 forks source link

Potentially faster strtree implementations #73

Closed paleolimbot closed 2 years ago

paleolimbot commented 2 years ago

Fixes #66 (hopefully!).

codecov-commenter commented 2 years ago

Codecov Report

Merging #73 (5d325a2) into master (956a675) will decrease coverage by 0.28%. The diff coverage is 93.04%.

@@            Coverage Diff             @@
##           master      #73      +/-   ##
==========================================
- Coverage   97.54%   97.26%   -0.29%     
==========================================
  Files          31       33       +2     
  Lines        2809     2996     +187     
==========================================
+ Hits         2740     2914     +174     
- Misses         69       82      +13     
Impacted Files Coverage Δ
src/init.c 100.00% <ø> (ø)
src/geos-basic-strtree.c 91.60% <91.60%> (ø)
R/geos-basic-strtree.R 97.72% <97.72%> (ø)
R/geos-make.R 100.00% <0.00%> (ø)
R/geos-unnest.R 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

paleolimbot commented 2 years ago

Example:

library(geos)

many_points <- wk::xy(runif(1e6), runif(1e6))

geos_match_xy <- function(x, table) {
  tree <- geos_basic_strtree()
  geos_basic_strtree_insert(tree, x)
  geos_basic_strtree_query(tree, x, limit = 1, fill = TRUE)
}

bench::mark(
  geos_match_xy(many_points, many_points),
  iterations = 5,
  check = FALSE
)
#> # A tibble: 1 × 6
#>   expression                                   min   median `itr/sec` mem_alloc
#>   <bch:expr>                              <bch:tm> <bch:tm>     <dbl> <bch:byt>
#> 1 geos_match_xy(many_points, many_points)    1.02s    1.02s     0.980     7.7MB
#> # … with 1 more variable: `gc/sec` <dbl>

Created on 2022-08-11 by the reprex package (v2.0.1)