[R] microbenchmark
Christophe Genolini
cgenolin at u-paris10.fr
Mon Sep 16 14:11:45 CEST 2013
Hi the list,
I am using the function microbenchmark to measure the performance of some code. But I notice that
the first execution of the code takes much longueur than the next executions.
I compare it to several executions of the code :
--- 8< ----------
A <- matrix(1:9,3)
nbReroll <- 1000
temps <- matrix(NA,1000,2)
temps[,1] <- microbenchmark(colMeans(A),times=nbReroll)$time
for(j in 1:nbReroll){
temps[j,2] <- microbenchmark(colMeans(A),times=1)$time
}
--- 8< -----------
Here is a plot of the result I get.
- In red, temps[,1], that is microbenchmarck(...,times=1000)
- In blue temps[,2], that is for(i in 1:1000)microbenchmark(...times=1)
So why is there such a bid difference? What is the correct execution time for my instruction?
Christophe
--
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense
More information about the R-help
mailing list