CodeTools - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : CodeTools : CodeTools/Usage

CodeTools

  

Usage

  

measure time and memory usage information for executing an expression

  

CPUTime

  

measure CPU time used to execute an expression

  

RealTime

  

measure real time used to execute an expression

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

CodeTools[Usage](expression, options)

CodeTools[CPUTime](expression, options)

CodeTools[RealTime](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.

Examples

withCodeTools:

Usageifactor32!+1

memory used=7.11MiB, alloc change=32.00MiB, cpu time=87.00ms, real time=88.00ms, gc time=6.00ms

6114608365293128894190494740737772281

(1)

Usageifactor33!+1,output='bytesused'

memory used=7.11MiB, alloc change=4.00MiB, cpu time=64.00ms, real time=63.00ms, gc time=0ns

7451344

(2)

Usageifactor36!+1,output='all'

Recordrealtime=0.054,cputime=0.054,gctime=0.,gcrealtime=0.,bytesused=6241808,bytesalloc=0,output=37837391483165202043669043459524628666916941

(3)

dataUsageifactor39!+1,output='all',quiet=false

memory used=41.30MiB, alloc change=8.04MiB, cpu time=528.00ms, real time=528.00ms, gc time=18.00ms

data:=Recordrealtime=0.528,cputime=0.528,gctime=0.01800000000,gcrealtime=0.01748895645,bytesused=43306816,bytesalloc=8425472,output=795755448536314610264891493930705821478100704367

(4)

databytesused

43306816

(5)

Usageifactor40!+1,output='cputime','bytesused'

memory used=4.36MiB, alloc change=0 bytes, cpu time=43.00ms, real time=43.00ms, gc time=0ns

0.043,4576576

(6)

Usageifactor42!+1,output='cputime','bytesused',quiet

0.966,81092744

(7)

The following takes too little resources to give useful information. Increasing the number of iterations improves this.

Usageifactor15!+1

memory used=6.91KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns, gc time=0ns

5947946271341

(8)

Usageifactor15!+1,iterations=106

memory used=48 bytes, alloc change=0 bytes, cpu time=1.01us, real time=1.02us, gc time=0ns

5947946271341

(9)

infolevelUsage5:

Usageifactor15!+1,iterations=2s

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"   1608245
memory used=48 bytes, alloc change=0 bytes, cpu time=1.06us, real time=1.05us, gc time=17ns

5947946271341

(10)

unassign'infolevelUsage'

withLinearAlgebra:

UsageLUDecompositionRandomMatrix25,output='all'

Recordrealtime=0.016,cputime=0.015,gctime=0.,gcrealtime=0.,bytesused=2937880,bytesalloc=0,output= 25 x 25 MatrixData Type: integer1Storage: sparseOrder: Fortran_order, 25 x 25 MatrixData Type: anythingStorage: triangularlowerOrder: Fortran_order, 25 x 25 MatrixData Type: anythingStorage: rectangularOrder: Fortran_order

(11)

UsageLUDecompositionRandomMatrix35,output='cputime','output'

memory used=8.46MiB, alloc change=0 bytes, cpu time=45.00ms, real time=45.00ms, gc time=0ns

0.045, 35 x 35 MatrixData Type: integer1Storage: sparseOrder: Fortran_order, 35 x 35 MatrixData Type: anythingStorage: triangularlowerOrder: Fortran_order, 35 x 35 MatrixData Type: anythingStorage: rectangularOrder: Fortran_order

(12)

UsageLUDecompositionRandomMatrix45,output='cputime','output','bytesused'

memory used=20.15MiB, alloc change=0 bytes, cpu time=112.00ms, real time=111.00ms, gc time=0ns

0.112, 45 x 45 MatrixData Type: integer1Storage: sparseOrder: Fortran_order, 45 x 45 MatrixData Type: anythingStorage: triangularlowerOrder: Fortran_order, 45 x 45 MatrixData Type: anythingStorage: rectangularOrder: Fortran_order,21129480

(13)

CPUTimeifactor45!+1

1.863,2931978954403404920630438210640397406279590400959696408493

(14)

RealTimeifactor46!+1

3.487,47268662306503771535067435777793891607546778854755077304349

(15)

Compatibility

• 

The iterations option was introduced in Maple 15.

• 

For more information on Maple 15 changes, see Updates in Maple 15.

• 

The iterations option was updated in Maple 16.

• 

The CodeTools[Usage] command was updated in Maple 18.

• 

The output option was updated in Maple 18.

See Also

kernelopts

time

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam