pymel.core.system.timer

timer(*args, **kwargs)

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 -ecall.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; I the -e flag or -lap flag return the time elapsed since the last ‘timer -s’ call.I the -s flag has no return value.

Flags:
Long name (short name) Argument Types Properties
endTimer (e) bool ../../../_images/create.gif
 

Stop the timer and return the time elapsed since the timer was started (in seconds). Once a timer is turned off it no longer exists, though it can be recreated with a new start

lapTime (lap) bool ../../../_images/create.gif
 
Get the lap time of the timer (time elapsed since start in seconds). Unlike the endflag this keeps the timer running.
name (n) unicode ../../../_images/create.gif
 

Use a named timer for the operation. If this is omitted then the default timer is assumed.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

startTimer (s) bool ../../../_images/create.gif
 
Start the timer.

Derived from mel command maya.cmds.timer

Example:

import pymel.core as pm

pm.timer( s=True )
# Result: u"Timer 'defaultTimer' started." #
# code being timed
print "START: time this"
for i in range (0, 50):
        print ("time this "+str(i))
print "END: time this"
pm.timer( e=True )
# Result: 0.084618 #
# Named timers can be used for nesting
pm.timer( s=True, name="outerLoop" )
# Result: u"Timer 'outerLoop' started." #
print "START: macro loop timing"
for i in range(0,50):
        pm.timer( s=True )
        for j in range(5,50):
                newObjs = pm.sphere( spans=j )
                pm.delete( newObjs )
        innerTime = pm.timer( e=True )
        lapTime = pm.timer( lap=True, name="outerLoop" )
        print "\tInner loop %d = %g" % (i, innerTime)
        print "\t       SUB = %g" % lapTime
fullTime = pm.timer( e=True, name="outerLoop" )
print "END: Full timing was %g" % fullTime

Previous topic

pymel.core.system.sysFile

Next topic

pymel.core.system.timerX

Core

Core Modules

Other Modules

This Page