MATLAB Performance Benchmarking for CLI and GUI Performance
Tags: matlab, performance, comparison, benchmark
Published: 2019-08-22 04:10:07

---
title: MATLAB Performance Benchmarking for CLI and GUI Performance
published: true
tags: matlab, performance, comparison, benchmark
canonical_url: https://www.featool.com/news/2019/08/20/Benchmarking-and-Performance-Comparison-of-MATLAB-Versions.html
---

Although the MATLAB core has essentially stayed the same throughout
the years, the MATLAB language and runtime has with every release been
extended with more functionality as well as featured significant
improvements to the interpreter and Just-In-Time (JIT) compilation
engine. As developer of the
[FEATool Multiphysics](https://www.featool.com) simulation toolbox for
MATLAB which features 10-years of both graphical user interface (GUI)
and command line interface (CLI) backwards compatibility (back to
R2009b), it would be very useful to be able to tell users with which
MATLAB version(s) is to be recommended for performance and/or other
reasons.

With this in mind, and as no official or comprehensive benchmarks of
MATLAB versions are available, both GUI and CLI script performance is
compared in the following for MATLAB versions R2011b (the subjectively
_snappiest_, most responsive, and currently preferred version in the
developers opinion) and R2019a (the latest version at the time of
writing). Timings and tests are performed with the FEATool
Multiphysics toolbox on a typical laptop with the Microsoft Windows 10
operating system and Intel CPU. The FEATool software is used for
benchmarking as the toolbox features a large number of pre-defined and
built-in validation test cases and fully automated (GUI) tutorials
which is used to automatically and consistently measure performance.

![FEATool Multiphysics MATLAB Simulation Toolbox](https://www.featool.com/images/featool-multiphysics-easy-to-use-gui.jpg)


## MATLAB GUI Performance

In the first step, the GUI model test suite is used for timing
runs. This test suite runs about 40 pre-defined multi-physics
simulation models (the test suite can be run by starting FEATool with
the `featool testt` command). The examples are completely automated so
that all GUI callbacks are automatically and consistently run just as
a user would manually do. The timing averages from five runs can be
seen in the table below.

<table>
  <thead style="border:1px solid #bdc1c4">
    <tr>
      <th style="border-right:none">MATLAB GUI Tutorial Tests</th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><i>R2019a</i></td>
      <td><i>R2011b</i></td>
    </tr>
    <tr>
      <td>3142 s</td>
      <td>2486 s</td>
    </tr>
  </tbody>
</table>

From the results it is clear that MATLAB R2011b runs significantly
faster (around 25%) than the latest version R2019a even with the
improved JIT optimization as the subsequent MATLAB versions have. Note
that the UI layout toolkit used by FEATool has been specifically
developed and written to run fast as possible using procedural code.
The Mathworks GUI Layout Toolbox was tested in development and at the
time shown to have significant overhead and cost due to the object
oriented design, and just not performant enough for moderately complex
GUIs such as the ones use by FEATool. (Note that due to backwards
compatibility the FEATool GUI toolkit only uses get(h, ...) and set(h,
...) calls, and not struct call options introduced with handle
graphics _hg2_. Also these results do not apply to the newer web
graphics backend which was not tested.)


## MATLAB CLI Performance

As these tests include everything from running the GUI to CAD geometry
and model pre-processing, mesh generation, linear equation solving,
plotting and visualization, we can not from the tests above
conclusively tell what is slower in newer versions of MATLAB. As
FEATool also is fully scriptable (one GUI action maps to an equivalent
MATLAB function) we can also run the tests without the GUI for
comparison, and the corresponding averaged results for 5 runs are
shown below (starting FEATool with `featool testm` runs all the
available script models in the
[FEATool examples](https://www.featool.com/doc/tutorials.html#ex_other)
directory).

<table>
  <thead style="border:1px solid #bdc1c4">
    <tr>
      <th style="border-right:none">MATLAB CLI Examples Tests</th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><i>R2019a</i></td>
      <td><i>R2011b</i></td>
    </tr>
    <tr>
      <td>812 s</td>
      <td>976 s</td>
    </tr>
  </tbody>
</table>

Without using any GUI functionality the results are now reversed with
MATLAB R2019a being somewhat faster. As the FEATool code base is both
[highly vectorized and optimized](https://www.featool.com/fem/2015/10/19/fem-assembly-and-solver-benchmarks),
and since Finite Element Analysis (FEA) simulations makes significant
use of pre-compiled numerical libraries and sparse linear solvers such
as BLAS, LAPACK, Umfpack etc. which are not really influenced by JIT
improvements, a quite modest 10% speedup is maybe what one can expect
from any JIT improvements (instead of a major increase in speed).

All in all with these simple tests we can indeed see that current
MATLAB JIT optimizations have resulted in a modest speed increase on
average, however older versions of MATLAB are significantly more
responsive for using GUI functionality. To FEATool users one can
therefore suggest using version 2011b when using the GUI, and as
FEATool supports saving and exporting models to standard MATLAB
m-script files, subsequent large scale simulations can be run on the
command line in a later version of MATLAB to take advantage of any
speed increases.