Go to: Synopsis. Return value. Flags. Python examples.
timerX([startTime=float])
Note: Strings representing object names and
arguments must be separated by commas. This is not depicted in the
synopsis.
timerX is undoable, NOT queryable, and NOT
editable.
Used to calculate elapsed time. This command returns sub-second
accurate time values. It is useful from scripts for timing the
length of operations. Call this command before and after the
operation you wish to time. On the first call, do not use any
flags. It will return the start time. Save this value. After the
operation, call this command a second time, and pass the saved
start time using the -st flag. The elapsed time will be returned.
float |
This command returns a different value depending on the flag
used. If no flag is used, then the start time is returned. If the
"-st" flag is used, then it returns the elapsed time since the
start time. |
startTime
Long name (short name) |
Argument types |
Properties |
startTime(st) |
float |
|
|
When this flag is used, the command returns the elapsed time
since the specified start time. |
|
Flag can appear in Create mode of
command |
Flag can appear in Edit mode of command |
Flag can appear in Query mode of command |
Flag can have multiple arguments, passed
either as a tuple or a list. |
import maya.cmds as cmds
# Example 1: Simple timing
#
start = cmds.timerX()
# code that is being timed
totalTime = cmds.timerX(startTime=start)
print "Total time: ", totalTime
# Example 2: Iterative timing
#
startTime = cmds.timerX()
for i in range(0,5):
elapsedTime = cmds.timerX()
print "Elapsed Time: ", elapsedTime
# Example 3: Stacked timing calls
#
startTime1 = cmds.timerX()
startTime2 = cmds.timerX()
for i in range(0,5):
elapsedTime = cmds.timerX()
print "Elapsed Time: ", elapsedTime
totalTime = cmds.timerX(startTime=startTime1)
print "Total Time: ", totalTime