CodeTools[Profiling]
SortBy
analyze and display profiling data
Calling Sequence
Parameters
Description
Examples
SortBy(proc1, proc2, ..., tab1, tab2, ..., opts)
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
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 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.
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:
with⁡CodeToolsProfiling:
t≔Build⁡procs=a,b,c,commands=c⁡:
SortBy⁡t
function calls time time% words words% --------------------------------------------------------------------------- c 1 0.000 0.00 12 0.00 a 1 1.334 40.35 14976709 42.91 b 1 1.972 59.65 19928190 57.09 --------------------------------------------------------------------------- total: 3 3.306 100.00 34904911 100.00
SortBy⁡t,order=time
function calls time time% words words% --------------------------------------------------------------------------- b 1 1.972 59.65 19928190 57.09 a 1 1.334 40.35 14976709 42.91 c 1 0.000 0.00 12 0.00 --------------------------------------------------------------------------- total: 3 3.306 100.00 34904911 100.00
SortBy⁡t,order=words
SortBy⁡t,order=load,statement=true
function calls time time% words words% --------------------------------------------------------------------------- b 30 1.972 59.65 19928190 57.09 stat 2) 2 int(tan(exp(x^i)),x) a 25 1.334 40.35 14976709 42.91 stat 2) 2 int(sin(exp(x^i)),x) c 1 0.000 0.00 6 0.00 stat 1) 1 a(); 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() b 1 0.000 0.00 0 0.00 stat 1) 1 for i to 30 do --------------------------------------------------------------------------- total: 59 3.306 100.00 34904911 100.00
SortBy⁡t,order=load,number=3,statement=true
function calls time time% words words% --------------------------------------------------------------------------- b 30 1.972 59.65 19928190 57.09 stat 2) 2 int(tan(exp(x^i)),x) a 25 1.334 40.35 14976709 42.91 stat 2) 2 int(sin(exp(x^i)),x) c 1 0.000 0.00 6 0.00 stat 1) 1 a(); --------------------------------------------------------------------------- total: 59 3.306 100.00 34904905 100.00
See Also
CodeTools[Profiling][Build]
CodeTools[Profiling][GetProfileTable]
CodeTools[Profiling][Merge]
CodeTools[Profiling][PrintProfiles]
CodeTools[Profiling][Profile]
Download Help Document