Question: How can I do some statistics on the indicators returned by CodeTools[Usage] ?

Hi everybody,

I want to compare the performances of a set of codes that realize the same operation.
The worksheet I use is organized this way

Code1 := proc(...) ... end proc:

Code2 := proc(...) ... end proc:

and so on.

It appears that the execution of the whole worksheet doesn't always return the same values for the different indicators, which means that the ranking of the codes can be affected

To obtain more precise indicators I thought do do some statistics.
I then replace each bloc by :

CodeX := proc(...) ... end proc:  # here X stands for 1, 2, ...
N := "some positive integer"
for n from 1 to N do
   "catch the values of the indicators"
end do:
"compute some statistics on the samples ot these indicator"

The problem is that Usage doesn't return any values but only does a printf.
I investigated two ways to circumvent this problem:

  1. - redirect the printings to file MyFile by using writeto(MyFile)
    - read MyFile
    - extract the numerical values of the indicators
    - compute the desired statistics
      It works well but it is far from being elegant
  2. - insert with(CodeTools) after the restart (within a separate block)
    - copy-paste the output of showstat(Usage) to define a new function, let's say MyUsage
    - insert at the correct place some lines like
             Tcpu := CodeTools:-FormatTime(result:-cputime)  (if my time of interest is the cpu time)
                          (this for all the indicators)
    - insert the line  [..., Tcpu, ...]; before the 'end proc' declaration;
      More elegant but it doesn't work
      I get the error   error (in T) DoUsage is not a command of the CodeTools package

Do you have some idea (beyond the first method above) of the way to catch the performance indicators that Usage computes ?

Thanks in advance


Please Wait...