Skip to content

Instantly share code, notes, and snippets.

@rmflight
Created October 5, 2018 14:56
Show Gist options
  • Select an option

  • Save rmflight/241876cba79b5d5352f645a3c482daa7 to your computer and use it in GitHub Desktop.

Select an option

Save rmflight/241876cba79b5d5352f645a3c482daa7 to your computer and use it in GitHub Desktop.
x = rnorm(500)
library(microbenchmark)
microbenchmark(
replicate(5000, sample(x)),
do.call(c, purrr::map(seq(1, 5000), function(.x){sample(x)}))
)
#Unit: milliseconds
#expr
#replicate(5000, sample(x))
#do.call(c, purrr::map(seq(1, 5000), function(.x) { sample(x) }))
#min lq mean median uq max neval
#75.48671 89.02109 118.58633 96.94587 127.36513 267.1767 100
#68.85197 75.65118 91.94416 80.93999 89.59123 196.6865 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment