From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA12778; Mon, 5 Nov 2001 12:48:15 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA13340 for ; Mon, 5 Nov 2001 12:48:14 +0100 (MET) Received: from mail.mimuw.edu.pl (paf87.warszawa.sdi.tpnet.pl [217.96.225.87]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fA5BmCH05638 for ; Mon, 5 Nov 2001 12:48:12 +0100 (MET) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id MAA08445 for caml-list@inria.fr; Mon, 5 Nov 2001 12:49:41 +0100 X-Authentication-Warning: qrnik.zagroda: news set sender to Marcin 'Qrczak' Kowalczyk using -f From: "Marcin 'Qrczak' Kowalczyk" Subject: Re: [Caml-list] Specialized dictionaries Date: Mon, 5 Nov 2001 11:49:37 +0000 (UTC) Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: References: <9s5pe7$5k6$1@qrnik.zagroda> X-Trace: qrnik.zagroda 1004960977 8440 192.168.0.1 (5 Nov 2001 11:49:37 GMT) X-Complaints-To: abuse@localhost NNTP-Posting-Date: Mon, 5 Nov 2001 11:49:37 +0000 (UTC) User-Agent: slrn/0.9.7.2 (Linux) To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Mon, 5 Nov 2001 11:19:56 +0100, Xavier Leroy pisze: > No, no need to copy anything, just unleash the power of functors! > > module IntHashtbl = Hashtbl.make(struct type t = int > let equal = (==) > let hash x = x land 0x3FFFFFFF > end) Ok, I tried: Implementation | Test1 | Test2 ---------------------------------+-------+------- Hashtbl.t | 7.40s | 6.45s Hashtbl.Make(...) | 3.62s | 5.35s hashtbl.ml specialized for ints | 2.37s | 5.00s Test1 is a small program which does nothing but dictionary lookups. Test2 is a real program where I use dictionaries. It happenens that let equal = (==) let equal (x : int) (y : int) = x = y are fast, where let equal x y = x = y (* module constrained by Hashtbl.HashedType with type t = int *) let equal : int -> int -> bool = (=) are slow. The compiler doesn't insert the specialized equality version if it's not immediately applied, or if its type is constrained only by module signature. I'm going to use the functorial version: 7% loss of performance wrt. the specialized version is acceptable. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr