CodeTools[Profiling] - Maple Programming Help

Home : Support : Online Help : Programming : Profiling : CodeTools[Profiling] : CodeTools/Profiling/Remove

CodeTools[Profiling]

 Remove
 remove procedures from a table of profiling data

 Calling Sequence Remove(selector, tab)

Parameters

 selector - boolean valued procedure tab - table of profiling data

Description

 • The Remove(selector, tab) command is similar to the remove function.  The boolean valued function selector is called on each element in tab.  A copy of tab is returned with the elements for which selector returns true removed.
 • The selector parameter is a procedure that accepts two arguments.  The first argument is the encoded name (see EncodeName) of the procedure and the second argument is the rtable containing the profiling data.

Examples

 > $\mathrm{with}\left(\mathrm{CodeTools}[\mathrm{Profiling}]\right):$
 > selector := proc(n,t)     # check the total number of function calls     if (t[1][1] > 5) then         return true;     else     return false;     end if; end proc;
 ${\mathrm{selector}}{≔}{\mathbf{proc}}\left({n}{,}{t}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{5}{<}{t}{[}{1}{]}{[}{1}{]}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{true}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{else}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{false}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > a := proc( )     return 1; end proc;
 ${a}{≔}{\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{1}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2)
 > b := proc( )     local i;     for i from 1 to 10 do         a();     end do; end proc;
 ${b}{≔}{\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{for}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{to}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{10}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{a}{}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (3)
 > $t≔\mathrm{Build}\left(\mathrm{procs}=\left[a,b\right],\mathrm{commands}='b\left(\right)'\right)$
 ${t}{≔}{\mathrm{table}}\left(\left[{\mathrm{_Inert_ASSIGNEDNAME}}{}\left({"a"}{,}{"PROC"}\right){=}\left[\begin{array}{rrr}{10}& {0}& {0}\\ {10}& {0}& {0}\end{array}\right]{,}{\mathrm{_Inert_ASSIGNEDNAME}}{}\left({"b"}{,}{"PROC"}\right){=}\left[\begin{array}{rrr}{1}& {0}& {0}\\ {1}& {0}& {0}\\ {10}& {0}& {0}\end{array}\right]\right]\right)$ (4)
 > $\mathrm{PrintProfiles}\left(t\right)$
 a a := proc()      |Calls Seconds  Words| PROC |   10   0.000      0|    1 |   10   0.000      0| return 1 end proc b b := proc() local i;      |Calls Seconds  Words| PROC |    1   0.000      0|    1 |    1   0.000      0| for i to 10 do    2 |   10   0.000      0|   a()                             end do end proc
 > $s≔\mathrm{Remove}\left(\mathrm{selector},t\right)$
 ${s}{≔}{\mathrm{table}}\left(\left[{\mathrm{_Inert_ASSIGNEDNAME}}{}\left({"b"}{,}{"PROC"}\right){=}\left[\begin{array}{rrr}{1}& {0}& {0}\\ {1}& {0}& {0}\\ {10}& {0}& {0}\end{array}\right]\right]\right)$ (5)
 > $\mathrm{PrintProfiles}\left(s\right)$
 b b := proc() local i;      |Calls Seconds  Words| PROC |    1   0.000      0|    1 |    1   0.000      0| for i to 10 do    2 |   10   0.000      0|   a()                             end do end proc