Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing Ant target execution time

Tags:

I want to print the execution time taken for each individual Ant target and its dependent targets.

<target name="target1" depends="target2, target3">  .... </target> 

When run should show following output

Target 2 - x seconds Target 3 - y seconds Target 1 - z seconds 

Any suggestions on how to achieve this?

like image 298
Nirmal Patel Avatar asked Feb 12 '10 07:02

Nirmal Patel


2 Answers

Since Ant 1.8.0 you can use a profilelogger to do this.

ant -logger org.apache.tools.ant.listener.ProfileLogger target 

Produces output like

Target aTarget: started Thu Jan 22 09:01:00 CET 2009

echo: started Thu Jan 22 09:01:00 CET 2009 [echo] echo-task

echo: finishedThu Jan 22 09:01:00 CET 2009 (250ms)

zip: started Thu Jan 22 09:01:00 CET 2009 [zip] Building zip: ...\my.zip

zip: finishedThu Jan 22 09:01:01 CET 2009 (1313ms)

Target aTarget: finishedThu Jan 22 09:01:01 CET 2009 (1719ms)

like image 125
martin clayton Avatar answered Sep 20 '22 17:09

martin clayton


Use one of the listeners from Ant add-on task collections:

  • antutility
  • antelope
  • antcontrib With -listener net.sf.antcontrib.perf.AntPerformanceListener

Or check their sources, and roll your own listener.

like image 22
Rebse Avatar answered Sep 19 '22 17:09

Rebse