caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michael Hicks <mwh@dsl.cis.upenn.edu>
To: Pawel.Wojciechowski@cl.cam.ac.uk (Pawel Wojciechowski)
Cc: caml-list@inria.fr, Pawel.Wojciechowski@cl.cam.ac.uk
Subject: Re: Hashtbl or ref Map?
Date: Thu, 28 Jan 1999 13:31:34 -0500 (EST)	[thread overview]
Message-ID: <199901281831.NAA25917@codex.cis.upenn.edu> (raw)
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."




      reply	other threads:[~1999-01-28 20:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-27 17:43 Pawel Wojciechowski
1999-01-28 18:31 ` Michael Hicks [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199901281831.NAA25917@codex.cis.upenn.edu \
    --to=mwh@dsl.cis.upenn.edu \
    --cc=Pawel.Wojciechowski@cl.cam.ac.uk \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).