https://issues.apache.org/bugzilla/show_bug.cgi?id=51953

--- Comment #11 from Francis Galiegue <fgalie...@gmail.com> 2011-10-05 12:51:19 
UTC ---
This crude test using the following code shows indeed that the byte array based
implementation is indeed MUCH faster:

----
    private static final int COUNT = 50000;

    public static void main(final String[] args) throws UnknownHostException
    {
        final NetMask nm = new NetMask("22.3.25.8/24");
        final NetMask2 nm2 = new NetMask2("22.3.25.8/24");

        final InetAddress in1 = InetAddress.getByName("22.3.25.10"),
            in2 = InetAddress.getByName("cf83::ef:13:1"),
            in3 = InetAddress.getByName("12.143.110.1");

        int i;
        long start, end;

        start = System.currentTimeMillis();
        for (i = 0; i < COUNT; i++) {
            nm.matches(in1);
            nm.matches(in2);
            nm.matches(in3);
        }
        end = System.currentTimeMillis();

        System.out.println("impl1: " + (end - start));

        start = System.currentTimeMillis();
        for (i = 0; i < COUNT; i++) {
            nm2.matches(in1);
            nm2.matches(in2);
            nm2.matches(in3);
        }
        end = System.currentTimeMillis();

        System.out.println("impl2: " + (end - start));

    }
----

Results:

----
impl1: 147
impl2: 11
----

So, it's definitely the byte-based class. I'll try and throw the string compare
into the mix and see how it fares for good measure.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to