
79Standard Performance-Tuning Techniques
If the assumptions are ever broken, MATLAB falls back to using the interpreted version
of code, but then the loop runs signicantly slower (see §4.1.4). We can place a tic-toc pair
(§2.2.1) within the loop to see JIT’s effect on iteration run-time. We will see that iterations
#10+ run much faster than iteration #1.
On a relatively modern MATLAB release, many simple loops now run at speeds compa-
rable with vectorization (Chapter 5). Vectorization still has an edge, since it employs multi-
threading on multicore CPUs, as well as CPU-level SIMD accelerations. But when these are
not a factor, JIT-ted loops can ...