Benchmark 1

# 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
## 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.
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)
## 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…  7.72m  7.72m  0.00216     33.7GB    0.237
## 2 landscapemetrics3::calculate_lsm(l… 18.81m 18.81m  0.000886    54.4GB    0.124
beepr::beep()
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)
## 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(lan… 1.64s  1.84s     0.537    28.1MB    0.751
## 2 landscapemetrics3::calculate_lsm(la… 7.12s  7.63s     0.131    45.6MB    0
beepr::beep()