[R] R badly lags matlab on performance?
Ben Bolker
bolker at ufl.edu
Sat Jan 3 19:28:03 CET 2009
Ajay Shah <ajayshah <at> mayin.org> writes:
>
> On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote:
> > On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah <ajayshah <at> mayin.org> wrote:
> >
> > AS> system.time(for (i in 1:10000000) {a[i] <- a[i] + 1})
> >
> > AS> I wonder what we're doing wrong!
> >
> > it is no secret that R does badly with loops. Thats why it is
> > recommended to use vectorized operations.
>
> But there's a big difference even on the vectorised version: a <- a +
> 1. Why should that be? Both systems should merely be handing down to
> the BLAS. The (stock) R install has a less carefully setup BLAS as
> compared with the (stock) matlab install?
See my other message. I'm suspicious of the real size of
the difference, I think the difference could well be
noise. Also, this particular bit of arithmetic doesn't
involve BLAS -- see arithmetic.c (dig down until you get to
integer_binary) ...
Ben Bolker
More information about the R-help
mailing list