Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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