Chapter 10. Stopwatch

The Stopwatch task makes it easy to add performance timing to Ant targets. Stopwatches are named so that multiple watches can run simultaneously.

To use this task in your build files, include a task definition like this:


    <taskdef name="stopwatch" classname="ise.antelope.tasks.StopWatchTask"/>
   

Table 10.1. Stopwatch Task Attributes

AttributeDescriptionDefaultRequired
nameThe name for the stopwatch. The elapsed time or total time will be stored as an Ant property with this name.NoneYes
actionValid values are "start", "stop", "elapsed", and "total"."start"No

The stopwatch is started with the "start" action. When the action is "elapsed" or "total", the running time of the stopwatch is printed out. Both "stop" and "total" stop the stopwatch and reset it to zero. "elapsed" prints out the current running time of the stopwatch without stopping it.

Example:


<stopwatch name="timer1"/>
<!-- do some tasks here... -->
<stopwatch name="timer1" action="elapsed"/> <!-- print the elapsed time -->
<!-- do some more tasks here... -->
<stopwatch name="timer1" action="total"/> <!-- print out the total time -->