Created
April 22, 2013 13:13
-
-
Save hadley/5434786 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(microbenchmark) | |
options(digits = 2) | |
env <- environment(plot) | |
names <- ls(env) | |
microbenchmark( | |
as.list(env), | |
mget(names, env), | |
mget(ls(env), env)) | |
# Unit: microseconds | |
# expr min lq median uq max neval | |
# as.list(env) 47 50 52 53 94 100 | |
# mget(names, env) 35 37 38 39 54 100 | |
# mget(ls(env), env) 365 367 368 379 498 100 | |
env <- new.env() | |
env$x <- 1:10 | |
env$y <- 1:100 | |
microbenchmark( | |
as.list(env), | |
mget(c("x", "y"), env), | |
mget(ls(env), env)) | |
# Unit: microseconds | |
# expr min lq median uq max neval | |
# as.list(env) 3.9 4.2 4.7 5.3 21 100 | |
# mget(c("x", "y"), env) 1.9 2.3 2.5 2.7 22 100 | |
# mget(ls(env), env) 11.8 12.6 13.1 13.6 42 100 | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment