On Apr 28, 2009, at 8:37 PM, Markus Mottl wrote:
On Tue, Apr 28, 2009 at 22:43, Brighten Godfrey <p...@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.


I can't see how this explains the problem. Why should the parsing get dramatically slower when starting to parse the file a *second* time?

(Changing to the precompiled regexp does make this bug go away -- but so do many other small changes, like commenting out the last line of the code, *after* the parsing is complete.)

Thanks very much,
~Brighten

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to