
74 Accelerating MATLAB
®
Performance
impact on performance that would far outweigh any benet gained from the improved
memory access.
3.1.8 Minimize Dereferencing
Accessing object properties/methods, array elements, and structure elds incurs a run-
time processing overhead (including boundary and security checks). Depending on the
frequency of the usage, the loop size and the average iteration run-time, this overhead can
be a signicant portion of the loop’s total run-time.
The simple act of caching such indirect data accesses in a simple variable negates this
performance penalty and can often bring about important speedups:*
% Simple loop accessing ...