knitr::opts_chunk$set(cache = FALSE, echo = TRUE, eval = FALSE)

Profiling and Benchmarking (1)

Profiling and Benchmarking (2)

microbenchmark::microbenchmark(
  loop = {
    a <- vector()
    for (i in 1:1000) a[i] <- runif(1)
  },
  vectorized = {
    a <- runif(1000)
  }
)

Profiling and Benchmarking (3)

If you have Rstudio version >=0.99.1208, then it has profiling as a menu item.

profvis::profvis({a <- rnorm(10000000)})

Profiling the spades call

Try it:

mySim <- simInit(
   times = list(start = 0.0, end = 2.0, timeunit = "year"),
   params = list(
     .globals = list(stackName = "landscape", burnStats = "nPixelsBurned")
   ),
   modules = list("randomLandscapes", "fireSpread", "caribouMovement"),
   paths = list(modulePath = system.file("sampleModules", package = "SpaDES"))
)
profvis::profvis({spades(mySim)})

When to profile

If you have used these tools, then:

Strategies for profiling



PredictiveEcology/SpaDES.Workshops documentation built on Jan. 30, 2021, 6:52 p.m.