Re: [R] R perfomance question !!!

From: Ben Bolker <bolker_at_ufl.edu>
Date: Wed, 18 Jun 2008 20:14:54 +0000 (UTC)

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 18 Jun 2008 - 21:10:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 18 Jun 2008 - 21:31:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive