caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Andrzej M. Ostruszka" <ostruszk@order.if.uj.edu.pl>
To: Caml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] Re: speed, loops vs. hofs
Date: Tue, 29 Apr 2003 16:39:55 +0200	[thread overview]
Message-ID: <20030429163955.A28572@order.if.uj.edu.pl> (raw)
In-Reply-To: <Pine.GSO.4.21.0304280958590.20131-100000@moussor.isi.edu>; from hdaume@ISI.EDU on Mon, Apr 28, 2003 at 10:13:17AM -0700

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


  reply	other threads:[~2003-04-29 14:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-28 17:13 [Caml-list] " Hal Daume III
2003-04-29 14:39 ` Andrzej M. Ostruszka [this message]
2003-04-30  0:45 ` Manos Renieris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030429163955.A28572@order.if.uj.edu.pl \
    --to=ostruszk@order.if.uj.edu.pl \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).