SortBy - Maple Help

CodeTools[Profiling]

 SortBy
 analyze and display profiling data

 Calling Sequence SortBy(proc1, proc2, ..., tab1, tab2, ..., opts)

Parameters

 proc1, proc2, ... - (optional) procedure tab1, tab2, ... - (optional) table opts - (optional) equation(s) of the form option=value where option is one of 'number', 'order', or 'statements'; specify options for the SortBy command

Description

 • The SortBy() command analyzes the profiling data for all the procedures for which data is available and prints the results.
 • The SortBy(proc1, proc2, ...) command analyzes the profiling data for the specified procedures and prints the results.
 • The SortBy(proc1, proc2, ..., tab1, tab2, ...) command analyzes the profiling data for the specified procedures and tables and prints the results.
 • The opts parameter can contain any of the following equations that specify options for the SortBy command.
 'number' = nonnegative integer
 Specifies the number of items displayed.  The number option can be used to control the maximum number of items displayed.  If $\mathrm{number}=n$, the top n elements are selected after the items have been sorted.
 'order' = value
 Specifies how to sort the table.  If order is not specified, then the default is rload.
 The optional argument order can be any one of the following:

 alpha   -  sort table alphabetically by function name ralpha  -  sort table reverse alphabetically by function name time    -  sort table by increasing cpu time usage rtime   -  sort table by decreasing cpu time usage words   -  sort table by increasing memory usage rwords  -  sort table by decreasing memory usage calls   -  sort table by increasing number of calls to each function rcalls  -  sort table by decreasing number of calls to each function load    -  sort table by increasing memory^2*time rload   -  sort table by decreasing memory^2*time

 'statements' = true or false
 Specifies whether to analyze procedures or statements.  If statements=true is specified, then the SortBy function analyzes the statements instead of procedures.   All the statements of the procedures are considered.
 • When displaying statements, the procedure name, statement number, and an abbreviation of the statement are provided with the profiling information.
 • It is possible that the total number of words used or the total time taken is zero.  In this case, the percent times and percent words are always zero, and the total percent time and the total percent words is 100%. If either of these events occur, SortBy prints a warning message.

Examples

 > a := proc( )     local i;     for i to 25 do     int( sin(exp(x^i)), x );     end do; end proc:
 > b := proc( )     local i;     for i to 30 do     int( tan(exp(x^i)), x );     end do; end proc:
 > c := proc( )     a();     b(); end proc:
 > $\mathrm{with}\left({\mathrm{CodeTools}}_{\mathrm{Profiling}}\right):$
 > $t≔\mathrm{Build}\left(\mathrm{procs}=\left[a,b,c\right],\mathrm{commands}='c\left(\right)'\right):$
 > $\mathrm{SortBy}\left(t\right)$
 function                 calls      time     time%          words    words% --------------------------------------------------------------------------- c                            1     0.000      0.00             12      0.00 a                            1     1.029     37.71       13245053     44.48 b                            1     1.700     62.29       16535466     55.52 --------------------------------------------------------------------------- total:                       3     2.729    100.00       29780531    100.00
 > $\mathrm{SortBy}\left(t,\mathrm{order}=\mathrm{time}\right)$
 function                 calls      time     time%          words    words% --------------------------------------------------------------------------- b                            1     1.700     62.29       16535466     55.52 a                            1     1.029     37.71       13245053     44.48 c                            1     0.000      0.00             12      0.00 --------------------------------------------------------------------------- total:                       3     2.729    100.00       29780531    100.00
 > $\mathrm{SortBy}\left(t,\mathrm{order}=\mathrm{words}\right)$
 function                 calls      time     time%          words    words% --------------------------------------------------------------------------- b                            1     1.700     62.29       16535466     55.52 a                            1     1.029     37.71       13245053     44.48 c                            1     0.000      0.00             12      0.00 --------------------------------------------------------------------------- total:                       3     2.729    100.00       29780531    100.00
 > $\mathrm{SortBy}\left(t,\mathrm{order}=\mathrm{load},\mathrm{statement}=\mathrm{true}\right)$
 function                 calls      time     time%          words    words% --------------------------------------------------------------------------- b                           30     1.700     62.29       16535466     55.52  stat 2) 2       int(tan(exp(x^i)),x) a                           25     1.029     37.71       13245053     44.48  stat 2) 2       int(sin(exp(x^i)),x) b                            1     0.000      0.00              0      0.00  stat 1) 1   for i to 30 do a                            1     0.000      0.00              0      0.00  stat 1) 1   for i to 25 do c                            1     0.000      0.00              6      0.00  stat 2) 2   b() c                            1     0.000      0.00              6      0.00  stat 1) 1   a(); --------------------------------------------------------------------------- total:                      59     2.729    100.00       29780531    100.00
 > $\mathrm{SortBy}\left(t,\mathrm{order}=\mathrm{load},\mathrm{number}=3,\mathrm{statement}=\mathrm{true}\right)$
 function                 calls      time     time%          words    words% --------------------------------------------------------------------------- b                           30     1.700     62.29       16535466     55.52  stat 2) 2       int(tan(exp(x^i)),x) a                           25     1.029     37.71       13245053     44.48  stat 2) 2       int(sin(exp(x^i)),x) b                            1     0.000      0.00              0      0.00  stat 1) 1   for i to 30 do --------------------------------------------------------------------------- total:                      59     2.729    100.00       29780519    100.00