[Contents] [TitleIndex] [WordIndex

1. SEP: advanced function/profiling in Scilab 6

2. Abstract

Scilab 6 introduced “coverage” functions and removed the legacy “profiling” functions, this SEP clarify the overall usage of such functionality and propose some extension to the Scilab 6.0.x functions: covStart, covMerge, covStop and covWrite. “coverage” did not aim to replace the “profiling” functionality but as both terms are related to the same “dynamic code analysis” area this led to some confusion; in this SEP, we will clarify the expected behaviors and describe a way to implement both “coverage” (the degree to which the source code is executed on a particular execution) and “profiling” (the frequency of each line of the source code) on top of the execution counters used to track execution time in Scilab 6.

3. Requirements

The initial idea is to have more information on a Scilab specific execution. Without any dedicated support, the user is left to guess where the code spent most of its time. “profiling” an execution should give insights on the execution by giving timing information back to the user as Scilab values and providing an easy way to visualize these timings. A specific analysis could also be written using Scilab to generate dedicated reports. “coverage” of an execution is such a dedicated report; it writes an HTML report of an execution in the form of a code line coverage.

The functions dedicated to the coverage are preserved as in 6.0.x and could be mixed with the profiling ones. The following functions are added or reserved for profiling:

The following names are reserved for a future implementation:

/!\ comparing to the Scilab 5 implementation, the functionalities are all prefixed with a profile name to clarify the topic.

Sub-functions (functions defined in the same macro file but private to the macro file) or inner-function (functions defined within another function) are handled as independe

The following bugs have been entered on Bugzilla to track similar or related problems/wishlist:

3.2. Mailing list threads

3.3. Other software

4. Examples

   1 // Function to be profiled
   2 function x=foo(n)
   3   if n > 0 then
   4     x = 0;
   5     for k = 1:n
   6       s = svd(rand(n, n));
   7       x = x + s(1);
   8     end
   9   else
  10     x = [];
  11   end
  12 endfunction
  14 // Enables the profiling of the function
  15 profileEnable(foo)
  17 // Executes the function
  18 foo(200);
  20 // Returns the function profiling results
  21 prof = profileGetInfo();


2022-09-08 09:27