[R-SIG-Mac] Old Dell running faster than new MacBook
Nils Rüfenacht
nils.ruefenacht at bluewin.ch
Sat Oct 25 19:23:08 CEST 2008
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 24, 2008, at 4:07 PM, Nils Rüfenacht wrote:
>
>> 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?
>>
>
> 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
>
More information about the R-SIG-Mac
mailing list