commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: [COLLECTIONS] FastHashMap performance
Date Tue, 03 Jun 2003 18:54:33 GMT

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:baliuka@centras.lt]
>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" <Yoav.Shapira@mpi.com>
>To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
>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:baliuka@centras.lt]
>>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" <Yoav.Shapira@mpi.com>
>>To: <commons-dev@jakarta.apache.org>
>>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: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
>
>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: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org




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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message