Skip to content

Instantly share code, notes, and snippets.

@romainfrancois
Last active August 29, 2015 14:01
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 romainfrancois/9a300acfc020afbf45d1 to your computer and use it in GitHub Desktop.
Save romainfrancois/9a300acfc020afbf45d1 to your computer and use it in GitHub Desktop.
Compilation times

This little benchmark compares the times it take to compile a really simple Rcpp example (the example you get from RStudio when you do new C++ file) with Rcpp and Rcpp11.

require(microbenchmark)
compile_Rcpp <- function(){
  Rcpp::sourceCpp("/tmp/timesTwo.cpp", rebuild = TRUE )
}
compile_Rcpp11 <- function(){
  attributes::sourceCpp( "/tmp/timesTwo.cpp" )
}

These timings come from my iMac running Mavericks.

> microbenchmark( Rcpp = compile_Rcpp(), Rcpp11 = compile_Rcpp11(), times = 10 )
Unit: seconds
   expr      min       lq   median       uq      max neval
   Rcpp 3.061308 3.068119 3.069977 3.071560 3.258582    10
 Rcpp11 1.475950 1.479628 1.480901 1.485374 1.512100    10
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int timesTwo(int x) {
return x * 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment