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 KAA13960; Fri, 31 Jan 2003 10:40:48 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA14071 for caml-list@pauillac.inria.fr; Fri, 31 Jan 2003 10:40:47 +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 VAA02457 for ; Thu, 30 Jan 2003 21:52:58 +0100 (MET) Received: from mallaury.noc.nerim.net (smtp-102.noc.nerim.net [62.4.17.102]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0UKqwr17474 for ; Thu, 30 Jan 2003 21:52:58 +0100 (MET) Received: from karryall.dnsalias.org (karryall.dnsalias.org [62.4.18.180]) by mallaury.noc.nerim.net (Postfix) with ESMTP id 6005F62D02; Thu, 30 Jan 2003 21:52:55 +0100 (CET) Received: by karryall.dnsalias.org (Postfix, from userid 500) id 3A8401A0022; Thu, 30 Jan 2003 21:52:56 +0100 (CET) From: Olivier Andrieu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15929.37032.3235.338843@karryall.dnsalias.org> Date: Thu, 30 Jan 2003 21:52:56 +0100 To: Brian Hurt Cc: Ocaml Mailing List Subject: Re: [Caml-list] @, List.append, and tail recursion In-Reply-To: References: <15929.27280.245255.70626@akasha.ijm.jussieu.fr> X-Mailer: VM 7.07 under Emacs 21.2.1 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Hurt [Thursday 30 January 2003] : > For short lists, this is the worst performer overall. I whipped up a > quick microbenchmark to compare the various implementations- the three > implementations are included in this email. The three programs are: > > list1.ml: lappend uses the @ operator to append the list > > list2.ml: uses local rev_append and rev functions (similiar to those in > List) to append the list > > list3.ml: uses Olivier's set_cdr function. > > The results I saw (compiling with ocamlopt -o list list.ml on a 1.4GHz P4 > running Linux and ocaml 3.06) are: > > list1: 1.462s > list2: 1.757s > list3: 1.824s There's an assert in setcdr : it's important because the first argument mustn't be an empty list. It's never the case here, so you can safely compile with -noassert. On my hardware list3 seems to be a teeny bit faster than list1 but anyway, since list2 is just barely slower, I'm not sure it's worth the trouble. -- Olivier ------------------- 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