Clock - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Clock

 

Calling Sequence

Description

Methods

The System UTC Clock

The Process Clock

Thread Clocks

Examples

Compatibility

Calling Sequence

SystemUTCClock

ProcessClock

ThreadClock()

Description

• 

A clock object provides access to the current time, returning a Time object that represents the moment at which the clock is queried by invoking its Now method.

• 

Each clock is associated with a so-called "epoch", which represents the origin of the time system that the clock implements.  The epoch of a clock is accessed via its Epoch method.

• 

The epoch of a clock may be defined or undefined.  A clock with an undefined epoch has a definite, but unknown, origin.

• 

Also associated with any clock object is a "precision" that can be queried by using the Precision method of the clock.  The precision of a clock represents the fineness with which the clock measures time.  It is designated by a unit name denoting the smallest interval of time that may be resolved by the clock.  A clock with a smaller unit of precision measures time more precisely than one with a larger unit of precision.  For example, a clock with micro-second precision is able to distinguish points in time that differ by one micro-second, and is more precise than a clock with second precision, which can only distinguish points of time that differ by one or more seconds.

• 

The precision of a clock should not be confused with its accuracy.  The latter is a measure of how close a measurement is to its true value.  The accuracy of a clock cannot be known, in general, as it depends upon the configuration of the underlying operating system and, perhaps, hardware.

• 

Each clock is of type Clock.  Use the type command to check whether a Maple expression is of type Clock.

Methods

• 

All clocks implement the following methods.

Now  returns a Time object representing the current time

Precision  returns the name of a unit designating a clock's precision

Epoch  returns the epoch of a clock

• 

The most important method of a clock object is the Now method. It returns a Time object representing the moment of time it was invoked, on the time system the clock represents. Numerically, this is a positive or negative count of the number of units of the clock's precision from the epoch of the clock, which may or may not be defined. For a clock with an undefined epoch, it is only meaningful to compare Time values produced by the same clock.

• 

The Precision method of a clock object returns a unit name designating the precision of the clock; that is, the fineness with which the clock measures time.

• 

The Epoch method of a clock returns a value representing the "origin", or zero-point of the time scale measured by that clock. Time values produced by clocks with a defined epoch are comparable and can be combined arithmetically. Time values produced by clocks with an undefined epoch can only be meaningfully compared if they are produced by the same (identical) clock object.

The System UTC Clock

• 

A single object, SystemUTCClock, provides access to the UTC time provided by the underlying operating system.

• 

Because the SystemUTCClock is determined uniquely by the operating system, values produced by it in different Maple processes are expected to agree and can be meaningfully compared and combined.

The Process Clock

• 

The ProcessClock object allows you to query the CPU time of the current Maple process.  It has an undefined epoch, and a precision (typically nanosecond) determined by the underlying operating system.

• 

The process clock is unique to the Maple process in which it exists.  Time values produced by its Now method are meaningful only within a single Maple process. They represent the amount of CPU time elapsed since their epoch, which is a definite, but undefined point in time.

Thread Clocks

• 

A ThreadClock object allows you to query the CPU time of the current thread in a Maple process.  Each ThreadClock has an undefined epoch, and a precision (typically nanosecond) determined by the underlying operating system.

• 

Since thread clocks are unique to the thread in which they are invoked, a different thread clock must be created via a constructor call of the form ThreadClock() in the current thread.

Examples

typeSystemUTCClock,Clock

true

(1)

typeProcessClock,Clock

true

(2)

NowSystemUTCClock

<Time: 1970-01-01T00:00:00 + 1709271620996 ms>

(3)

EpochSystemUTCClock

<Date: 1970-01-01 GMT>

(4)

PrecisionSystemUTCClock

millisecond

(5)

NowProcessClock

<Time: 318480999 nanosecond>

(6)

EpochProcessClock

undefined

(7)

EpochThreadClock

undefined

(8)

Compatibility

• 

The Clock command was introduced in Maple 2018.

• 

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

See Also

Calendar

Date

Time