caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Hashtbl or ref Map?
@ 1999-01-27 17:43 Pawel Wojciechowski
  1999-01-28 18:31 ` Michael Hicks
  0 siblings, 1 reply; 2+ messages in thread
From: Pawel Wojciechowski @ 1999-01-27 17:43 UTC (permalink / raw)
  To: caml-list; +Cc: Pawel.Wojciechowski

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? 

Pawel

-- 
   ------------------------------------------------------------
      Pawel T Wojciechowski            cambridge university
      www.cl.cam.ac.uk/users/ptw20         computer lab.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Hashtbl or ref Map?
  1999-01-27 17:43 Hashtbl or ref Map? Pawel Wojciechowski
@ 1999-01-28 18:31 ` Michael Hicks
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Hicks @ 1999-01-28 18:31 UTC (permalink / raw)
  To: Pawel Wojciechowski; +Cc: caml-list, Pawel.Wojciechowski


> 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."




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-01-28 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-27 17:43 Hashtbl or ref Map? Pawel Wojciechowski
1999-01-28 18:31 ` Michael Hicks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).