You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I'm seeing that, like pcre-heavy, it takes a surprisingly long time when replacing patterns that occurs many times in a string. I haven't investigated, but I suspect it's taking time proportional to the number of matched patterns times the length of the string, which would mean quadratic time complexity in the case where the string is densely filled with patterns. See https://github.com/jamesdbrock/replace-benchmark#results
Or maybe I'm using your library wrong? Is there a better way to write this following program?
main =T.putStr=<< ([regex|x|] . match %~const"oo") <$>T.getContents
Oh wow! Yikes, that's pretty unacceptable. Thanks for pointing it out 😄 . Judging from the fact that the pcre-heavy benchmark is slow too, it must be occurring in the match detection part. I have a hard time believing the underlying C lib is that slow, so there must be a glitch somewhere along the way (possibly even in pcre-light). I'll try to remember to take a look under the hood when I have time, this is way worse than it should be.
BTW the idiomatic way would be ([regex|x|] . match .~ "oo") but they expand to the exact same thing 😄
Hi Chris!
I was moved by reading this line your README
to benchmark
lens-regex-pcre
in myreplace-benchmark
suite.I think I'm seeing that, like
pcre-heavy
, it takes a surprisingly long time when replacing patterns that occurs many times in a string. I haven't investigated, but I suspect it's taking time proportional to the number of matched patterns times the length of the string, which would mean quadratic time complexity in the case where the string is densely filled with patterns. See https://github.com/jamesdbrock/replace-benchmark#resultsOr maybe I'm using your library wrong? Is there a better way to write this following program?
https://github.com/jamesdbrock/replace-benchmark/blob/92290b7f3334c9dfae911fda4ab57e5c1c705998/src/LensRegexText.hs#L10
https://github.com/jamesdbrock/replace-benchmark/blob/92290b7f3334c9dfae911fda4ab57e5c1c705998/src/LensRegexByteString.hs#L9
The sparse benchmark case for
lens-regex-pcre
is nice and speedy.Congratulations on publishing Optics by Example, and thanks for writing it!
The text was updated successfully, but these errors were encountered: