Skip to content
Prev 208235 / 398502 Next

R performance

On Sun, Jan 31, 2010 at 7:55 PM, Marc Jekel <feuerwald at gmx.de> wrote:
R can be a million times quicker than C code. Badly written C code.
Next question...
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