|
Calling Sequence
|
|
CodeTools[Usage](expression, options)
CodeTools[CPUTime](expression, options)
CodeTools[RealTime](expression, options)
CodeTools[GCTime](expression, options)
|
|
Parameters
|
|
expression
|
-
|
expression
|
options
|
-
|
optional arguments of the form keyword=value; keyword can be one of output, iterations, and quiet
|
|
|
|
|
Description
|
|
•
|
The Usage command records time and memory usage statistics for the evaluation of expression.
|
•
|
By default, usage statistics are printed and the result of the evaluation of expression is returned.
|
•
|
The option output=value can be given to return one of the statistics where value is one of realtime, cputime, gctime, gcrealtime, bytesused, bytesalloc, or output or, to specify multiple outputs, a list of any of these. Multiple outputs are returned in the order they are specified. If the output from evaluating expression is an expression sequence, it will be returned as a list if it appears in the middle of the outputs.
|
•
|
output may also be all to return a record containing all the statistics. In this case, the statistics are not printed by default. Memory is returned in bytes (with IEC binary prefixes) and time is returned in seconds.
|
•
|
You can specify an option of the form iterations = posint. This will cause expression to be evaluated the specified number of times, and all results other than bytesalloc to be divided by that same number (bytesalloc is returned unchanged). The default number of iterations is 1.
|
|
Alternatively, you can specify the option as iterations = t, where t is an amount of time expressed using the Units package. In this case, the Usage command will estimate the number of iterations that takes the given amount of real time. Estimating this number takes some time itself; if this estimation process takes close to the amount of time requested, no subsequent run is made anymore. More information about this estimation process can be obtained by setting the infolevel of CodeTools or Usage.
|
•
|
The option quiet=truefalse can be given to suppress printing of the statistics (or to force printing when output=all).
|
•
|
CPUTime(expression) calls Usage(expression, output=[cputime,output], quiet). It can be passed an option of the form iterations = posint, which is also passed to Usage.
|
•
|
RealTime(expression) calls Usage(expression, output=[realtime,output], quiet). It can be passed an option of the form iterations = posint, which is also passed to Usage.
|
•
|
GCTime(expression,real=truefalse) calls Usage(expression, output=[gcrealtime,output], quiet) if the second argument is true or Usage(expression, output=[gctime,output], quiet) if the second argument is false (the default). It can be passed an option of the form iterations = posint, which is also passed to Usage.
|
|
|
Examples
|
|
memory used=10.07MiB, alloc change=35.01MiB, cpu time=89.00ms, real time=90.00ms, gc time=4.71ms
| |
memory used=15.60MiB, alloc change=38.00MiB, cpu time=216.00ms, real time=162.00ms, gc time=112.95ms
| |
memory used=40.25MiB, alloc change=-4.00MiB, cpu time=630.00ms, real time=598.00ms, gc time=77.65ms
| |
memory used=4.06MiB, alloc change=0 bytes, cpu time=62.00ms, real time=63.00ms, gc time=0ns
| |
The following takes too little resources to give useful information. Increasing the number of iterations improves this.
memory used=4.58KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns, gc time=0ns
| |
memory used=48 bytes, alloc change=0 bytes, cpu time=8.4e+02ns, real time=8.4e+02ns, gc time=0ns
| |
Usage: "trying out" 1 "iteration"
Usage: "trying out" 2 "iterations"
Usage: "trying out" 4 "iterations"
Usage: "trying out" 8 "iterations"
Usage: "trying out" 16 "iterations"
Usage: "trying out" 32 "iterations"
Usage: "trying out" 64 "iterations"
Usage: "trying out" 128 "iterations"
Usage: "trying out" 256 "iterations"
Usage: "trying out" 512 "iterations"
Usage: "trying out" 1024 "iterations"
Usage: "trying out" 2048 "iterations"
Usage: "trying out" 4096 "iterations"
Usage: "trying out" 8192 "iterations"
Usage: "trying out" 16384 "iterations"
Usage: "trying out" 32768 "iterations"
Usage: "trying out" 65536 "iterations"
Usage: "trying out" 131072 "iterations"
Usage: "setting iterations to" 1464491
memory used=48 bytes, alloc change=0 bytes, cpu time=8.5e+02ns, real time=8.5e+02ns, gc time=0ns
| |
memory used=8.46MiB, alloc change=0 bytes, cpu time=150.00ms, real time=112.00ms, gc time=82.44ms
| |
memory used=20.15MiB, alloc change=0 bytes, cpu time=96.00ms, real time=96.00ms, gc time=0ns
| |
|
|
Compatibility
|
|
•
|
The iterations option was introduced in Maple 15.
|
•
|
The iterations option was updated in Maple 16.
|
•
|
The output option was updated in Maple 18.
|
•
|
The CodeTools[Usage] command was updated in Maple 2017.
|
•
|
The GCTime option was updated in Maple 2017.
|
|
|
|
|