1.15.2011

MathWorks MATLAB vs. GNU Octave Speed/Performance Comparison

When I went back to school in 2009 after a year hiatus, I was forced by many classes to start using MATLAB. I of course did not want to use such closed-source software and immediately started using GNU Octave instead. Octave has been great and with the exception of a missing Simulink counterpart, has provided me with every capability needed. I however have been wondering how fast MATLAB is in comparison. I didn't think I'd get a chance...until I needed Simulink and had to install the student version at home.

Using an older laptop with a 32-bit 1.6 GHz Intel Core Duo processor, I installed and compared Octave 3.2.4 and MATLAB R2009b (on Windows). I have been learning some advanced numerical methods from the mechanical engineering department's CFD expert and selected five different homework problems for testing purposes. They all solve the same problem and all use the same initial conditions but use different algorithms obviously. I ran them all with both programs, recorded the times, and calculated the percent differences.

Conclusion: MATLAB will take non-vectorized loops and still give them almost full compiled performance. All of the partially vectorized scripts showed at least a 99.4% reduction in time when run in MATLAB. This translates to MATLAB being about 200-300 times faster than Octave for non-vectorized code. Even for code that was fully vectorized, MATLAB still showed a 2x improvement over Octave. In any case, MATLAB is definitely faster.

This is very disappointing...pretty much a slap in the face to open-source software. I am obviously a big proponent of open-source software, but I can't ignore these numbers. Anyway, while Octave is a nice piece of software, it's obviously too slow for use with anything more complicated than simpler homework assignments.

Edit: Since Filedropper.com sucks and lost my only copy of the data table, I have rerun the scripts on a different machine. This machine has the same clock speed, but is a single-core Intel Atom processor. The software versions and platforms are the same (32-bit Windows).

Edit 1/29/2012: I have re-uploaded the scripts so that anyone may try them. Download them here.

FileMATLAB*Octave*Speedup
HW3_16.1210.171.7
HW3_24.361092.4250.6
HW4_15.55777.6140.1
HW4_20.6884.1123.7
HW51.8366.2203.4
* = time in seconds

The improvement on a single-core processor is of course slightly less than that of the Core Duo; I'm sure that MATLAB automatically parallelizes a lot of the assignments and parts of the for loops. In any case, MATLAB is much, much faster than Octave.