Purpose:TIMER is a system stopwatch

 

Format:TIMER [/1 /2 /3 /4 /5 /6 /7 /8 /9 /10 /Q /S] [ON | OFF] [command]

 

ONForce the stopwatch to reset and start
OFFForce the stopwatch to stop
commandTime the specified command

 

/1

stopwatch #1 (default)

/Q

quiet

/2

stopwatch #2

/S

split

/3

stopwatch #3



/4

stopwatch #4



/5

stopwatch #5



/6

stopwatch #6



/7

stopwatch #7



/8

stopwatch #8



/9

stopwatch #9



/10

stopwatch #10



 

Usage:

 

The TIMER command accepts its parameters in any order, and acts on the specified one of ten 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.

 

The switch arguments (/1 - /10, /Q, and /S) must appear before any other arguments on the TIMER command line.

 

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 ten stopwatches available (1 - 10) 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

 

You can optionally specify a command for TIMER to run. This is the equivalent of "timer on & command & timer off". For example:

 

timer dir c:\ /s

 

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.

 

/4Use timer #4.

 

/5Use timer #5.

 

/6Use timer #6.

 

/7Use timer #7.

 

/8Use timer #8.

 

/9Use timer #9.

 

/10Use timer #10.

 

/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.