harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Hu (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4064) [classlib][luni] Performance improvement of java.util.HashMap
Date Wed, 06 Jun 2007 09:54:26 GMT
[classlib][luni] Performance improvement of java.util.HashMap
-------------------------------------------------------------

                 Key: HARMONY-4064
                 URL: https://issues.apache.org/jira/browse/HARMONY-4064
             Project: Harmony
          Issue Type: Improvement
          Components: Classlib
            Reporter: Robert Hu


The performance of HashMap can be improved, the hash method is improved.
By running the following test code, our HashMap can be improved from 110% time cost (compared
by RI) to 90% time cost (compared by RI).

public class TestHashMap {
    public static void main(String[] args) {
        Random ran = new Random();
        HashMap map = new HashMap();
        int elementNum = 500;
        int times = 10000;
        int[] rans = new int[elementNum];
        for (int i = 0; i < elementNum; i++)
            rans[i] = ran.nextInt(Integer.MAX_VALUE);
        long start = System.currentTimeMillis();
        for (int i = 0; i < elementNum; i++)
            map.put(rans[i], "b");
        System.out.println(System.currentTimeMillis() - start);
        start = System.currentTimeMillis();
        for (int i = 0; i < elementNum; i++)
            for(int j = 0; j< times; j++){
                map.get(rans[i]);
            }
        System.out.println(System.currentTimeMillis() - start);        
    }
}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message