back to top   Latest News


There seems to be a problem using the timer task inside ANT v1.6 compliant targets. Watch out for an updated version of the timer task which will be issued soon.

back to top   Purpose


Extend Ant to measure amount of time elapsed to complete a build task.


The task now supports the high resolution timer (accessed by nanoTime) introduced by Java 1.5.
If present it will be used automatically otherwise the classical currentTimeMillis will be used.
Note: The task will no longer compile using a JDK prior to version 1.5.
If you intend to run it under JRE 1.4 or earlier download the JAR archive.

back to top   Installation


  1. Download the JAR archive
  2. Add the JAR archive to Ant's classpath
  3. Add to following line to your Ant buildfile to create the include task
    <taskdef name="timer" classname="de.jeckle.AntExtension.Timer"/>
  4. Installation finished!
    Now you can define your own timer tasks.

back to top   Usage


  1. Define a new Ant task (e.g. named timer).
  2. Use the new task whereas the verbose attribute switches the verbose mode on if it contains the value true. Additionally, the timer task can be named by the name attribute.
  3. Embrace all tasks or sequences of tasks whose execution time should be measured by timer tasks.
Turns verbose mode on if it contains the value true
Names the timer task

back to top   Example


<target name="test">
	<timer verbose="true">
	<timer name="timer2">
		<timer name="timer3" verbose="true">


Buildfile: build.xml

    [timer] System reports java version 1.5.0-beta
    [timer] Using high resolution timer
    [timer] started     [echo] test1
    [timer] elapsed time: 0 ms
     [echo] test2
    [timer] named timer3 started
     [echo] test3
    [timer] elapsed time for executing task named timer3: 2 minute(s) 7 second(s) 762 millisecond(s) 818327 nannosecond(s)
     [echo] test4
    [timer] elapsed time for executing task named timer2: 1 minute(s) 9 second(s) 235 millisecond(s) 593192 nannosecond(s)

Total time: 1 second

Download this example code

back to top   License


The implementation is released unter the Lesser GNU Public License.

back to top   Tested Versions


back to top   Download


separator line
Service provided by Mario Jeckle
Generated: 2004-06-11T07:11:41+01:00
Feedback Feedback       SiteMap SiteMap
This page's original location This page's original location:
RDF metadata describing this page RDF description for this page