Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.0 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.1.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Advanced functions > profiling > profile


Returns the profiling results of a function

Calling Sequence

c = profile(fun)



a Scilab function


a nx3 matrix containing the profiling results:

  • c(i,1) : number of times the line i of the function has been executed

  • c(i,2) : cumulated CPU time [in seconds] spent to execute the line i of the function

  • c(i,3) : Measurement of the interpreter effort to execute once the line i of the function [arbitrary unit]


To use profile on a function, the profiling of this function must have been first activated:

  • either by using the add_profiling command.

  • or if the function has beed defined with the deff command, by setting the optional argument of deff to "p".

Once the function executed, calling profile returns a matrix, where each row contains the profiling results for the corresponding function line (including the header line of the function), such as the number of calls, and the total CPU time spent in that line, and a measurement of the interpretor effort to execute the line, as following:

Number of callsTotal CPU time (s)Interpretor effort

Here we can see that the 3th line of the function has been called 300 times, for a total CPU time of 3.59 seconds.

Note: due to the precision limit of CPU time measure (typically one micro second), some executed lines which execution is very fast may appear with a CPU total time of 0.


// Function to be profiled
function x=foo(n)
  if n > 0 then
    x = 0;
    for k = 1:n
      s = svd(rand(n, n));
      x = x + s(1);
    x = [];

// Enables the profiling of the function

// Executes the function

// Returns the function profiling results

See Also

  • add_profiling — Enables the profiling of a function
  • deff — on-line definition of function
  • plotprofile — Displays the profiling charts of a function
  • showprofile — Outputs the function profiling results to the console
Report an issue
<< plotprofile profiling remove_profiling >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Fri Apr 11 14:07:05 CEST 2014