Go to: Synopsis. Return value. Keywords. Related. Flags. Python examples.
timer([endTimer=boolean], [lapTime=boolean], [name=string], [startTimer=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
timer is NOT undoable, NOT queryable, and NOT editable.
Allow simple timing of scripts and commands. The resolution of this timer is at the level of your OS's gettimeofday() function.
Note:This command does not handle stacked calls. For
example, this code below will give an incorrect answer on the
second timer -e call.
timer -s; timer -s; timer -e; timer -e;To do this use named timers:
timer -s; timer -s -name "innerTimer"; timer -e -name "innerTimer"; timer -e;
None
| Long name (short name) | Argument types | Properties | ||
|---|---|---|---|---|
endTimer(e)
|
boolean
|
|
||
|
||||
lapTime(lap)
|
boolean
|
|
||
|
||||
name(n)
|
string
|
|
||
|
||||
startTimer(s)
|
boolean
|
|
||
|
||||
import maya.cmds as cmds
cmds.timer( s=True )
# code being timed
print "START: time this"
for i in range (0, 50):
print ("time this "+str(i))
print "END: time this"
cmds.timer( e=True )
# Named timers can be used for nesting
cmds.timer( s=True, name="outerLoop" )
print "START: macro loop timing"
for i in range(0,50):
cmds.timer( s=True )
for j in range(5,50):
newObjs = cmds.sphere( spans=j )
cmds.delete( newObjs )
innerTime = cmds.timer( e=True )
lapTime = cmds.timer( lap=True, name="outerLoop" )
print "\tInner loop %d = %g" % (i, innerTime)
print "\t SUB = %g" % lapTime
fullTime = cmds.timer( e=True, name="outerLoop" )
print "END: Full timing was %g" % fullTime