Hi!

I did a few trickery things with ellipsis parameters to highly speed up 
Validate invocations. 

One of the main problems with validation and logging is the message 
construction which usually causes enormous amounts of String operations which 
means object creations and thus heavy garbage collection effort.

To shorten this, I now use ellipsis notation to simply pass all the objects 
which should be concatenated to the error message if, _and_only_if_ the 
validation fails!

I wrote this for EGIT org.spearce.jgit.util.Validate [1] and also did a few 
quick tests on the algorithm to ensure that the ellipsis handling in Java 
doesn't cause any performance side effects [2].

The numbers are pretty ok ;)

strmsg 1 took: 445
strmsg 2 took: 32
strmsg 1 took: 149
strmsg 2 took: 17

or

strmsg 1 took: 8040
strmsg 2 took: 397
strmsg 1 took: 7478
strmsg 2 took: 393

for ITERATIONS=10000000;


I already wrote Sigi (he is in the commons PMC) how we could best move this to 
commons.lang.Validate. 

If you have any additional ideas, then please tell me ;)

LieGrue,
strub

[1] 
http://github.com/sonatype/JGit/blob/2ab3a576fa67145d6a9f66efd7437c52d567eb68/org.spearce.jgit/src/org/spearce/jgit/util/Validate.java

[2] http://pastebin.com/m2cf887a9



Reply via email to