The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Benchmarking slopes calculation

library(slopes)
library(bench)

Performance

A benchmark can reveal how many route gradients can be calculated per second using different interpolation methods:

e = dem_lisbon()
r = lisbon_road_network
res = bench::mark(check = FALSE,
  bilinear = slope_raster(r, e),
  simple   = slope_raster(r, e, method = "simple")
)
res
#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 bilinear     21.2ms   21.8ms      45.5   17.89MB     33.1
#> 2 simple       18.3ms   18.7ms      53.0    1.88MB     35.4

That is approximately

round(res$`itr/sec` * nrow(r))
#> [1] 12335 14376

routes per second using bilinear and simple interpolation methods, respectively.

To go faster, you can chose the simple method to gain some speed at the expense of accuracy:

res2 = bench::mark(check = FALSE,
  bilinear = slope_raster(r, e, method = "bilinear"),
  simple   = slope_raster(r, e, method = "simple")
)
res2
#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 bilinear     21.7ms   22.7ms      44.2    1.73MB     29.5
#> 2 simple       18.8ms   19.3ms      50.8    1.81MB     39.1
round(res2$`itr/sec` * nrow(r))
#> [1] 11973 13764

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.