1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) ????-2008 - INRIA
5 * Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO
7 * This file must be used under the terms of the CeCILL.
8 * This source file is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at
11 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
14 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="showprofile">
16 <refname>showprofile</refname>
17 <refpurpose>Outputs the function profiling results to the console</refpurpose>
20 <title>Calling Sequence</title>
21 <synopsis>showprofile(fun)</synopsis>
24 <title>Arguments</title>
29 <para>a Scilab function</para>
35 <title>Description</title>
37 To use <literal>showprofile</literal> on a function, the profiling of this function must have been first activated:
41 either by using the <link linkend="add_profiling">add_profiling</link> command.
46 or if the function has beed defined with the <link linkend="deff">deff</link> command, by setting the optional argument of <link linkend="deff">deff</link> to "p".
52 Once the function has been executed, calling <literal>showprofile</literal> outputs to the console the profiling results.
54 <para>For each function line (including the header of function), are printed the following informations, in order:
56 <listitem><para>the total number of times the line was called</para></listitem>
57 <listitem><para>the total CPU time spent in the line (in seconds)</para></listitem>
58 <listitem><para>a measurement of the interpretor effort to interpret the line</para></listitem>
59 <listitem><para>the number and source code of the line</para></listitem>
66 |1 |0 |0| 1: function x=fun(n)
67 |1 |0 |0| 2: if n > 0 then
69 |200|0.01|0| 4: for k = 1:n
70 |200|3.99|5| 5: s = svd(rand(n, n));
74 Here we can see that the 5th line of the function has been called 200 times, for a total CPU time of 3.99 seconds (and an effort of 5 to interpret the line).
77 <literal>show_profile</literal> looks like to <link linkend="profile">profile</link>, but <link linkend="profile">profile</link> returns a matrix with the profiling results, while <literal>show_profile</literal> only prints that results to the console.
80 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.
84 <title>Examples</title>
85 <programlisting role="example"><![CDATA[
86 // Function to be profiled
99 // Enables the profiling of the function
100 add_profiling("foo");
102 // Executes the function
105 // Prints the function profiling results to console
109 <refsection role="see also">
110 <title>See Also</title>
111 <simplelist type="inline">
113 <link linkend="add_profiling">add_profiling</link>
116 <link linkend="profile">profile</link>
119 <link linkend="plotprofile">plotprofile</link>
122 <link linkend="reset_profiling">reset_profiling</link>