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 JAA30715; Sun, 4 May 2003 09:55:27 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 JAA30616 for ; Sun, 4 May 2003 09:55:26 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h447tPH08888 for ; Sun, 4 May 2003 09:55:25 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id D394A5EB6; Sun, 4 May 2003 10:55:24 +0300 (EEST) Date: Sun, 4 May 2003 10:55:24 +0300 Subject: Re: [Caml-list] Efficiency of 'a list Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: "caml Mailing List'" To: alc@PublicPropertySoftware.com From: Ville-Pertti Keinonen In-Reply-To: <3EB4922A.A69C2038@PublicPropertySoftware.com> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Spam: no; 0.00; caml-list:01 recursively:01 iterating:01 arrays:01 ocaml:01 checking:01 optimizer:02 bounds:03 btw:03 array:04 efficiency:05 maybe:06 lists:91 looping:08 certainly:09 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I've done a little timing of things, and according to my results: > If you care about efficiency and use OCaml, you should use lists > fairly often, ie if you are always looping and accessing the elements > in order. OCaml can iterate through a list (recursively) about twice as > fast as it can iterate through an array. It can iterate through a > list about as fast as or maybe even a little faster than C or C++ can > iterate through an array. Don't trust microbenchmarks too far over what your knowledge of how things should work tell you. Iterating over arrays is certainly going to be much more cache- and TLB-friendly. BTW: Did you try turning off bounds checking? The OCaml optimizer isn't smart enough to get rid of them. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners