English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Functors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-04 (07:43)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] Functors

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