TIMER

Print Topic  Return to Overview  Previous Topic  Next Topic 
Purpose:TIMER is a system stopwatch.

 

Format:TIMER [ ON | OFF | /Q /S /1 /2 /3 ]

 

ONForce the stopwatch to reset and start
OFFForce the stopwatch to stop

 

/1

stopwatch #1 (default)

/Q

quiet

/2

stopwatch #2

/S

split

/3

stopwatch #3

 

 

 

Usage:

 

The TIMER command accepts its parameters in any order, and acts on the specified one of three possible timers (system stopwatches) by turning it on or off, or by displaying its current elapsed time. The TIMER command with neither of the keywords ON and OFF nor the /S option toggles the state of the timer.

 

If you execute TIMER or TIMER /S when the timer is off, or execute TIMER ON at any time, the current time of day is displayed, and the stopwatch starts from :

 

[c:\] timer

Timer 1 on:  12:21:46

 

If you execute TIMER /S when the timer is on, the elapsed time is displayed:

 

[c:\] timer /s

Timer 1  Elapsed time: 0:00:12.06

 

If you execute TIMER when it is on, or execute TIMER OFF, the stopwatch stops, the current time and the elapsed time are displayed, and the elapsed time is reset:

 

[c:\] timer

Timer 1 off:  12:21:58

Elapsed time: 0:00:12.06

 

There are three stopwatches available (1, 2, and 3) so you can time multiple overlapping events. By default, TIMER uses stopwatch #1.

 

TIMER is particularly useful for timing events in batch files. For example, to time both an entire batch file, and an intermediate section of the same file, you could use commands like this:

 

rem Turn on timer 1

timer

rem Do some work here

rem Turn timer 2 on to time the next section

timer /2

rem Do some more work

echo Intermediate section completed

rem Display time taken in intermediate section

timer /2

rem Do some more work

rem Now display the total time

timer

 

The smallest interval TIMER can measure depends on the operating system you are using, your hardware, and the interaction between the two. However, it should never be more than 60 ms.

 

You can also retrieve the elapsed time of a timer using the @TIMER[] function.

 

Options:

 

/1Use timer #1 (the default).

 

/2Use timer #2.

 

/3Use timer #3.

 

/Q Don't display any messages.

       

/SDisplay a split time without stopping the timer. To display the current elapsed time but leave the timer running:

 

[c:\] timer /s

Timer 1 elapsed: 0:06:40.63

 

ONStart the timer regardless of its previous state (on or off). Otherwise the TIMER command toggles the timer state (unless /S is used).

 

OFFStops the timer.

 

Topic "timer.htm" last edited 2008-04-21. ©2009  JP Software, Inc.
Keywords: TIMER,@TIMER