pymel.core.system.timerX¶
- timerX(*args, **kwargs)¶
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.
Flags:
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 have multiple arguments, passed either as a tuple or a list. Derived from mel command maya.cmds.timerX
Example:
import pymel.core as pm # Example 1: Simple timing # start = pm.timerX() # code that is being timed totalTime = pm.timerX(startTime=start) print "Total time: ", totalTime # Example 2: Iterative timing # startTime = pm.timerX() for i in range(0,5): elapsedTime = pm.timerX() print "Elapsed Time: ", elapsedTime # Example 3: Stacked timing calls # startTime1 = pm.timerX() startTime2 = pm.timerX() for i in range(0,5): elapsedTime = pm.timerX() print "Elapsed Time: ", elapsedTime totalTime = pm.timerX(startTime=startTime1) print "Total Time: ", totalTime