Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Français - Português - 日本語 -

Please note that the recommended version of Scilab is 6.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.

Справка Scilab >> Функции > profiling > profile

profile

Returns the profiling results of a function

Calling Sequence

c = profile(fun)

Arguments

fun

a Scilab function

c

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]

Description

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
100
3000.10
3003.595
.........

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.

Examples

// 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);
    end
  else
    x = [];
  end
endfunction

// Enables the profiling of the function
add_profiling("foo");

// Executes the function
foo(200);

// Returns the function profiling results
profile(foo)

See Also

  • add_profiling — Enables the profiling of a function
  • deff — определение функции во время выполнения программы
  • plotprofile — Displays the profiling charts of a function
  • showprofile — Outputs the function profiling results to the console
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 02 14:01:18 CEST 2014