[Scilab-users] How to read profileGetInfo().LineCoverage results correctly?

classic Classic list List threaded Threaded
2 messages Options
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] How to read profileGetInfo().LineCoverage results correctly?

Dear all,

Still about new Scilab 6 profiling capabilities:
The first so-called ""Basic example" given in the documentation of  the profiling features
@ https://help.scilab.org/docs/6.1.0/en_US/profile.html  is the following:

// 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
profileEnable(foo);

// Executes the function
foo(200);

// Returns the function profiling results
prof = profileGetInfo();


Now, after https://help.scilab.org/docs/6.1.0/en_US/profileGetInfo.html we can get
--> prof.LineCoverage(1)
 ans  =
  -1.     0.                                    // function ...
   1.     0.6385544                    // if ...  Why so long time ??
   1.     0.6385513                    // x = 0;    638 ms for a single execution ??
   1.     0.6385467                    // idem
   200.   1.2763477                 // OK, quite expected. The strange thing is that the "x=0" time is almost the half of this time..
   200.   0.0005116                 // OK, a result more understandable than for x=0 above.
  -1.     0.                                   // OK (end for)
  -1.     0.                                   // OK (else)
   0.     0.                                    // OK : never met
  -1.     0.      
  -1.     0.      

Since it is presented as a basic example, it is likely error-proof.
So what am i missing about how to read or interpret these results ?

Thanks for any clarification. Without it, it quite hard to trust and use this important tool.
Best regards
Samuel Gougeon


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Clément David-3 Clément David-3
Reply | Threaded
Open this post in threaded view
|

Re: How to read profileGetInfo().LineCoverage results correctly?

Hello Samuel, hello all,

 

As a reminder and behind the introduction of profile-prefixed functions the idea is to implement functions similar to the ones available within Scilab-5 to:

  1. instrument a specific function
  2. get the counters in a Scilab structure
  3. de-instrument a specific function

 

So depending on your use you can covStart()/profileEnable() then profileGetInfo() then covStop() /profileDisable() to retrieve information about your execution. covStart() will clear previous instrumented information whereas profileEnable() allow to append functions (same difference between covStop() and profileDisable()). In term of arguments, covStart() allow string arguments (function names) whereas profileEnable() only take functions or libraries.

 

About numbers, well I think you get it right and I agree the lines 2,3 and 4 are not obvious ; there might be a bug there. 638ms for getting / setting a double scalar is not correct as well as the cumulated time `sum( prof(4)(1), 'r')` does not look like being in seconds (as stated in the documentation).

 

Clément

 

From: users <[hidden email]> On Behalf Of Samuel Gougeon
Sent: Thursday, January 28, 2021 2:44 PM
To: International users mailing list for Scilab. <[hidden email]>
Subject: [Scilab-users] How to read profileGetInfo().LineCoverage results correctly?

 

Dear all,

Still about new Scilab 6 profiling capabilities:
The first so-called ""Basic example" given in the documentation of  the profiling features
@ https://help.scilab.org/docs/6.1.0/en_US/profile.html  is the following:

// 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
profileEnable(foo);
 
// Executes the function
foo(200);
 
// Returns the function profiling results
prof = profileGetInfo();
 
 

Now, after https://help.scilab.org/docs/6.1.0/en_US/profileGetInfo.html we can get
--> prof.LineCoverage(1)
 ans  =
  -1.     0.                                    // function ...
   1.     0.6385544                    // if ...  Why so long time ??
   1.     0.6385513                    // x = 0;    638 ms for a single execution ??
   1.     0.6385467                    // idem
   200.   1.2763477                 // OK, quite expected. The strange thing is that the "x=0" time is almost the half of this time..
   200.   0.0005116                 // OK, a result more understandable than for x=0 above.
  -1.     0.                                   // OK (end for)
  -1.     0.                                   // OK (else)
   0.     0.                                    // OK : never met
  -1.     0.      
  -1.     0.      

Since it is presented as a basic example, it is likely error-proof.
So what am i missing about how to read or interpret these results ?

Thanks for any clarification. Without it, it quite hard to trust and use this important tool.
Best regards
Samuel Gougeon


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users