You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ephi Sachs <Ep...@DigitalFuel.com> on 2005/12/13 18:53:41 UTC

ant-contrib foreach performance

I have a <foreach> task which runs on a list of >1000 strings, and calls
an ant task which extracts 2 sub-strings, interprets them as numbers,
calculates their sum, and replaces the 2 sub-strings with their sum
(this is done by writing the sub-strings to a properties file, loading
it and using the <math> task).
The problem is that running the <foreach> task so many times, even on an
empty task which doesn't do anything, takes a long time (over a minute).
So:
1) Is there a more efficient way to accomplish iteration over a list?
2) Is there a way to perform such a math operation in a regular regex
replacement, without using a foreach iteration?
 
Thanks,
Ephi
 

Re: ant-contrib foreach performance

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 13 Dec 2005, Ninju Bohra <ni...@yahoo.com> wrote:
> Try using the <for> task.  The <foreach> task has the overhead of
> having to re-load the build file as it runs the target.  The <for>
> task uses macrodefs and should be much faster.
>  
> Also if you have such a well-defined complex usage it may make sense
> to create a custom task and drop into a compiled language (like
> JAVA) to accomplish what you need.

Yes, good advice, in particular writing a task to do it.

You can write a task using scripting languages as well, see Ant's
scriptdef task.

Stefan

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


Re: ant-contrib foreach performance

Posted by Ninju Bohra <ni...@yahoo.com>.
Try using the <for> task.  The <foreach> task has the overhead of having to re-load the build file as it runs the target.
The <for> task uses macrodefs and should be much faster.
 
Also if you have such a well-defined complex usage it may make sense to create a custom task and drop into a compiled language (like JAVA) to accomplish what you need.
 
Ninju
 


----- Original Message ----
From: Ephi Sachs <Ep...@DigitalFuel.com>
To: user@ant.apache.org
Sent: Tuesday, December 13, 2005 11:53:41 AM
Subject: ant-contrib foreach performance


I have a <foreach> task which runs on a list of >1000 strings, and calls
an ant task which extracts 2 sub-strings, interprets them as numbers,
calculates their sum, and replaces the 2 sub-strings with their sum
(this is done by writing the sub-strings to a properties file, loading
it and using the <math> task).
The problem is that running the <foreach> task so many times, even on an
empty task which doesn't do anything, takes a long time (over a minute).
So:
1) Is there a more efficient way to accomplish iteration over a list?
2) Is there a way to perform such a math operation in a regular regex
replacement, without using a foreach iteration?

Thanks,
Ephi

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