geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "gianny DAMOUR" <gianny_dam...@hotmail.com>
Subject RE: JMX Management Console (ObjectName hog)
Date Wed, 03 Sep 2003 08:34:54 GMT
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


Mime
View raw message