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] Slow... very slow...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-02-07 (08:03)
From: Florian Hars <hars@b...>
Subject: Re: [Caml-list] Slow... very slow...
Oliver Bandel wrote:
> Why is the Ocaml-program so slow,

The tool of choice if you don't understand where your program spends it's time 
isn't mutt, but gprof or ocamlprof.

The main problem may be here:

>    let firstsplit = Str.bounded_split (Str.regexp "[ \t]+") line 3

If Str.regexp is implemented in the same way as Pcre.regexp (where I first 
encountered this problem), the compiler regards the call to the external C 
library prividing the regexp code as an unsafe operation that may have side 
effects and so must be repeated on every invocation of Str.bounded_split.
Try moving it to the toplevel:

let tabre = Str.regexp "[ \t]+"

and then change all your functions to use it like:

     let firstsplit = Str.bounded_split tabre line 3

Yours, Florian.

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