Chapter 10. Stopwatch
Prev | Additional Ant Tasks | Next

## 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

Attribute | Description | Default | Required
--- | --- | --- | ---
name | The name for the stopwatch. The elapsed time or total time will be stored as an Ant property with this name. | None | Yes
action | Valid 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 -->

Prev | Up | Next
Chapter 9. Variable Task | Home | Chapter 11. Limit