The caching that in ObjectName most likely makes it faster, but for your test, you should try a name with like 5 key value pairs, because the JSR 77 names tend to be very long.

-dain


On Wednesday, September 3, 2003, at 03:34 AM, gianny DAMOUR wrote:

Simon wrote:
> My guess it it is faster to use a (pre-compiled) regular
> expression to
> grab the chunk you are interested in out our the string
> directly.  Last
> I checked constructing an ObjectName was very expensive.

[...]
So, IMHO no need to use regexp.

I have done a micro-bench and the regexp approach is an order of magnitude (2 times) slower than a naive ObjectName.getKeyProperty.


I used the RE of the JDK1.4, yet perhaps that Jakarta regexp is quicker.

A snippet to check it for yourself:

           Pattern pattern = Pattern.compile("(.*):j2eeType=(.*)");

int iter = 100000;
long start = System.currentTimeMillis();
for (int i = 0; i < iter; i++) {
Matcher m = pattern.matcher("fwewe:j2eeType=ffqwefqwe");
m.matches();
m.group(2);
}
long end = System.currentTimeMillis();
System.out.println("perf=" + (end - start));
start = System.currentTimeMillis();
for (int i = 0; i < iter; i++) {
ObjectName name = new ObjectName("fwewe:j2eeType=ffqwefqwe");
name.getKeyProperty("j2eeType");
}
end = System.currentTimeMillis();
System.out.println("perf=" + (end - start));


_________________________________________________________________
Hotmail : un compte GRATUIT qui vous suit partout et tout le temps ! http://g.msn.fr/FR1000/9493




/************************* * Dain Sundstrom * Partner * Core Developers Network *************************/



Reply via email to