Go to: Synopsis. Return value. Keywords. Related. Flags. MEL examples.

Synopsis

timer [-endTimer] [-lapTime] [-name string] [-startTimer]

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;

Return value

None

Keywords

debug, timer

Related

dgtimer, timerX

Flags

endTimer, lapTime, name, startTimer
Long name (short name) Argument types Properties
-endTimer(-e) create
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) create
Get the lap time of the timer (time elapsed since start in seconds). Unlike the end flag this keeps the timer running.
-name(-n) string create
Use a named timer for the operation. If this is omitted then the default timer is assumed.
-startTimer(-s) create
Start the timer.

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 be used more than once in a command.

MEL examples

timer -s;
// code being timed
print( "START: time this\n" );
for ($i = 0 ; $i<50 ; $i++)
	print( "time this "+$i+"\n" );
print( "END: time this\n" );
timer -e;
// Named timers can be used for nesting
timer -s -tn "outerLoop";
print( "START: macro loop timing\n" );
for ($i=0; $i<50; $i++ )
{
	timer -s;
	for ($j=5; $j<50; $j++ )
	{
		delete `sphere -spans $j`;
	}
	$innerTime = `timer -e`;
	print( "\tInner loop " + $i + " = " + $innerTime + "\n" );
	$lapTime = `timer -lap -tn "outerLoop"`;
	print( "\t       SUB = " + $lapTime + "\n" );
}
$lapTime = `timer -e -tn "outerLoop"`;
print( "END: Full timing was " + $lapTime + "\n" );