I ran the simple script bellow and received shoking results. It was complied for about 15 seconds !!! on modern Intel Core Duo computer. i=0; while(i<5000000) { i=i+1; } Using Visual Basic I can complete the same script (simple loop of 5000000 itterations) in 0.1 sec. Is it realy R not suitable for huge computing. -- View this message in context: http://www.nabble.com/R-perfomance-question-%21%21%21-tp17984154p17984154.html Sent from the R help mailing list archive at Nabble.com.
diver495 <ansolid <at> gmail.com> writes:> > > I ran the simple script bellow and received shoking results. It was complied > for about 15 seconds !!! on modern Intel Core Duo computer. > > i=0; > while(i<5000000) > { > i=i+1; > } > > Using Visual Basic I can complete the same script (simple loop of 5000000 > itterations) in 0.1 sec. > Is it realy R not suitable for huge computing.9.25 seconds for me. Every language has its strong and weak points, and every language has its idioms. Depending on what you want to do you may be able to figure out a way to do it quickly in R (and the folks on this list might be able to help). People do lots of "huge computing" in R, but brute-force approaches may be slow. For example sum(as.numeric(1:5e6)) takes 0.06 seconds while the equivalent summation i=0;s=0;system.time(while (i<5e6) { i <- i+1; s <- s+i }) takes 17 seconds. (While we're at it, the equivalent "for loop" to the while loop above system.time(for (i in 1:5e6) { }) takes 1.6 seconds on my machine) If Visual Basic does what you need, use it ... Ben Bolker
On 19/06/2008, at 2:38 AM, diver495 wrote:> > I ran the simple script bellow and received shokingYour spelling is pretty shoking too.> results. It was complied > for about 15 seconds !!! on modern Intel Core Duo computer. > > i=0; > while(i<5000000) > { > i=i+1; > } > > Using Visual Basic I can complete the same script (simple loop of > 5000000 > itterations) in 0.1 sec. > Is it realy R not suitable for huge computing.It helps to know what the <expletive deleted> you're doing. E.g.: > x <- rep(1,5e6) > system.time(sum(x)) user system elapsed 0.014 0.000 0.014 cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
Hi, diver495 wrote:> Using Visual Basic I can complete the same script (simple loop of 5000000 > itterations) in 0.1 sec. > Is it realy R not suitable for huge computing.If you are happy with Visual Basic, then there is no need for you to use R. In case your message was not a flamebait, it is well known that loops like these are often bottlenecks for R. There are many resources how to easily avoid them. See, for example, "S Programming by Venables and Ripley or John Chambers' book: Programming with data. Even searching the mail archive for subject like "avoid loops" might be helpful. You might also consider checking functions like apply, tapply, ... Best, Roland P.S. It seems there is also a good book available for scientific computing with Visual Basic: http://www.ibiblio.org/Dave/Dr-Fun/df200002/df20000210.jpg