You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Robert Hu (JIRA)" <ji...@apache.org> on 2007/06/06 11:56:26 UTC

[jira] Updated: (HARMONY-4064) [classlib][luni] Performance improvement of java.util.HashMap

     [ https://issues.apache.org/jira/browse/HARMONY-4064?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Hu updated HARMONY-4064:
-------------------------------

    Attachment: HARMONY-4064.diff

Please try this patch.
Thanks a lot!

> [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
>         Attachments: HARMONY-4064.diff
>
>
> 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.