in reply to Re: Need regexes with alternations in them for testing perl...
in thread Need regexes with alternations in them for testing perl...

Thanks. This was interesting. I ended up playing around with words.t and discovered a slight bug that isn't exposed by this test. The regex /foobar|foo/ is equivelent to /foo(?:bar)?/ the regex /foo|foobar/ is equivelent to the regex /foo(?:|bar)/. Regex::PreSuf along with similar modules like Regexp::Assemble and Regexp::List will generate /foo(?:bar)?/ for both. Eg:

G:\cblead2\win32>perl -e "print $& if 'foobar'=~/foo|foobar/" foo G:\cblead2\win32>perl -e "print $& if 'foobar'=~/foo(?:|bar)/" foo G:\cblead2\win32>perl -e "print $& if 'foobar'=~/foobar|foo/" foobar G:\cblead2\win32>perl -e "print $& if 'foobar'=~/foo(?:bar)?/" foobar

Unfortunately this makes them not entirely suitable for my needs. But it has proved interesting using them. :-)

G:\>g:\perl_trie\bin\perl regexp.pl --words=foo;foobar;baz;bop;brief;z +oo g:\perl_blead\bin\perl.exe used the following Regex modules: Regexp::List, Regexp::Assemble, Regexp::Optimizer, Regex::PreSuf Read 184821 chars from '\blead_trie\regcomp.c' Got 6 words to match Testing regexes: Regexp 'RA' [Regexp::Assemble] : (?x-ism:( (?: b (?: rief | az | op )| foo (?: bar )?| zoo ) )) Regexp 'RL' [Regexp::List] : (?x-ism:( (?= [bfz] )(?: foo (?: bar )?| b (?: az | op | rief )| zoo ) )) Regexp 'RO' [Regexp::Optimizer] : (?x-ism:( (?: foo (?: bar )?| b (?: az | op | rief )| zoo ) )) Regexp 'RPS' [Regex::PreSuf] : (?x-ism:( (?: b (?: az | op | rief )| foo (?: bar )?| zoo ) )) Regexp 'smpl' : (?x-ism:( foo | foobar | baz | bop | brief | zoo )) Running tests for 2 seconds on 2 perls: Pfx |Perl ----+-------------------------- A |g:\perl_trie\bin\perl.exe B |g:\perl_blead\bin\perl.exe ----+-------------------------- Rate A_RO A_RPS A_RA B_smpl B_RO B_RPS B_RA A_RL B +_RL A_smpl A_RO 18.2/s -- -1% -2% -9% -24% -26% -27% -43% - +52% -53% A_RPS 18.5/s 1% -- -0% -8% -23% -25% -26% -42% - +51% -52% A_RA 18.5/s 2% 0% -- -8% -22% -25% -26% -42% - +51% -52% B_smpl 20.1/s 10% 9% 8% -- -16% -19% -20% -37% - +47% -48% B_RO 23.9/s 31% 30% 29% 19% -- -3% -5% -25% - +37% -38% B_RPS 24.7/s 36% 34% 33% 23% 3% -- -1% -23% - +35% -36% B_RA 25.1/s 38% 36% 35% 25% 5% 1% -- -22% - +34% -35% A_RL 32.0/s 76% 74% 73% 60% 34% 30% 28% -- - +15% -17% B_RL 37.9/s 108% 105% 104% 89% 58% 53% 51% 18% + -- -2% A_smpl 38.6/s 112% 109% 108% 92% 61% 56% 54% 20% + 2% -- Testing with /\b(PAT)\b/ Pfx |Perl ----+-------------------------- A |g:\perl_trie\bin\perl.exe B |g:\perl_blead\bin\perl.exe ----+-------------------------- Rate B_smpl A_RA A_RO A_RPS B_RA B_RPS B_RO A_RL B +_RL A_smpl B_smpl 71.8/s -- -5% -5% -5% -13% -14% -14% -32% - +37% -42% A_RA 75.5/s 5% -- -0% -1% -9% -9% -10% -28% - +34% -39% A_RO 75.7/s 5% 0% -- -0% -9% -9% -9% -28% - +33% -39% A_RPS 76.0/s 6% 1% 0% -- -8% -9% -9% -28% - +33% -39% B_RA 83.0/s 16% 10% 10% 9% -- -0% -1% -21% - +27% -33% B_RPS 83.1/s 16% 10% 10% 9% 0% -- -1% -21% - +27% -33% B_RO 83.5/s 16% 11% 10% 10% 1% 1% -- -21% - +27% -33% A_RL 105/s 47% 40% 39% 39% 27% 27% 26% -- +-7% -15% B_RL 114/s 58% 51% 50% 50% 37% 37% 36% 8% + -- -8% A_smpl 124/s 73% 64% 64% 63% 50% 49% 49% 18% + 9% -- G:\>
---
demerphq