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
Strange performance bug
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-29 (03:37)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] Strange performance bug
On Tue, Apr 28, 2009 at 22:43, Brighten Godfrey <pbg@cs.berkeley.edu> wrote:
> I've encountered a very odd performance problem which I suspect is not a bug
> in my code.  Could it be the compiler, or maybe PCRE?

I'm not sure it solves your problem (haven't tried the example), but
just looking at the code there is clearly a performance bug: the
pattern is passed to Pcre.pmatch "on the fly" using label "~pat".
This is ok and convenient if it is used only once, but is bad if it
happens in a loop.  Precompile the regular expression outside of the
loop (let rex = Pcre.regexp "...") and pass it in with label "~rex" to
solve this problem.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com