> Unsurprisingly the R loop (vacc1) is very slow, and proper > vectorisation speeds it up immensely. Interestingly, however, the C++ > loop still does considerably better (about 10x faster) - I'm not sure > exactly why this is the case, but I suspect it may be because it > avoids the many intermediate vectors that R requires.
A little bit of exploration on that theme: https://gist.github.com/4111432 The R versions incur a cost of about 100µs for each additional intermediate vector, whereas the C++ cost is much smaller. Again, most of the time this isn't going to matter, but if you are trying to eke out every possible iota of speed, then rewriting already vectorised code in C++ may give significant speed increases if you have many intermediate values. Hadley -- RStudio / Rice University http://had.co.nz/ _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel