Romain rightly scolds me once again for me having forgotten about the fact that INTSXP != REALSXP, and conversion to NumericVector has a cost. So once we keep everything in int, there is no difference:
R> x <- 1L:10L R> benchmark(replications = 10000, + R = x + x, Rfun = funR(x, x), Rcpp = funRcpp(x, x)) test replications elapsed relative user.self sys.self user.child sys.child 1 R 10000 0.041 1.0000 0.04 0 0 0 3 Rcpp 10000 0.054 1.3171 0.05 0 0 0 2 Rfun 10000 0.054 1.3171 0.06 0 0 0 R> x <- 1L:1000L R> benchmark(replications=1000, R = x + x, Rfun = funR(x, x), Rcpp = funRcpp(x, x)) test replications elapsed relative user.self sys.self user.child sys.child 1 R 1000 0.008 1.3333 0.01 0 0 0 3 Rcpp 1000 0.006 1.0000 0.01 0 0 0 2 Rfun 1000 0.009 1.5000 0.01 0 0 0 R> x <- 1L:1000000L R> benchmark(replications=100, R = x + x, Rfun = funR(x, x), Rcpp = funRcpp(x, x)) test replications elapsed relative user.self sys.self user.child sys.child 1 R 100 0.436 1.5034 0.43 0.00 0 0 3 Rcpp 100 0.290 1.0000 0.18 0.11 0 0 2 Rfun 100 0.461 1.5897 0.44 0.01 0 0 R> Happier now? Dirk -- Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
