caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: Jon Harrop <jdh30@cam.ac.uk>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Functors
Date: Tue, 4 May 2004 09:25:41 +0200	[thread overview]
Message-ID: <16535.17781.103979.884152@gargle.gargle.HOWL> (raw)
In-Reply-To: <200405031941.46770.jdh30@cam.ac.uk>


Jon Harrop writes:
 > 
 > Absolutely, but it can result in a huge performance increase in some cases. 
 > Although these cases may seem to be insignificant to most people
 > round these  parts, I believe they would be a make-or-break for
 > someone considering ocaml  for numerical work. The most obvious
 > example would be to use functors to  partially specialise code for
 > a primitive vector or geometric type.  

I  have  such an  example:  I  recently  wrote Ukkonen's  suffix  tree
algorithm in a functorized way,  being generic w.r.t. the alphabet and
w.r.t. to branching data structure used in the trees.

When applied  to the particular char/string  alphabet, the performance
was quite poor  w.r.t. some C code implementing  the same algorithm. I
defunctorized manually and  got a 5 times speedup  (and the ocaml code
now runs almost as fast as  the C code, while still generic w.r.t. the
tree  data type).  The  main reason  was  that the  most often  called
function was  String.get (millions of  times) and through  the functor
argument it didn't get inlined.

-- 
Jean-Christophe Filliâtre (http://www.lri.fr/~filliatr)

-------------------
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:[~2004-05-04  7:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-02  9:12 Jon Harrop
2004-05-02 10:24 ` Martin Jambon
2004-05-02 13:34   ` Jon Harrop
2004-05-02 14:12     ` skaller
2004-05-02 16:49       ` Jon Harrop
2004-05-03  0:20         ` skaller
2004-05-03 14:43           ` Jacques Carette
2004-05-03 16:09             ` Alain.Frisch
2004-05-03 18:53               ` Jacques Carette
2004-05-03 19:17                 ` [Caml-list] Mathematica Jon Harrop
2004-05-03 22:51                 ` [Caml-list] Functors Alain.Frisch
2004-05-03 16:02     ` Julien Signoles
2004-05-03 18:41       ` Jon Harrop
2004-05-04  7:25         ` Jean-Christophe Filliatre [this message]
2004-05-05  8:15         ` Julien Signoles
2004-05-05 20:41           ` brogoff
2004-05-06 11:16             ` Jon Harrop
2004-05-06 20:23               ` Alain.Frisch
2004-05-06 18:26                 ` Olivier Grisel
2004-05-06 12:26             ` Julien Signoles
2004-05-06 16:35               ` brogoff
2004-05-02 17:18   ` David Brown

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=16535.17781.103979.884152@gargle.gargle.HOWL \
    --to=jean-christophe.filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=jdh30@cam.ac.uk \
    /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).