Benchmark 3

# online
# remotes::install_github("r-spatialecology/landscapemetrics@basemetrics3")
# remotes::install_github("r-spatialecology/landscapemetrics@commoncalcs")
# or locally
devtools::load_all("~/Software/landscapemetrics3")
## ℹ Loading landscapemetrics3
## Starting from v2.0.0, landscapemetrics does not support the 'raster' or 'sp' packages.
##     They are replaced by 'terra' and 'sf', respectively. More information
##     about the 'terra' package can be found here: https://rspatial.org/index.html.
devtools::load_all("~/Software/landscapemetrics")
## ℹ Loading landscapemetrics
landscape <- terra::rast(landscapemetrics::augusta_nlcd)
# landscape <- terra::disagg(landscape, 4)
# landscape <- terra::aggregate(landscape, 4, fun = "modal")
bench::mark(landscapemetrics::calculate_lsm(landscape, verbose = FALSE),
            landscapemetrics3::calculate_lsm(landscape, verbose = FALSE),
            iterations = 1, check = FALSE)
## Warning: Some expressions had a GC in every iteration; so filtering is
## disabled.
## # A tibble: 2 × 6
##   expression                             min median `itr/sec` mem_alloc `gc/sec`
##   <bch:expr>                          <bch:> <bch:>     <dbl> <bch:byt>    <dbl>
## 1 landscapemetrics::calculate_lsm(la…  2.99m  2.99m  0.00557     30.2GB    0.485
## 2 landscapemetrics3::calculate_lsm(l… 17.31m 17.31m  0.000963    54.4GB    0.136
landscape2 <- terra::rast(landscapemetrics::landscape)
# landscape <- terra::disagg(landscape, 4)
# landscape <- terra::aggregate(landscape, 4, fun = "modal")
bench::mark(landscapemetrics::calculate_lsm(landscape2, verbose = FALSE),
            landscapemetrics3::calculate_lsm(landscape2, verbose = FALSE),
            iterations = 10, check = FALSE)
## # A tibble: 2 × 6
##   expression                            min  median `itr/sec` mem_alloc `gc/sec`
##   <bch:expr>                       <bch:tm> <bch:t>     <dbl> <bch:byt>    <dbl>
## 1 landscapemetrics::calculate_lsm… 511.68ms 629.2ms     1.39     25.4MB    0.927
## 2 landscapemetrics3::calculate_ls…    6.67s    7.2s     0.127    45.6MB    0