<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Arial">Dear all,</font></p>
<p><font face="Arial">Still about new Scilab 6 profiling
capabilities:<br>
The first so-called ""Basic example" given in the documentation
of the profiling features <br>
@ <a class="moz-txt-link-freetext" href="https://help.scilab.org/docs/6.1.0/en_US/profile.html">https://help.scilab.org/docs/6.1.0/en_US/profile.html</a> is the
following:<br>
</font></p>
<pre style="font-family:Monospaced;font-style:normal;font-size:14.0;"><span style="color:rgb(100,174,100);font-style:italic;">// Function to be profiled</span>
<span style="color:rgb(176,24,19);">function</span> <span style="color:rgb(131,67,16);font-weight:bold;">x</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(0,0,0);text-decoration:underline;">foo</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">n</span><span style="color:rgb(74,85,219);">)</span>
<span style="color:rgb(160,32,240);">if</span> <span style="color:rgb(131,67,16);font-weight:bold;">n</span> <span style="color:rgb(92,92,92);">></span> <span style="color:rgb(188,143,143);">0</span> <span style="color:rgb(160,32,240);">then</span>
<span style="color:rgb(131,67,16);font-weight:bold;">x</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">0</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(160,32,240);">for</span> <span style="color:rgb(0,0,0);">k</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">1</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(131,67,16);font-weight:bold;">n</span>
<span style="color:rgb(0,0,0);">s</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">svd</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(50,185,185);">rand</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">n</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(131,67,16);font-weight:bold;">n</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(131,67,16);font-weight:bold;">x</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(131,67,16);font-weight:bold;">x</span> <span style="color:rgb(92,92,92);">+</span> <span style="color:rgb(0,0,0);">s</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(160,32,240);">end</span>
<span style="color:rgb(160,32,240);">else</span>
<span style="color:rgb(131,67,16);font-weight:bold;">x</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(74,85,219);">]</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(160,32,240);">end</span>
<span style="color:rgb(176,24,19);">endfunction</span>
<span style="color:rgb(100,174,100);font-style:italic;">// Enables the profiling of the function</span>
<span style="color:rgb(50,185,185);">profileEnable</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);text-decoration:underline;">foo</span><span style="color:rgb(74,85,219);">)</span>;
<span style="color:rgb(100,174,100);font-style:italic;">// Executes the function</span>
<span style="color:rgb(0,0,0);text-decoration:underline;">foo</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">200</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(100,174,100);font-style:italic;">// Returns the function profiling results</span>
<span style="color:rgb(0,0,0);">prof</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">profileGetInfo</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">);
</span></pre>
<p>Now, after
<a class="moz-txt-link-freetext" href="https://help.scilab.org/docs/6.1.0/en_US/profileGetInfo.html">https://help.scilab.org/docs/6.1.0/en_US/profileGetInfo.html</a> we
can get <br>
--> prof.LineCoverage(1)<br>
ans =<br>
-1. 0. // function ...<br>
1. <font color="#ff8040">0.6385544</font>
// if ... <b>Why so long time ??</b><br>
1. <font color="#ff8040">0.6385513 </font>
// x = 0; 638 ms for a single execution ??<br>
1. <font color="#ff8040">0.6385467 </font>
// idem<br>
200. 1.2763477 // OK, quite expected. The
strange thing is that the "x=0" time is almost the half of this
time..<br>
200. 0.0005116 // OK, a result more
understandable than for x=0 above.<br>
-1. 0. // OK (end for)<br>
-1. 0. // OK (else)<br>
0. 0. // OK : never met<br>
-1. 0. <br>
-1. 0. <br>
<br>
Since it is presented as a basic example, it is likely
error-proof.<br>
So what am i missing about how to read or interpret these results
?<br>
</p>
<p>Thanks for any clarification. Without it, it quite hard to trust
and use this important tool.<br>
Best regards<br>
Samuel Gougeon<br>
<br>
<font face="Arial"> </font></p>
<div class="refsection">
<div class="programlisting"></div>
</div>
</body>
</html>