CodeTools[Profiling][Coverage] - Maple Programming Help

Home : Support : Online Help : Programming : Profiling : CodeTools[Profiling] : Coverage : CodeTools/Profiling/Coverage/Percent

CodeTools[Profiling][Coverage]

 Percent
 calculate the percent coverage of procedures

 Calling Sequence Percent(proc1, proc1, ..., tab1, tab2, ..., opts)

Parameters

 proc1, proc2, ... - (optional) procedure tab1, tab2, ... - (optional) table opts - (optional) equation of the form 'depth'=posint and 'output'=value; specify options for the Percent command

Description

 • The Percent() command calculates and prints the coverage percent for every procedure for which it has profiling data.
 The coverage percent of a procedure is the number of lines covered divided by the total number of lines in the procedure.
 • The Percent(proc1, proc2, ...) command calculates and prints the coverage percent for the specified procedures.
 • Percent reads profiling data from currently profiled procedures and from any specified tables of profiling data.  If a procedure appears more than once in any of these sources, the profiles are joined together (as in Merge) and the data from the merged profiles is used.
 • The output option can be any of the following names that control the format in which the data is returned.
 'default'
 Specifies that Percent print the percent coverage.  Each line of the output has a procedure name followed by its percent coverage.  This is the default behavior.
 'string'
 Specifies that Percent return a string instead of printing the percent coverage.  The string is what is printed if you specify 'output'='default'.
 'table'
 Specifies that Percent return the percentages in a table.  This table has elements with the encoded name of a procedure (see EncodeName) as the key and the coverage percent, represented as a number in the range 0 to 1, as the value.
 • A statement is considered covered if it is executed greater than or equal to a certain number of times.  Use the 'depth' argument to specify the number of iterations required.
 'depth'=posint
 Specifies the number of times that a statement has to be executed to be considered covered.  The default is one.

Examples

 > a := proc(x)     local y;     if (x > 1) then         y := int(i^x, i);         return y;     else         y := int(sin(i), i);         return y;     end if; end proc:
 > $\mathrm{with}\left(\mathrm{CodeTools}[\mathrm{Profiling}]\right):$
 > $\mathrm{t1}≔\mathrm{Build}\left(\mathrm{procs}='a',\mathrm{commands}='a\left(2\right)'\right):$
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1}\right)$
 a 60.00%
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},'\mathrm{output}'='\mathrm{string}'\right)$
 ${"a 60.00%"}$ (1)
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},'\mathrm{output}'='\mathrm{table}'\right)$
 ${\mathrm{table}}\left(\left[{\mathrm{_Inert_ASSIGNEDNAME}}{}\left({"a"}{,}{"PROC"}\right){=}\frac{{3}}{{5}}\right]\right)$ (2)
 > $\mathrm{t2}≔\mathrm{Build}\left(\mathrm{procs}='a',\mathrm{commands}='a\left(0\right)'\right):$
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},\mathrm{t2}\right)$
 a 100.00%
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},\mathrm{t2},'\mathrm{output}'='\mathrm{string}'\right)$
 ${"a 100.00%"}$ (3)
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},\mathrm{t2},'\mathrm{output}'='\mathrm{table}'\right)$
 ${\mathrm{table}}\left(\left[{\mathrm{_Inert_ASSIGNEDNAME}}{}\left({"a"}{,}{"PROC"}\right){=}{1}\right]\right)$ (4)
 > $\mathrm{t3}≔\mathrm{Build}\left(\mathrm{procs}='a',\mathrm{commands}='a\left(0\right)'\right):$
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},\mathrm{t2},\mathrm{t3},'\mathrm{depth}'=2\right)$
 a 60.00%
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},\mathrm{t2},\mathrm{t3},'\mathrm{depth}'=2,'\mathrm{output}'='\mathrm{string}'\right)$
 ${"a 60.00%"}$ (5)
 > $\mathrm{Coverage}[\mathrm{Percent}]\left(a,\mathrm{t1},\mathrm{t2},\mathrm{t3},'\mathrm{depth}'=2,'\mathrm{output}'='\mathrm{table}'\right)$
 ${\mathrm{table}}\left(\left[{\mathrm{_Inert_ASSIGNEDNAME}}{}\left({"a"}{,}{"PROC"}\right){=}\frac{{3}}{{5}}\right]\right)$ (6)