Re: [R] R badly lags matlab on performance?

2009-01-05 Thread luke
On Sun, 4 Jan 2009, Stavros Macrakis wrote: On Sun, Jan 4, 2009 at 4:50 PM, l...@stat.uiowa.edu wrote: On Sun, 4 Jan 2009, Stavros Macrakis wrote: On Sat, Jan 3, 2009 at 7:02 PM, l...@stat.uiowa.edu wrote: R's interpreter is fairly slow due in large part to the allocation of argument lists

Re: [R] R badly lags matlab on performance?

2009-01-04 Thread Philippe Grosjean
I wrote once the benchmark mentioned in Stefan's post (based on initial work by Stephan Steinhaus), and it is still available for those who would like to update it. Note that it is lacking some checking of the results to make sure that calculation is not only faster, but correct! Now, I'll

Re: [R] R badly lags matlab on performance?

2009-01-04 Thread Stavros Macrakis
On Sat, Jan 3, 2009 at 7:02 PM, l...@stat.uiowa.edu wrote: R's interpreter is fairly slow due in large part to the allocation of argument lists and the cost of lookups of variables, including ones like [- that are assembled and looked up as strings on every call. Wow, I had no idea the

Re: [R] R badly lags matlab on performance?

2009-01-04 Thread luke
On Sun, 4 Jan 2009, Stavros Macrakis wrote: On Sat, Jan 3, 2009 at 7:02 PM, l...@stat.uiowa.edu wrote: R's interpreter is fairly slow due in large part to the allocation of argument lists and the cost of lookups of variables, including ones like [- that are assembled and looked up as strings

Re: [R] R badly lags matlab on performance?

2009-01-04 Thread Peter Dalgaard
Stavros Macrakis wrote: On Sat, Jan 3, 2009 at 7:02 PM, l...@stat.uiowa.edu wrote: R's interpreter is fairly slow due in large part to the allocation of argument lists and the cost of lookups of variables, including ones like [- that are assembled and looked up as strings on every call. Wow,

Re: [R] R badly lags matlab on performance?

2009-01-04 Thread Stavros Macrakis
On Sun, Jan 4, 2009 at 4:50 PM, l...@stat.uiowa.edu wrote: On Sun, 4 Jan 2009, Stavros Macrakis wrote: On Sat, Jan 3, 2009 at 7:02 PM, l...@stat.uiowa.edu wrote: R's interpreter is fairly slow due in large part to the allocation of argument lists and the cost of lookups of variables, I'd

Re: [R] R badly lags matlab on performance?

2009-01-04 Thread Stavros Macrakis
Thanks for the explanations of the internals. I understand about the 'redefining log' problem in the interpreter, but I wasn't aware of the NAMED counter. In both cases, beyond static analysis, dynamic Java compilers do a pretty good job, but I don't know if Java bytecodes are suitable for R,

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Stefan Grosse
On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah ajays...@mayin.org wrote: AS system.time(for (i in 1:1000) {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. Another approach is just in

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ben Bolker
Ajay Shah ajayshah at mayin.org writes: Here's a small R program: --- a - rep(1,1000) system.time(a - a + 1) system.time(for (i in 1:1000) {a[i] - a[i] + 1})

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote: On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah ajays...@mayin.org wrote: AS system.time(for (i in 1:1000) {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

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ben Bolker
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:1000) {a[i] - a[i] + 1}) AS I wonder what we're doing wrong! it is no

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
As for jit and Ra, that was immediate reaction too but I found that jit does not help on your example. But I concur fully with what Ben said --- use the tool that is appropriate for the task at hand. If your task is running for loops, Matlab does it faster and you have Matlab, well then you

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ted Harding
On 03-Jan-09 18:28:03, Ben Bolker wrote: 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:1000) {a[i] - a[i] + 1}) AS I

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread hadley wickham
On Sat, Jan 3, 2009 at 12:37 PM, Ajay Shah ajays...@mayin.org wrote: As for jit and Ra, that was immediate reaction too but I found that jit does not help on your example. But I concur fully with what Ben said --- use the tool that is appropriate for the task at hand. If your task is running

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Stefan Grosse
I don't have octave (on the same machine) to compare these with. And I don't have MatLab at all. So I can't provide a comparison on that front, I'm afraid. Ted. Just to add some timings, I was running 1000 repetitions (adding up to a=1001) on a notebook with core 2 duo T7200 R 2.8.1 on

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Wacek Kusnierczyk
(Ted Harding) wrote: On 03-Jan-09 18:28:03, Ben Bolker wrote: 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

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Wacek Kusnierczyk
Ajay Shah wrote: As for jit and Ra, that was immediate reaction too but I found that jit does not help on your example. But I concur fully with what Ben said --- use the tool that is appropriate for the task at hand. If your task is running for loops, Matlab does it faster and you have

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Duncan Murdoch
On 03/01/2009 1:37 PM, Ajay Shah wrote: As for jit and Ra, that was immediate reaction too but I found that jit does not help on your example. But I concur fully with what Ben said --- use the tool that is appropriate for the task at hand. If your task is running for loops, Matlab does it

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread luke
On Sat, 3 Jan 2009, Duncan Murdoch wrote: On 03/01/2009 1:37 PM, Ajay Shah wrote: As for jit and Ra, that was immediate reaction too but I found that jit does not help on your example. But I concur fully with what Ben said --- use the tool that is appropriate for the task at hand. If your

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Dirk Eddelbuettel
On 3 January 2009 at 18:02, l...@stat.uiowa.edu wrote: | The current byte code compiler available from my web site speeds this | (highly artificial) example by about a factor of 4. The experimental | byte code engine I am currently working on (and that can't yet do much | more than an example