Skip to content

Old Dell running faster than new MacBook

10 messages · wouter.buytaert at scarlet.be, Nils Rüfenacht, Simon Urbanek +3 more

#
I recently changed from a 4 year old Dell running on Windows XP to a  
mew MacBook Pro running on OS X 10.5. I expected to save an amount of  
runtime when executing my R code now, but I was mistaken.

I didn't figure out what the problem could be! Same code is running  
about 30% (!) slower now!

Any suggestions?

N.R.
#
Hi Nils,

try R from the terminal with X11 graphics instead of R.app. I've noticed 
it is often much faster, also for non-graphics stuff.

cheers
wouter
On Fri, 24 Oct 2008, Nils R?fenacht wrote:

            
#
On Oct 24, 2008, at 4:07 PM, Nils R?fenacht wrote:

            
What about sharing the code with us? There is very little we can say  
unless you share the code with us as well as the exact machine specs  
(and compare the same version of R).

Cheers,
Simon
#
Thanks for your replies.

There's nothing special about my code (I guess), but here it is.


indexGenerator <-  
function(mue,sigma,duration,numOfSimulations,timeStep =  
1/252,nameBasis="Index"){

     m   <- mue
     s   <- sigma
     T   <- duration
     dt  <- timeStep
     n   <- numOfSimulations

     # dataMatrix contains n simulations over T+1 years (from 0 to T)
     dataMatrix      <- matrix(1,nrow=n,ncol=T+1)

     YearEndIndex    <- seq(1:T)/dt + 1

     PTIME <- proc.time()
     for(i in 1:n){

         Index_all   <- seq(0,T,by=dt) + 1
         Index_YE    <- seq(1:(T+1))
         time        <- seq(0,T,by=dt)

         ZFZ <- rnorm(length(Index_all)-1,0,1)

         for(t in 2:length(Index_all)){
             Index_all[t] <- Index_all[t-1] + m*Index_all[t-1]*dt +  
s*Index_all[t-1]*sqrt(dt)*ZFZ[t-1]
         }

         print(paste("Simulation",i,"of",n,"done."),quote=FALSE)
         dataMatrix[i,2:(T+1)] <- t(Index_all[YearEndIndex])
     }

     tableName <- "dummy"
     write.table(dataMatrix,tableName,sep = ";")

     print(proc.time()-PTIME)
}


Without running any other program in the background yields (on my Mac)

 > indexGenerator(0.08,0.15,30,100)
    user  system elapsed
  19.739   0.220  19.961
 > indexGenerator(0.08,0.15,30,1000)
    user  system elapsed
197.721   2.138 199.012
 >

I figured out that the function can be made faster by rewriting the  
code but this doesn't answer my question why my MacBook is slower.  
Here some specifications:

	Modell-Identifizierung:	MacBookPro4,1
   	Prozessortyp:	Intel Core 2 Duo
   	Prozessorgeschwindigkeit:	2.4 GHz
   	Anzahl der Prozessoren:	1
   	Gesamtzahl der Kerne:	2
   	L2-Cache:	3 MB
   	Speicher:	2 GB
	Systemversion:	Mac OS X 10.5.5 (9F33)
   	Kernel-Version:	Darwin 9.5.0

Before I used a Dell Inspirion 510, running on Windows XP with a 1.7  
GHz processor and some lousy 512 MB RAM.

The R-version in use is 2.8.o

Cheers,
Nils



Am 25.10.2008 um 16:41 schrieb Simon Urbanek:
#
On Oct 25, 2008, at 1:23 PM, Nils R?fenacht wrote:

            
Well, the only special thing about it is that it's pure interpreted  
code so it cannot take advantage of anything in R.
However, I'm surprised about your timings - are you sure you're not  
throttling the CPU? See the energy savings preferences - it seems as  
if you're running in a battery saving mode so the CPU is at half its  
speed. This is what I get:

mini, Intel Code 1.66GHz (so much slower than yours):
    user  system elapsed
  15.321   0.123  15.764

iMac, Intel Core 2 Duo 2.8GHz (a bit faster than yours):
    user  system elapsed
   8.602   0.067   8.708

Given the kind of code, you cannot expect any magic, because it  
doesn't use memory or multiple cores, so even the most recent,  
expensive machines won't be much faster. Raw clock speed is what  
matters here (whether old Pentium or latest Xeon won't matter  
much ;)). Given the results above, I'd expect your machine to clock  
somewhere around 10s. I have compared it to other OSes and the results  
are consistent ...

Cheers,
Simon
#
A 2.6 MacBook Pro, 2G, just to check differences between R and R.app.
Not completely fair, R.app runs in 64 bit, R in Terminal in 32 bit.

Stiil, always interesting to check now and then.

Rob


R.app (64 bit):
=====

 > indexGenerator(0.08,0.15,30,100)
[1] Simulation 1 of 100 done.
[1] Simulation 2 of 100 done.
...
[1] Simulation 99 of 100 done.
[1] Simulation 100 of 100 done.
    user  system elapsed
   8.266   0.216   8.631

(iGen comments out the print statement.)

 > iGen(0.08,0.15,30,100)
    user  system elapsed
   8.219   0.220   8.635
 > iGen(0.08,0.15,30,100)
    user  system elapsed
   8.202   0.227   8.567

 > indexGenerator(0.08,0.15,30,1000)
[1] Simulation 1 of 1000 done.
[1] Simulation 2 of 1000 done.
...
[1] Simulation 999 of 1000 done.
[1] Simulation 1000 of 1000 done.
    user  system elapsed
  83.898   1.443  98.678
 >

(iGen again.)

 > iGen(0.08,0.15,30,1000)
    user  system elapsed
  81.026   1.306  82.828
 > iGen(0.08,0.15,30,1000)
    user  system elapsed
  80.688   1.311  82.535
 >

R in Terminal (32 bit):
===========

 > indexGenerator(0.08, 0.15, 30, 100)
[1] Simulation 1 of 100 done.
[1] Simulation 2 of 100 done.
...
[1] Simulation 99 of 100 done.
[1] Simulation 100 of 100 done.
    user  system elapsed
   9.107   0.099   9.283
 >

 > indexGenerator(0.08, 0.15, 30, 100)
[1] Simulation 1 of 100 done.
[1] Simulation 2 of 100 done.
...
[1] Simulation 999 of 1000 done.
[1] Simulation 1000 of 1000 done.
    user  system elapsed
  91.582   1.199  94.543

 > indexGenerator(0.08, 0.15, 30, 100)
[1] Simulation 1 of 1000 done.
[1] Simulation 2 of 1000 done.
...
[1] Simulation 999 of 1000 done.
[1] Simulation 1000 of 1000 done.
    user  system elapsed
  92.544   3.551 101.139
 >

I did do some other work during this last run in the Terminal.
In fact TimeMachine kicked in and I read some more email.
On Oct 25, 2008, at 11:42 AM, Simon Urbanek wrote:

        
On Oct 25, 2008, at 1:06 PM, Byron Ellis wrote:

            
#
On 26/10/2008, at 4:23 AM, Nils R?fenacht wrote:

            
I have a 1 year old iMac 2 Ghz. The  indexGenerator(0.08,0.15,30,1000)  
call takes about 121s in . For comparison I ran the Windows version  
under Parallels and it also takes about 120s.

I think you have a sick MacBook, look for a benchmarking program  
(maybe geekBench) and compare against others, or contact your Apple  
dealer and see what they suggest.

Ken
#
Thanks for all your replies.

I now know what made the difference (but still can't believe it!!!).  
Before I was running with the mains adapter only whereas the battery  
was removed. If the battery is inserted and the adapter is connected  
the runtime decreases "dramatically" even on my MacBook.

Battery INSERTED:
indexGenerator(0.08,0.15,30,100): 10.242
indexGenerator(0.08,0.15,30,1000): 100.875

Battery REMOVED:
indexGenerator(0.08,0.15,30,100): 19.779
indexGenerator(0.08,0.15,30,1000): 197.375

Would anyone have expected that? Sorry, but me I wouldn't.

Cheers,
Nils




Am 26.10.2008 um 07:54 schrieb Ken Beath:
#
On Oct 26, 2008, at 5:21 AM, Nils R?fenacht wrote:

            
Yes, if your energy settings are to save battery as I said in the  
original reply. You can choose which mode you want to use (from  
battery saving to best performance - and you can even create a custom  
mode), so it's up to you whether you want battery life or fast  
benchmarks ;). Note that the settings are customizable for both batter  
and adapter power.

Cheers,
Simon