Control the built-in profiler.
profile on
Start the profiler, clearing all previously collected data if there is any.
profile off
Stop profiling. The collected data can later be retrieved and examined
with T = profile ("info")
.
profile clear
Clear all collected profiler data.
profile resume
Restart profiling without clearing the old data. All newly collected statistics are added to the existing ones.
S = profile ("status")
Return a structure with information about the current status of the
profiler. At the moment, the only field is ProfilerStatus
which is
either "on"
or "off"
.
T = profile ("info")
Return the collected profiling statistics in the structure T. The
flat profile is returned in the field FunctionTable
which is an
array of structures, each entry corresponding to a function which was called
and for which profiling statistics are present. In addition, the field
Hierarchical
contains the hierarchical call tree. Each node has an
index into the FunctionTable
identifying the function it corresponds
to as well as data fields for number of calls and time spent at this level
in the call tree.
See also: profshow, profexplore.
The following code
profile on; A = rand (100); B = expm (A); profile off; profile resume; C = sqrtm (A); profile off; T = profile ("info"); profshow (T);
Produces the following output
# Function Attr Time (s) Time (%) Calls -------------------------------------------------------- 40 sqrtm 0.072 32.75 2 2 expm 0.052 23.77 5 26 binary * 0.037 16.99 80 32 binary ^ 0.022 9.81 10 35 binary \ 0.014 6.17 5 33 binary + 0.011 4.79 41 1 rand 0.006 2.78 5 27 balance 0.003 1.24 5 24 binary / 0.001 0.45 10 28 norm 0.001 0.39 5 34 binary - 0.001 0.23 5 15 binary == 0.000 0.19 5 37 profile 0.000 0.13 7 16 trace 0.000 0.10 5 25 eye 0.000 0.03 11 21 diag 0.000 0.02 10 29 log2 0.000 0.02 5 30 max 0.000 0.01 5 10 strfind 0.000 0.01 5 3 nargin 0.000 0.01 17
Package: octave