ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wascally Wabbit <>
Subject Re: TImestamping in ANT
Date Thu, 19 Jul 2007 13:02:27 GMT
dkhanna01 wrote:
> I need to find out the time taken by each of the process/target in our
> build.xml file. Now for doing this I have use ANT tstamp task to calculate
> the start time and end time of the process. Now my question is how do I find
> out the total time taken by the process, I mean is there any way to
> calculate difference between "End time" and "Start time" 
> Thanks

If you can use thirdparty libraries you can use the AntXtra's
<assign> task like so:

<target name="compile" depends="-init" description="Compile stuff">
   <assign var="time" value="now"/>
   ...[all your compiling tasks here]
   <assign var="time" value="-now" transform="duration"
   <echo level="info" message="compile took ${compile.duration}"/>

If you want to do this for lots of your targets you can leverage
macrodefs to do this for every target using something like:

<macrodef name="timedtarget">
   <attribute name="name">
   <attribute name="functions"/>
     <assign var="time_" value="now"/>
     <callinline targets="@{functions}"/> <!--do NOT switch projects-->
     <assign var="time_" value="-now" transform="duration"
     <echo level="info" message="@{name} took ${@{name}.duration}"/>

Then use it like so:

<target name="-compile">
    ...[all your compiling work here in private target]

<target name="compile" depends="-init" description="Compile stuff">
   <timetarget name="compile" functions="-compile"/>

AntXtras is at:

Hope that helps.

-The Wabbit

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message