[R] R performance
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Sun Jan 31 21:10:43 CET 2010
On Sun, Jan 31, 2010 at 7:55 PM, Marc Jekel <feuerwald at gmx.de> wrote:
> Dear R Fans,
>
> I was recently asking myself how quick R is in code execution.
R can be a million times quicker than C code. Badly written C code.
Next question...
> I have been
> running simulations lately that need quite a time for execution and I was
> wondering if it is reasonable at all to do more computational extensive
> projects with R. Of course, it is possible to compare execution time for the
> same code written in several languages but maybe someone has some experience
> on the subject?
The corollary to my first answer is that badly written R can be a
million times slower than well written R. There are lots of techniques
for writing faster (==better? discuss!) R code, including vectorizing
loops, writing parts in C or Fortran and so on. The one thing you need
to do first is...
Profile Your Code!
See help(Rprof). Also make sure you know how to tell what system
resources your program is using in terms of real and swap memory (you
didn't mention your platform - Unix or Windows?).
Eventually you will hit speed limits and CPUs aren't getting much
faster. But there are more of them, so you'll need to look into the
various parallel processing magic things, eg in the HPC Task View on
CRAN:
http://ftp.heanet.ie/mirrors/cran.r-project.org/web/views/HighPerformanceComputing.html
The future is very definitely multi-core.
Barry
More information about the R-help
mailing list