[prev in list] [next in list] [prev in thread] [next in thread] 

List:       e-lang
Subject:    [e-lang] Java Kernel Timing Tests
From:       Tyler Close <list () waterken ! net>
Date:       2003-11-26 22:56:44
[Download RAW message or body]

As MarkM mentioned, the recent method dispatch benchmarks made me
suspect there is something very wrong with E's hashtable
implementation. I wrote another benchmark to test this hypothesis.
The results confirm the hypothesis:

org.erights.e.elib.tables.FlexMapImpl get() time: 30241
java.util.HashMap get() time: 391
com.waterken.adt.hashed.hashtable.HashMap search() time: 553

I don't know what's causing the E implementation to be ~100x
slower than the others. The E implementation is written in Java,
same as the others.

I suspect the ADT implementation is slower than the java.util
implementation because ADT uses array storage instead of per
element node objects. I suspect array indexing is slower than
member access. The advantage of the ADT approach is significantly
lower memory use.

These results were generated by the following code:

import java.util.Random;

public final
class Main
{
    /**
     * The number of operation iterations per test.
     */
    private static final int LOOP = 1000000;

    public static
    void testE()
    {
        // Build the map.
        Random entropy = new Random(0);
        org.erights.e.elib.tables.FlexMap m = 
org.erights.e.elib.tables.FlexMap.make();
        for(int n = 10; n-- != 0;)
            m.put("" + entropy.nextInt(), new Object());

        // Setup search test.
        String key = "" + entropy.nextInt();
        m.put(key, new Object());
        m.get(key);

        // Test search.
        long start = System.currentTimeMillis();
        for(int n = LOOP; n-- != 0;)
            m.get(key);
        long finish = System.currentTimeMillis();
        System.out.println(m.getClass().getName() + " get() time: " + (finish 
- start));
    }

    public static
    void testJava()
    {
        // Build the map.
        Random entropy = new Random(0);
        java.util.Map m = new java.util.HashMap();
        for(int n = 10; n-- != 0;)
            m.put("" + entropy.nextInt(), new Object());

        // Setup search test.
        String key = "" + entropy.nextInt();
        m.put(key, new Object());
        m.get(key);

        // Test search.
        long start = System.currentTimeMillis();
        for(int n = LOOP; n-- != 0;)
            m.get(key);
        long finish = System.currentTimeMillis();
        System.out.println(m.getClass().getName() + " get() time: " + (finish 
- start));
    }

    public static
    void testADT()
    {
        // Build the map.
        Random entropy = new Random(0);
        com.waterken.adt.hashed.Map m = 
com.waterken.adt.tuple.Tuple.make().toMap();
        for(int n = 10; n-- != 0;)
            m = m.with("" + entropy.nextInt(), new Object());

        // Setup search test.
        String key = "" + entropy.nextInt();
        m = m.with(key, new Object());
        m.search(key);

        // Test search.
        long start = System.currentTimeMillis();
        for(int n = LOOP; n-- != 0;)
            m.search(key);
        long finish = System.currentTimeMillis();
        System.out.println(m.getClass().getName() + " search() time: " + 
(finish - start));
    }

    public static
    void main(String[] args) throws Exception
    {
        testE();
        testJava();
        testADT();
    }
}

-- 
The union of REST and capability-based security.
http://www.waterken.com/dev/Web/


_______________________________________________
e-lang mailing list
e-lang@mail.eros-os.org
http://www.eros-os.org/mailman/listinfo/e-lang
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic