Skip to content

Instantly share code, notes, and snippets.

@lrasmus
Created January 15, 2019 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrasmus/13131f58c46345f167ac6b6035e5af7c to your computer and use it in GitHub Desktop.
Save lrasmus/13131f58c46345f167ac6b6035e5af7c to your computer and use it in GitHub Desktop.
R GC timing
library(microbenchmark)
cat(version$major, version$minor)
createdf <- function() {
x <- runif(100000)
y <- runif(100000)
z <- runif(100000)
df <- data.frame(x = x, y = y, z = z)
gc()
}
microbenchmark(createdf(), times = 1000)
@lrasmus
Copy link
Author

lrasmus commented Jan 15, 2019

Results indicate forced GC for each iteration is slower in R 3.5+

3 4.3Unit: milliseconds
       expr      min      lq     mean   median       uq      max neval
 createdf() 14.26464 15.1249 15.94736 15.70314 16.50341 39.91744  1000

3 5.2Unit: milliseconds
       expr      min       lq    mean  median       uq      max neval
 createdf() 22.11165 24.02668 24.6672 24.3578 25.05036 44.39232  1000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment