Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save laurajanegraham/208df503057e9831161f05887af392f8 to your computer and use it in GitHub Desktop.
Save laurajanegraham/208df503057e9831161f05887af392f8 to your computer and use it in GitHub Desktop.
Does suppressing output save time?
f1 <- function() {
y <- system.time(x <- rnorm(10000, 0, 1))
z <- mean(x)
print(y)
print(z)
}
f2 <- function() {
y <- system.time(x <- rnorm(10000, 0, 1))
z <- mean(x)
}
microbenchmark::microbenchmark(f1(), f2(), times = 500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment