time  total CPU time used for the session

Calling Sequence


time(x)
time[real](x)


Parameters


x



(optional) expression

real



(optional) : use real to specify real time instead of cpu time





Description


•

The time command returns the total CPU time used since the start of the Maple session. The units are in seconds and the value returned is a floatingpoint number.

•

The time(x) calling sequence returns the time taken to evaluate the expression x.

•

The time[real] command returns the real time elapsed since kernel startup, in seconds.

•

The time[real](x) calling sequence returns the real time used to evaluate expression x.


Note that when constructing certain data structures, Maple does some automatic simplifications. For example, Maple recognizes that the expression 3^2 can be exactly represented in its expanded form (9), and so automatically and immediately does the expansion. Since this computation is done at simplification time, and because the time() command only records CPU time elapsed during evaluation (not simplification), the expansion does not register as having taken any time.

•

To time particular statements or groups of statements, one method would be the following:

>

... statements to be timed ...:


Note the use of a colon to prevent the display of an uninteresting value; it is the value time()  st which gives the desired information.



Thread Safety


•

The time command is threadsafe as of Maple 15.



Examples


To illustrate the difference between time elapsed including simplification of data structures, consider the following example.
The following records only the time to evaluate the expression after the data structure is already created.
>


 (1) 
The following is the same computation but it also records the time used to create the data structure.
 (2) 
The following is the same computation as the one above, but records real time used instead of cpu time.
 (3) 


Download Help Document
Was this information helpful?