Go to: Synopsis. Return value. Flags. MEL examples.
timerX [-startTime float]
timerX is undoable, NOT queryable, and NOT editable.
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.
float | This command returns a different value depending on the flag used. If no flag is used, then the start time is returned. If the "-st" flag is used, then it returns the elapsed time since the start time. |
Long name (short name) | Argument types | Properties | ||
---|---|---|---|---|
-startTime(-st)
|
float
|
![]() |
||
|
![]() |
![]() |
![]() |
![]() |
// Example 1: Simple timing // $startTime = `timerX`; // code that is being timed $totalTime = `timerX -startTime $startTime`; print ("Total Time: "+$totalTime+"\n"); // Example 2: Iterative timing // $startTime = `timerX`; for ($i = 0; $i < 5; $i++) { $elaspedTime = `timerX -startTime $startTime`; print ("Elapsed Time: "+$elaspedTime+"\n"); } // Example 3: Stacked timing calls // $startTime1 = `timerX`; $startTime2 = `timerX`; for ($i = 0; $i < 5; $i++) { $elapsedTime = `timerX -startTime $startTime2`; print ("Elapsed Time: "+$elapsedTime+"\n"); } $totalTime = `timerX -startTime $startTime1`; print ("Total Time: "+$totalTime+"\n");