Installation guide

Profiling fo r Improving Performance
Profiling for Improving Performance
In this section...
“What Is Profiling?” on page 7-27
“Profiling Proces s and Guidelines” on page 7-28
“Using the Profiler” on page 7-29
“Profile Summary Report” on page 7 -33
“Profile Detail Report” on page 7-35
“The profile Function” on page 7-42
What Is Profiling?
Profiling is a way to measure where a program spends time. To a ssist
you in profiling, MATLAB provides a graphical user interface, called the
Profiler, which is based on the results returned by the
profile function.
Once you identify which functions are consuming the most time, you can
determin e why you are callin g them and look for ways to minimize their
useandthusimproveperformance. Itisoftenhelpfultodecidewhether
the number of times a particular function is called is reasonable. Because
programs often have several layers, your code may not explicitly call the
most time-consuming functions. Rather, functions within your code might
be calling other time-consuming functions that can be several layers down
in the code. In this case it is important to determ ine which of your functions
are responsible for such calls.
Profiling helps to uncover performance problems that you can solve by
Avoiding unnecessary computation, which can arise from oversight
Changing your algorithm to avoid costly functions
Avoiding recomputation by storing results for future us e
When yo u re ach the point where most of the time is spent on calls to a small
number of built-in functions, you have probably optimized the code as much
as you can expect.
7-27