ropensci / slopes

Package to calculate slopes of roads, rivers and trajectories
https://docs.ropensci.org/slopes/
GNU General Public License v3.0
70 stars 6 forks source link

Improve performance #1

Closed Robinlovelace closed 4 years ago

Robinlovelace commented 4 years ago

As discussed with @joeytalbot and @temospena we need to speed this up. 100 routes per second is sloooow, on current benchmark:

e = dem_lisbon_raster
r = lisbon_road_segments[1:100, ]
bench::mark(
  slope_raster(r, e)
)
#> Warning: Some expressions had a GC in every iteration; so filtering is disabled.
#> # A tibble: 1 x 6
#>   expression              min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>         <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 slope_raster(r, e)    574ms    574ms      1.74    7.35MB     10.4
Robinlovelace commented 4 years ago

Heads-up guys I got the 10 fold+ speed-up. I think this function is ready to use!

e = dem_lisbon_raster
r = lisbon_road_segments[1:100, ]
res = bench::mark(check = FALSE,
  raster_bilinear = {slope_raster(r, e)},
  raster_simple = {slope_raster(r, e, method = "simple")}
)
# ?bench::mark
res
#> # A tibble: 2 x 6
#>   expression           min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>      <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 raster_bilinear  12.12ms  12.93ms      77.8    7.73MB     21.5
#> 2 raster_simple     6.49ms   6.78ms     146.     5.68MB     25.6
Robinlovelace commented 4 years ago

One question for @temospena, can you try to find out how many routes per second ArcMap calculates? Will be interesting comparison and we could update this section with the result: https://github.com/ITSLeeds/slopes/blob/master/README.Rmd#L94