On 9 September 2010 at 13:26, Rainer M Krug wrote: | -----BEGIN PGP SIGNED MESSAGE----- | Hash: SHA1 | | On 09/09/10 12:26, Christofer Bogaso wrote: | > Dear all, R offers integration mechanism with different programming | > languages like C, C++, Fortran, .NET etc. Therefore I am curious on, | > for heavy numerical computation which language is the fastest? Is | > there any study? I specially want to know because, if there is some | > study saying that C is the fastest language for numerical computation | > then I would change some of my R code into C. | | As far as I am aware, the two choices are C and Fortran - where it | depends on the calculations, which one is faster.
Could it get any more un-scientific and un-empirical? Maybe we should debate whether it is faster on Thursdays than on Wednesdays too ? FWIW the Rcpp package contains this benchmark example where (R and) C++ is faster than (R and) C. So it really all depends. If someone wants to contribute a Fortran version I'll gladly commit it too. test replications elapsed relative user.self sys.self 5 Rcpp_New_ptr(a, b) 10000 0.213 1.0000 0.21 0 1 R_API_optimised(a, b) 10000 0.233 1.0939 0.23 0 4 Rcpp_New_std(a, b) 10000 0.258 1.2113 0.26 0 3 Rcpp_Classic(a, b) 10000 0.445 2.0892 0.45 0 2 R_API_naive(a, b) 10000 1.179 5.5352 1.17 0 6 Rcpp_New_sugar(a, b) 10000 1.260 5.9155 1.26 0 All results are equal e...@max:~/svn/rcpp/pkg/Rcpp/inst/examples/ConvolveBenchmarks$ (That is a slightly reworked version from SVN and to be on CRAN soon. What is on CRAN looks a little different as it doesn't use the rbenchmark package.) Benchmark results are far from conclusive proofs but a carefully set-up study can highlight and illuminate differences and/or lack thereof. If Christopher has a particular problem in mind he should probably test and benchmark approaches to that problem. Lastly, the time the code runs is just one measure. For Rcpp we also aim to minimise the time it takes to _write_ the code to solve the problem. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.