Date: Tue, 4 Feb 1997 21:47:32 -0500 (EST) From: Thomas David Rivers <ponds!rivers@dg-rtp.dg.com> To: patrick@xinside.com, ponds!freebsd.org!freebsd-hackers Subject: Re: [Fwd: freebsd performance.] Message-ID: <199702050247.VAA23395@lakes.water.net>
next in thread | raw e-mail | index | archive | help
Patrick Giagnocavo writes: > Julian Elischer writes: > > > The posix regex library is VERY VERY slow. > > > > I have a program that uses a large regex to parse some input. > > > > I have a version in perl and a version in C++ using the freebsd posix > > regex library. > > > > The perl version is 100X faster that the C++ version. > > > > gprof on the C++ version shows 99% of the spend in: > > > > 91.53 46.17 46.17 1152366 0.04 0.04 lstep > > 6.52 49.46 3.29 98497 0.03 0.47 lslow > > I am surprised that some of our more erudite members on the list have > not jumped on this. So, a definitely non-erudite person will. > ... > > There are two different 'engines' - NFA (nondeterministic finite > automaton) and DFA (deterministic finite automaton). Perl is > 'traditional NFA' according to Mr. Friedl, while POSIX leans towards > DFA-like behavior in all cases (always returns 'leftmost-longest' that > matches - perl returns I believe the first part that matches). Ah, but you should remember that all NFAs are convertable to DFAs. > > Also, Perl does not 'do' POSIX IIRC; so the results can actually be > different when using the same regex string. Perl does however have > some very powerful features for its regex - covered in the book. This could be part of the reason for a performance difference; if they are not performing the same operation - you're comparing apples and oranges. - Dave Rivers -
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702050247.VAA23395>