
35Proling MATLAB
®
Performance
The reason for this is that while subFunc is now being run only once instead of 100
times, it is actually only the rst iteration which takes any signicant amount of time (at
least now that we have implemented our data-load caching mechanism). We still spend
nearly 0.9 s to read our data le, something that cannot be avoided.
Let’s turn our attentions to the loop’s remaining code line. Here we are recomputing the
maximal value of a constant data matrix, and then adding a nonconstant (random) value
to it. Instead, we can move the constant calculation term outside the loop:
function perfTest
newData = subFunc(); ...