In your test, are you synchronizing the HashMap?  FastHashMap implements
smart synchronization.  It should not be compared with an unsynchronized
version of HashMap.

P.S.  In fact, it might be nice to allow doing this smart synchronization
on *any* Map.  i.e. alternative to Collections.synchronizeMap(Map).

Eric Pabst
Discover Financial Services
2500 Lake Park Blvd., 3N
West Valley City, UT 84120
Ph: 801.902.4636
Fax: 801.902.4123



|---------+--------------------------->
|         |           "Shapira, Yoav" |
|         |           <[EMAIL PROTECTED]|
|         |           i.com>          |
|         |                           |
|         |           06/03/03 12:54  |
|         |           PM              |
|         |           Please respond  |
|         |           to "Jakarta     |
|         |           Commons         |
|         |           Developers List"|
|         |                           |
|---------+--------------------------->
  
>---------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                           |
  |        To:      "Jakarta Commons Developers List" <[EMAIL PROTECTED]>              
              |
  |        cc:                                                                         
                           |
  |        Subject: RE: [COLLECTIONS] FastHashMap performance                          
                           |
  
>---------------------------------------------------------------------------------------------------------------|





Howdy,
I understand it's just a wrapper, and that the
reading cannot be any faster.  I'm curious why the
writing is so much faster, even in the default (not fast)
mode of FastHashMap.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Juozas Baliuka [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, June 03, 2003 2:36 PM
>To: Jakarta Commons Developers List
>Subject: Re: [COLLECTIONS] FastHashMap performance
>
>FastHashMap can not be faster than HasMap in single thread just because
it
>uses HasMap to implement mappings:
>
> public Object get(Object key) {
>        if (fast) {
>            return (map.get(key));
>        } else {
>            synchronized (map) {
>                return (map.get(key));
>            }
>        }
>    }
>
>
>/**
>     * Construct an empty map.
>     */
>    public FastHashMap() {
>        super();
>        this.map = new HashMap();
>    }
>
>----- Original Message -----
>From: "Shapira, Yoav" <[EMAIL PROTECTED]>
>To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
>Sent: Tuesday, June 03, 2003 8:00 PM
>Subject: RE: [COLLECTIONS] FastHashMap performance
>
>
>Howdy,
>Neither did I, but I just ran the attached benchmark and got surprising
>results.  I hope the attachement comes through OK: if not I'll re-post
>inline.  This benchmark has just one thread writing, one thread
reading,
>which I expected to be the case where FastHashMap is not as efficient
as
>HashMap.
>
>The benchmark inserts 100000 records in the map, then reads 1000 of
>those at random.  I run this 10 times for each map implemention.  I'm
>ignoring the first run read times as there's overhead in initializing
>the Random generator.
>
>I'm running this test on JDK 1.4.1, no special java switches, just java
>MapTest on the command line, on Solaris 8.
>
>I'm very curious to hear comments, ideas.  I was expecting to have to
>write another test with multiple writing threads, but if FastHashMap is
>faster even for the simple case, why ever use the regular HashMap?
>
>The results are:
>[MapTest: Map class: java.util.HashMap / Insert time: 1616 / Read time:
>30]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 1252 / Read time: 6]
>[MapTest: Map class: java.util.HashMap / Insert time: 958 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 1203 / Read time: 2]
>[MapTest: Map class: java.util.HashMap / Insert time: 820 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 988 / Read time: 2]
>[MapTest: Map class: java.util.HashMap / Insert time: 781 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 1033 / Read time: 3]
>[MapTest: Map class: java.util.HashMap / Insert time: 720 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 1067 / Read time: 2]
>[MapTest: Map class: java.util.HashMap / Insert time: 1454 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 1267 / Read time: 2]
>[MapTest: Map class: java.util.HashMap / Insert time: 1534 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 862 / Read time: 2]
>[MapTest: Map class: java.util.HashMap / Insert time: 1433 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 844 / Read time: 2]
>[MapTest: Map class: java.util.HashMap / Insert time: 1578 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 1488 / Read time: 2]
>[MapTest: Map class: java.util.HashMap / Insert time: 1450 / Read time:
>2]
>[MapTest: Map class: org.apache.commons.collections.FastHashMap /
Insert
>time: 859 / Read time: 2]
>
>Yoav Shapira
>Millennium ChemInformatics
>
>
>>-----Original Message-----
>>From: Juozas Baliuka [mailto:[EMAIL PROTECTED]
>>Sent: Tuesday, June 03, 2003 1:53 PM
>>To: Jakarta Commons Developers List
>>Subject: Re: [COLLECTIONS] FastHashMap performance
>>
>>I do not think it is faster than java.util.HashMap, it is just pseudo
>>thread
>>safe wrapper.
>>
>>----- Original Message -----
>>From: "Shapira, Yoav" <[EMAIL PROTECTED]>
>>To: <[EMAIL PROTECTED]>
>>Sent: Tuesday, June 03, 2003 7:17 PM
>>Subject: [COLLECTIONS] FastHashMap performance
>>
>>
>>
>>Howdy,
>>Has anyone benchmarked the performance of the FastHashMap and how it
>>compares to the java.util.HashMap implementation?  If so, are the
>>benchmarks available online somewhere?
>>
>>I don't doubt its quality nor its performance, just curious... Thanks,
>>
>>Yoav Shapira
>>Millennium ChemInformatics
>>
>>
>>
>>
>>
>>This e-mail, including any attachments, is a confidential business
>>communication, and may contain information that is confidential,
>>proprietary
>>and/or privileged.  This e-mail is intended only for the individual(s)
>to
>>whom it is addressed, and may not be saved, copied, printed, disclosed
>or
>>used by anyone else.  If you are not the(an) intended recipient,
please
>>immediately delete this e-mail from your computer system and notify
the
>>sender.  Thank you.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>This e-mail, including any attachments, is a confidential business
>communication, and may contain information that is confidential,
>proprietary
>and/or privileged.  This e-mail is intended only for the individual(s)
to
>whom it is addressed, and may not be saved, copied, printed, disclosed
or
>used by anyone else.  If you are not the(an) intended recipient, please
>immediately delete this e-mail from your computer system and notify the
>sender.  Thank you.
>
>
>
>
>
>-----------------------------------------------------------------------
----
>-
>----
>
>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential,
proprietary and/or privileged.  This e-mail is intended only for the
individual(s) to whom it is addressed, and may not be saved, copied,
printed, disclosed or used by anyone else.  If you are not the(an) intended
recipient, please immediately delete this e-mail from your computer system
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to