You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Raja Nagendra Kumar <Na...@tejasoft.com> on 2009/09/02 18:24:15 UTC

Peformance Task usage from custom task

Hi,

Is it possible to set the performance monitoring as described in 
http://antelope.tigris.org/nonav/docs/manual/bk03ch27.html (i.e enable and
disable such data collection) from a custom ant tasks java code.

My need to enable monitoring only during the execution of the custom task
and remove it once that is executed.

Also, I am not interested to change the ant launch time parameters as this
would impact entire build completion and not ideal for our needs.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com

-- 
View this message in context: http://www.nabble.com/Peformance-Task-usage-from-custom-task-tp25260860p25260860.html
Sent from the Ant - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: AW: Peformance Task usage from custom task

Posted by Gilles Scokart <gs...@gmail.com>.
Note that if your intention is to profile your own task, you can also use
any profiler you want.  An ant build is a java application like an other.


Gilles Scokart


2009/9/3 <Ja...@rzf.fin-nrw.de>

> You could also subclass that listener and overwrite the
> [task|target][Starts|Finished] by calling the build[Starts|Finished] method.
> Would that help?
>
> Or use the StopWatchTask?
>
> http://ant-contrib.svn.sourceforge.net/viewvc/ant-contrib/ant-contrib/trunk/src/main/java/net/sf/antcontrib/perf/StopWatchTask.java?revision=130&view=markup
>
>
> Jan
>
>
> >-----Ursprüngliche Nachricht-----
> >Von: Raja Nagendra Kumar [mailto:Nagendra.Raja@tejasoft.com]
> >Gesendet: Donnerstag, 3. September 2009 10:30
> >An: dev@ant.apache.org
> >Betreff: Re: AW: Peformance Task usage from custom task
> >
> >
> >Nope Jan..
> >
> >On making such correction it giving error in  line  188
> >
> >i.e the line
> >        StopWatch sw = ( StopWatch ) targetStats.get( be.getTarget() );
> >
> >of targetFinished()..
> >
> >It appears to me that AntPerformanceListener or the interface
> >BuildListener
> >is not custom tag friendly..
> >
> >Some of the things I see from the interface are.. they are meant for
> >printing the report of entire build and not between when it is
> >added and
> >when it is removed..
> >
> >I saw some where SubAntListener etc.. which means not sure
> >impact of calls
> >antcall and ant and subant tags usage..
> >
> >May be it would be nice to put  AntPerformanceListener  or
> >BuildListener
> >towards TaskPerfListener level rather than entire build level..
> >
> >
> >Regards,
> >Raja Nagendra Kumar,
> >C.T.O
> >www.tejasoft.com
> >
> >
> >
> >--
> >View this message in context:
> >http://www.nabble.com/Peformance-Task-usage-from-custom-task-tp
> >25260860p25271781.html
> >Sent from the Ant - Dev mailing list archive at Nabble.com.
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> >For additional commands, e-mail: dev-help@ant.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

AW: AW: Peformance Task usage from custom task

Posted by Ja...@rzf.fin-nrw.de.
You could also subclass that listener and overwrite the [task|target][Starts|Finished] by calling the build[Starts|Finished] method. 
Would that help?

Or use the StopWatchTask?
http://ant-contrib.svn.sourceforge.net/viewvc/ant-contrib/ant-contrib/trunk/src/main/java/net/sf/antcontrib/perf/StopWatchTask.java?revision=130&view=markup


Jan


>-----Ursprüngliche Nachricht-----
>Von: Raja Nagendra Kumar [mailto:Nagendra.Raja@tejasoft.com] 
>Gesendet: Donnerstag, 3. September 2009 10:30
>An: dev@ant.apache.org
>Betreff: Re: AW: Peformance Task usage from custom task
>
>
>Nope Jan..
>
>On making such correction it giving error in  line  188
>
>i.e the line 
>        StopWatch sw = ( StopWatch ) targetStats.get( be.getTarget() );
>
>of targetFinished()..
>
>It appears to me that AntPerformanceListener or the interface 
>BuildListener
>is not custom tag friendly.. 
>
>Some of the things I see from the interface are.. they are meant for
>printing the report of entire build and not between when it is 
>added and
>when it is removed..
>
>I saw some where SubAntListener etc.. which means not sure 
>impact of calls
>antcall and ant and subant tags usage..
>
>May be it would be nice to put  AntPerformanceListener  or 
>BuildListener 
>towards TaskPerfListener level rather than entire build level..
>
>
>Regards,
>Raja Nagendra Kumar,
>C.T.O
>www.tejasoft.com
>
>
>
>-- 
>View this message in context: 
>http://www.nabble.com/Peformance-Task-usage-from-custom-task-tp
>25260860p25271781.html
>Sent from the Ant - Dev mailing list archive at Nabble.com.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: AW: Peformance Task usage from custom task

Posted by Raja Nagendra Kumar <Na...@tejasoft.com>.
Nope Jan..

On making such correction it giving error in  line  188

i.e the line 
        StopWatch sw = ( StopWatch ) targetStats.get( be.getTarget() );

of targetFinished()..

It appears to me that AntPerformanceListener or the interface BuildListener
is not custom tag friendly.. 

Some of the things I see from the interface are.. they are meant for
printing the report of entire build and not between when it is added and
when it is removed..

I saw some where SubAntListener etc.. which means not sure impact of calls
antcall and ant and subant tags usage..

May be it would be nice to put  AntPerformanceListener  or BuildListener 
towards TaskPerfListener level rather than entire build level..


Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com



-- 
View this message in context: http://www.nabble.com/Peformance-Task-usage-from-custom-task-tp25260860p25271781.html
Sent from the Ant - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


AW: Peformance Task usage from custom task

Posted by Ja...@rzf.fin-nrw.de.
According to your stacktrace the NPE occurs in line 62 of the listener
Its source is available here:
http://ant-contrib.svn.sourceforge.net/viewvc/ant-contrib/ant-contrib/trunk/src/main/java/net/sf/antcontrib/perf/AntPerformanceListener.java?revision=130&view=markup

	long stop_time = master.stop();

So 'master' is null.
This field is initialized in the buildStarted() method, which is invoked before your task started.

So try instead your add

AntPerformanceListener perf = new net.sf.antcontrib.perf.AntPerformanceListener();
perf.buildStarted(null); // the BuildEvent is not evaluated in that method
getProject().addBuildListener(perf);


Jan


>-----Ursprüngliche Nachricht-----
>Von: Raja Nagendra Kumar [mailto:Nagendra.Raja@tejasoft.com] 
>Gesendet: Mittwoch, 2. September 2009 20:37
>An: dev@ant.apache.org
>Betreff: Re: Peformance Task usage from custom task
>
>
>Hi Dale,
>
>Thank you for the pointer.
>
>Tried this in custom ant ask	    getProject().addBuildListener(new
>net.sf.antcontrib.perf.AntPerformanceListener());
>
>this at the end of the build give the below exception..
>
>java.lang.NullPointerException
>        at
>net.sf.antcontrib.perf.AntPerformanceListener.buildFinished(AntPerfor
>manceListener.java:62)
>        at 
>org.apache.tools.ant.Project.fireBuildFinished(Project.java:2037)
>        at org.apache.tools.ant.Main.runBuild(Main.java:778)
>        at org.apache.tools.ant.Main.startAnt(Main.java:217)
>        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>
>Not sure what else needs to be added..
>
>
>Dale Anson wrote:
>> 
>> From a custom task, you have access to a Project object, which has
>> both add and remove build listener methods, which means you should be
>> able to add and remove listeners on the fly.   I haven't tried this,
>> but I don't see why it wouldn't work.
>> 
>> Dale
>> 
>
>-- 
>View this message in context: 
>http://www.nabble.com/Peformance-Task-usage-from-custom-task-tp
25260860p25263224.html
>Sent from the Ant - Dev mailing list archive at Nabble.com.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Peformance Task usage from custom task

Posted by Raja Nagendra Kumar <Na...@tejasoft.com>.
Hi Dale,

Thank you for the pointer.

Tried this in custom ant ask	    getProject().addBuildListener(new
net.sf.antcontrib.perf.AntPerformanceListener());

this at the end of the build give the below exception..

java.lang.NullPointerException
        at
net.sf.antcontrib.perf.AntPerformanceListener.buildFinished(AntPerfor
manceListener.java:62)
        at org.apache.tools.ant.Project.fireBuildFinished(Project.java:2037)
        at org.apache.tools.ant.Main.runBuild(Main.java:778)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Not sure what else needs to be added..


Dale Anson wrote:
> 
> From a custom task, you have access to a Project object, which has
> both add and remove build listener methods, which means you should be
> able to add and remove listeners on the fly.   I haven't tried this,
> but I don't see why it wouldn't work.
> 
> Dale
> 

-- 
View this message in context: http://www.nabble.com/Peformance-Task-usage-from-custom-task-tp25260860p25263224.html
Sent from the Ant - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Peformance Task usage from custom task

Posted by Dale Anson <da...@grafidog.com>.
>From a custom task, you have access to a Project object, which has
both add and remove build listener methods, which means you should be
able to add and remove listeners on the fly.   I haven't tried this,
but I don't see why it wouldn't work.

Dale


On Wed, Sep 2, 2009 at 10:24 AM, Raja Nagendra
Kumar<Na...@tejasoft.com> wrote:
>
> Hi,
>
> Is it possible to set the performance monitoring as described in
> http://antelope.tigris.org/nonav/docs/manual/bk03ch27.html (i.e enable and
> disable such data collection) from a custom ant tasks java code.
>
> My need to enable monitoring only during the execution of the custom task
> and remove it once that is executed.
>
> Also, I am not interested to change the ant launch time parameters as this
> would impact entire build completion and not ideal for our needs.
>
> Regards,
> Raja Nagendra Kumar,
> C.T.O
> www.tejasoft.com
>
> --
> View this message in context: http://www.nabble.com/Peformance-Task-usage-from-custom-task-tp25260860p25260860.html
> Sent from the Ant - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org