Kev Jackson wrote:
[EMAIL PROTECTED] wrote:

As I've been hacking away today, I've been swapping a load of "" + "" + "" style code over to use StringBuffers. I thought that perhaps there's a potential use of a static method in StringUtils to construct these strings from an array


For a significant performance boost we had to refactor the whole (or a
major part) of the codebase in this manner. So I think a performance
test would be good. How much is the improvement on <delete>?


It's less to do with speed performance and more to do with memory performance. "a" + "b" + "c" creates "a" + "bc" <- intermediate String, and then "abc"

I'd love to do a performance/memory test of some kind, perhaps I'll use the new NetBeans (it's supposed to have a good view of the heap being used). Any suggestions on tools to help evaluate changes would be helpful.

We also have a problem with logging in general where the Strings are concatenated :
log("a" + toFile + " b " + dir + etc, verbosity);

This will produce a lot of temp Strings, send the result to log and crucially, if the verbosity is too low, won't even use it - that's a waste of memory in every sense of the word. I'd like to fix this, the appendMessage method I proposed is only a bandaid for now.

Essentially we don't want to perform any operations, or produce any temporary values if they aren't going to be used, but I can't see a way of doing this without something like

if (verbosity >= Project.MSG_INFO) {
 log(msg + e + msg2);
}

but this is subverting the log method that uses the verbosity internally, and adding conditions to the construction of log messages is not nice.


This is the pattern you encounter with log4j/commons-logging a lot

if(log.isDebug() {
 log.debug("something);
}

skipping the entire concat and log process would speed things up. Too bad the log interface spews everything out and then it gets discarded later. I think in the Ant1.8+ timeframe we could think about tuning how we log to let tasks find out more about how they get logged and feed that back in to string creation.

Regarding the change, I thought for a moment you were in Java5 varargs code. Whatever changes are used they should ideally prepare ant for a world where varargs logging is possible, some years down the line, or much closer in third party java5+ only tasks.

-steve

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to