FUNCTION REFERENCE

profile

Collect function calls, elapsed time, source-line counts and optional call history.

Collect function calls, elapsed time, source-line counts and optional call history.

Syntax

profile on

Syntax

profile on -history -historysize 1000 -timer real

Syntax

profile off

Syntax

profile resume

Syntax

profile clear

Syntax

profile viewer

Syntax

p = profile('info')

Syntax

s = profile('status')

'on' clears statistics; 'resume' retains them. 'off', 'clear', 'info' and 'viewer' stop collection. Settings persist across clear. Options also work alone while off; -nohistory disables history. The viewer prints function, calls, total time and self time, sorted by total time. FunctionTable is an N-by-1 struct array (empty 0-by-1); builtin ExecutedLines is 0-by-3. FunctionHistory is 2-by-N, with entry/exit in row 1 and 1-based function index in row 2. Children and Parents provide FunctionTableIndex and the documented Index alias.

Example

profile on; x=sum([1 2]); profile off; p=profile('info'); p.FunctionTable.NumCalls   % 1

Differences from MATLAB: History defaults off with 1000000 events maximum; timestamp history is unsupported. All timers use the monotonic elapsed clock, retaining the selected real/cpu/performance name. ClockSpeed is 0 (unknown); ClockPrecision reports nominal nanosecond representation. TotalRecursiveTime is 0. The engine bounds retained functions to 1024, call graph edges to 4096, executed lines to 65536 and retained source to 16 MiB. No desktop viewer is opened. Profiling overhead affects measured times.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.