Skip to content

Instantly share code, notes, and snippets.

@casallas
Created December 31, 2014 04:06
Show Gist options
  • Save casallas/b82e8f2fb34a9a38293b to your computer and use it in GitHub Desktop.
Save casallas/b82e8f2fb34a9a38293b to your computer and use it in GitHub Desktop.
A small benchmark to compare the 'ans' and 'with' forms of 'freduce'
library(microbenchmark) # microbenchmark
library(pryr) # mem_used
library(ggplot2) # qplot
devtools::dev_mode(T)
benchmark_pipe_qplot <- function(x){
library(magrittr)
print(mem_used())
cat("------\n")
print(microbenchmark(x %>% qplot, times=10L))
detach("package:magrittr", unload=TRUE)
}
x <- rnorm(1e8) # 800 Mb, this may take a while...
cat("'with' method\n")
devtools::install_github("casallas/magrittr", ref="freduce_with_bmark", quick = T, quiet = T)
benchmark_pipe_qplot(x)
cat("'ans' method\n")
devtools::install_github("casallas/magrittr", ref="freduce_ans_bmark", quick = T, quiet = T)
benchmark_pipe_qplot(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment