Eric's Page

Matlab Speed on OS X, Win7, and Ubuntu

After getting a MacBook Pro, I quickly became frustrated with how slow Matlab runs on it. It's not just the GUI running on X11 but even basic loops running in console mode are significantly slower than the same loops run using the same UNIX version of Matlab on Ubuntu.  Here I'll give some of the numbers I've gotten running Matlab 2008a/b on the above listed OSes.

Simple FFT Loop

    N = 2^15;
    x = rand(1,N);

    for i = 1:5000
        X = fft(x);
    end

Timing Results:

OS
Matlab Vers.
Hardware
Median Time
Ratio
Ubuntu 8.10
7.6.0 (R2008a) UNIX
Thinkpad T61 [Core 2 Duo T9300 2.5GHz]
3.58 sec
-
Mac OS X 10.5 7.6.0 (R2008a) UNIX MacBook Pro 5,3 [Core 2 Duo P8800 2.66GHz]
13.73 sec
3.8x
Windows 7 RC
7.7.0 (R2008b) Windows
Thinkpad T61 [Core 2 Duo T9300 2.5GHz] 3.25 sec
0.9x
Windows 7 RC 7.7.0 (R2008b) Windows
MacBook Pro 5,3 [Core 2 Duo P8800 2.66GHz] 3.12 sec
0.9x


Sliding 2D Correlation

A novelty score for audio segmentation can be computed by correlating a checkerboard kernel with a frame-based self-similarity matrix.  A naive implementation is shown below:


    novelty = zeros(1,size(S,2)-size(CL,2));

    for i = 1:length(novelty)
        novelty(i) = sum(sum(CL.*S(:,i:i+L-1)));
    end

Array Sizes:

> whos
  Name                       Size                  Bytes  Class     Attributes

  CL                       432x432               1492992  double             
  S                        432x11454            39585024  double                     
  novelty                    1x11022               88176  double

Timing Results:           

OS
Matlab Vers.
Hardware
Median Time
Ratio
Ubuntu 8.10
7.6.0 (R2008a) UNIX
Thinkpad T61 [Core 2 Duo T9300 2.5GHz]
12.41 sec
-
Mac OS X 10.5 7.6.0 (R2008a) UNIX MacBook Pro 5,3 [Core 2 Duo P8800 2.66GHz]
54.06 sec
4.4x
Windows 7 RC
7.7.0 (R2008b) Windows
Thinkpad T61 [Core 2 Duo T9300 2.5GHz] 37.31 sec
3.0x
Windows 7 RC 7.7.0 (R2008b) Windows
MacBook Pro 5,3 [Core 2 Duo P8800 2.66GHz] 39.31 sec
3.2x


It's really disheartening to see Matlab perform so poorly on OS X, especially when the same exact version performs so well with Ubuntu.  The Windows version even performs pretty slowly compared to Ubuntu for this correlation loop.  It's too bad the X11 figure windows can get screwy on Ubuntu or else Ubuntu would easily be the preferred OS for running Matlab.