Yesterday, I received my new Apple MacBook. It’s running a Core 2 Duo at 2.4 Ghz and it’s fast. Really fast!

Apparently, it’s very cool to show of the speed of R-Project on your system. Optimized .DLL files help to speed up your R on Windows systems (and possibly other systems as well) with respect to matrix transformations, which has led to enormous speed increases. So, let’s perform a speed-test of our own.

First of all, in the syntax below, the Matrix package is activated, using the require() command. Since we will be creating random data, we set the seed in order to receive the exact same data every time the test is run. This is done with set.seed(). The next line creates a matrix X, which in the last three lines is manipulated in different ways.

To test how long this takes, we enclose that matrix operations in the system.time() function, which clocks the operation.


require(Matrix)
set.seed(123)
X <- Matrix(rnorm(1e6), 1000)
system.time(for(i in 1:25) X%*%X)
system.time(for(i in 1:25) solve(X))
system.time(for(i in 1:10) svd(X))

This results in the following output:


> X <- Matrix(rnorm(1e6), 1000)
> system.time(for(i in 1:25) X%*%X)
user system elapsed
8.306 0.591 5.031
> system.time(for(i in 1:25) solve(X))
user system elapsed
8.933 1.331 6.684
> system.time(for(i in 1:10) svd(X))
user system elapsed
36.989 3.665 33.384

WOW! This is the fastest I've seen in real life, even faster than some of the desktops that I know people currently work with (i.e. my own). I'm however very sure that it is not the fastest possible, not to say compared with how fast future calculations will be.

Additionally, in the near future my MacBook will be configured with 4 Gb RAM, so I'm curious to find out whether or not this will result in an additional speed increase. I expect, however, most benefit from the additional RAM when doing binomial mixed effects models, so of course expect a comparative benchmark on that one as well as soon as the new RAM arrives.

So, in the meantime, you can use this code to do some benchmarks yourself, on various computers. Please post the results here, or discuss them in the R-Sessions Forum.

UPDATE:
I also tested my old Powerbook G4 (1.5 Ghz, 1.25 Gb RAM):

> set.seed(123)
> X <- Matrix(rnorm(1e6), 1000)
> system.time(for(i in 1:25) X%*%X)
user system elapsed
34.661 1.590 47.528
> system.time(for(i in 1:25) solve(X))
user system elapsed
37.184 1.656 51.516
> system.time(for(i in 1:10) svd(X))
user system elapsed
247.694 11.258 331.979

- - -- --- ----- --------

- - -- --- ----- --------
R-Sessions is a collection of manual chapters for R-Project, which are maintained on Curving Normality. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.
-------- ----- --- -- - -