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 QAA01295; Tue, 29 Apr 2003 16:33:21 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 QAA01281 for ; Tue, 29 Apr 2003 16:33:20 +0200 (MET DST) Received: from order.if.uj.edu.pl (order.if.uj.edu.pl [149.156.90.15]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h3TEXKT18296 for ; Tue, 29 Apr 2003 16:33:20 +0200 (MET DST) Received: (from ostruszk@localhost) by order.if.uj.edu.pl (8.11.6/8.11.6) id h3TEdtK29067 for caml-list@inria.fr; Tue, 29 Apr 2003 16:39:55 +0200 Date: Tue, 29 Apr 2003 16:39:55 +0200 From: "Andrzej M. Ostruszka" To: Caml Mailing List Subject: [Caml-list] Re: speed, loops vs. hofs Message-ID: <20030429163955.A28572@order.if.uj.edu.pl> Mail-Followup-To: Caml Mailing List References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from hdaume@ISI.EDU on Mon, Apr 28, 2003 at 10:13:17AM -0700 X-Spam: no; 0.00; andrzej:01 ostruszka:01 ostruszk:01 hofs:01 newbie:01 inlined:01 inlining:01 amo:99 ocamlopt:01 -inline:01 messed:01 instytut:01 fizyki:01 uniwersytet:01 jagiellonski:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, Apr 28 (2003), Hal Daume III wrote: [...] > I find these numbers very disturbing. First, just looking at the > discrepency between 3 and 4. I'd imagine this happens because in (3), the > "let b = false in if not b..." gets folded down to just "cnt := !cnt + 1". << Disclaimer: This is an answer of a newbie :)) >> I haven't checked the assembler output but it looks like the > let f i b = if not b then cnt := !cnt + 1 in is not inlined in the 4th version -- a bit surprising that default inlining level is that conservative. I've cut&pasted the 3rd and 4th functions into the test.ml: [amo@order ostruszk]$ ocamlopt test.ml [amo@order ostruszk]$ ./a.out Time 3 = 1.050000 sec Time 4 = 3.090000 sec [amo@order ostruszk]$ ocamlopt -inline 2 test.ml [amo@order ostruszk]$ ./a.out Time 3 = 1.050000 sec Time 4 = 1.050000 sec As to the module version: it is impossible to inline unknown function. Functions passed in arguments are unknown to the compiler -- unless you've got some "whole program analyser" that checks every use of your loop function -- so every call will be done via the function pointer. I hope I haven't messed up anything and this will be of any help to you :) Best regards -- ____ _ ___ / | \_/ |/ _ \ Andrzej Marek Ostruszka / _ | | (_) | Instytut Fizyki, Uniwersytet Jagiellonski (Cracow) /_/ L|_|V|_|\___/ (PGP <-- finger ostruszk@order.if.uj.edu.pl) ------------------- 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