Benchmark 4
# 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")
whats <- c("lsm_l_ent")
window2 <- matrix(1, nrow = 15, ncol = 15)
bench::mark(landscapemetrics::window_lsm(landscape, window = window2, what = whats),
landscapemetrics3::window_lsm(landscape, window = window2, what = whats),
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::window_lsm(lands… 2.58m 2.58m 0.00647 5.87GB 0.0517
## 2 landscapemetrics3::window_lsm(land… 16.27m 16.27m 0.00102 6.07GB 0.132
landscape2 <- terra::rast(landscapemetrics::landscape)
# landscape <- terra::disagg(landscape, 4)
# landscape <- terra::aggregate(landscape, 4, fun = "modal")
window <- matrix(1, nrow = 3, ncol = 3)
bench::mark(landscapemetrics::window_lsm(landscape2, window = window, what = whats),
landscapemetrics3::window_lsm(landscape2, window = window, what = whats),
iterations = 10, check = FALSE)
## # A tibble: 2 × 6
## expression min median `itr/sec` mem_alloc `gc/sec`
## <bch:expr> <bch:t> <bch:t> <dbl> <bch:byt> <dbl>
## 1 landscapemetrics::window_lsm(lan… 140.5ms 244.6ms 4.45 4.65MB 0
## 2 landscapemetrics3::window_lsm(la… 1.97s 2.11s 0.449 5.28MB 0.300