Re: Hashtbl or ref Map?

From: Michael Hicks (mwh@dsl.cis.upenn.edu)
Date: Thu Jan 28 1999 - 19:31:34 MET


From: Michael Hicks <mwh@dsl.cis.upenn.edu>
Message-Id: <199901281831.NAA25917@codex.cis.upenn.edu>
Subject: Re: Hashtbl or ref Map?
To: Pawel.Wojciechowski@cl.cam.ac.uk (Pawel Wojciechowski)
Date: Thu, 28 Jan 1999 13:31:34 -0500 (EST)
In-Reply-To: <E105Yzz-0007hg-00@heaton.cl.cam.ac.uk> from "Pawel Wojciechowski" at Jan 27, 99 05:43:30 pm

> I'd like to have a simple map (association table, not hashed)
> and share it between OCAML threads. Which module (from efficiency
> point-of-view) it would better to use for that purpose: Hashtbl
> or ref Map?

I was wondering the same thing and did some experiements. On my pentium 166
with lots of memory, I ran a test which inserted about 150 different strings
into the table and then looked up each string. The time for the hashtable
operations includes the time to enter and exit a critical section. I
measured the total time to insert all of the strings, and the total time to
find all of the strings. The initial size of the hashtable didn't affect
the overall measurements by a significant amount.

Using the bytecode compiler, I found that inserts for the hashtable are
about 4 times faster, and finds are almost twice as fast. With native code,
the hashtable is about 2.5 times faster for inserts and about 1.3 times
faster for finds.

Of course, the hashtable does not allow different threads to look at
versions of the table created at different times, whereas a map would.

Mike

-- 
Michael Hicks
Ph.D. Candidate, the University of Pennsylvania
http://www.cis.upenn.edu/~mwh            mailto://mwh@dsl.cis.upenn.edu
"I worked with an individual who plugged his power strip back into itself
and for the life of him could not understand why his computer would not
turn on."



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:19 MET