time - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Resource Management : time

time

total CPU time used for the session

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

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 floating-point 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:

st := time():

... statements to be timed ...:

time() - st;

  

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 thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

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.

time31000000

0.

(1)

The following is the same computation but it also records the time used to create the data structure.

sttime:31000000:timest

0.017

(2)

The following is the same computation as the one above, but records real time used instead of cpu time.

sttime[real]:31000000:time[real]st

0.018

(3)

See Also

kernelopts

showtime

timelimit

 


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