pymel.core.system.timerX

static system.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 ../../../_images/create.gif
 

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

Previous topic

pymel.core.system.timer

Next topic

pymel.core.system.translator

Core

Core Modules

Other Modules

This Page