ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Mailhot <Nicolas.Mail...@laPoste.net>
Subject RE: measuring performance of a task
Date Mon, 27 Sep 2004 14:01:02 GMT
Le lundi 27 septembre 2004 à 15:49 +0200, Stephen McConnell a écrit :
> 
> > -----Original Message-----
> > From: lists@bitfaeule.net [mailto:lists@bitfaeule.net]
> > Sent: 27 September 2004 15:28
> > To: user@ant.apache.org
> > Subject: measuring performance of a task
> > 
> > 
> > Hello,
> > 
> > I would like to automatically measure the time ant spends executing a
> > task and write it to my logfile.
> > 
> > What's the best way to do that? I would like to avoid writing a custom
> > task in Java.
> 
> I guess you could create a build listener.  Using the events posted to
> the listener I think you can capture the start and end of task execution
> based on task name or target name.  The interface to look at is
> BuildListener which is the org.apache.tools.ant package.  Once you have
> created an implementation of this interface you can register it with
> your project using something like:
> 
>    BuildListener listener = new MyBuildListener();
>    getProject().addBuildListener( listener );

Another (very crude) way :

    <tstamp>
      <format pattern="HH:mm.ss" property="foo.start"/>
    </tstamp>

do something ...

    <tstamp>
      <format pattern="HH:mm.ss" property="foo.stop"/>
    </tstamp>

    <echo level="info" message="Run time (foo): ${foo.start} to
${foo.stop}"/>

This depends of course of what you need to achieve exactly

Regards,

-- 
Nicolas Mailhot

Mime
View raw message