From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA24520 for caml-redistribution; Thu, 28 Jan 1999 21:00:11 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA14660 for ; Thu, 28 Jan 1999 19:33:06 +0100 (MET) Received: from linc.cis.upenn.edu (LINC.CIS.UPENN.EDU [158.130.12.3]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id TAA17402 for ; Thu, 28 Jan 1999 19:33:04 +0100 (MET) Received: from codex.cis.upenn.edu (CODEX.CIS.UPENN.EDU [158.130.6.15]) by linc.cis.upenn.edu (8.8.5/8.8.5) with ESMTP id NAA11461; Thu, 28 Jan 1999 13:31:37 -0500 (EST) Received: (from mwh@localhost) by codex.cis.upenn.edu (8.8.5/8.8.5) id NAA25917; Thu, 28 Jan 1999 13:31:35 -0500 (EST) From: Michael Hicks 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) Cc: caml-list@inria.fr, Pawel.Wojciechowski@cl.cam.ac.uk In-Reply-To: from "Pawel Wojciechowski" at Jan 27, 99 05:43:30 pm X-Mailer: ELM [version 2.4 PL23-upenn3.1] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > 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."