3
# Generates a test file for comparing @rx and @pm speed.
8
srand(424242); # We want this static, so we can compare different runs
10
my $MIN = $ARGV[0] || 0;
11
my $MAX = $ARGV[1] || 5000;
12
my $INC = $ARGV[2] || int($MAX * .05);
13
my $ITERATIONS = 10000;
17
my $match = join '', ('a' .. 'z');
21
my $ra = Regexp::Assemble->new;
24
unshift @param, rndstr();
32
" comment => \"rx1 %6d item(s)\",\n".
35
" param => qr/%s/,\n".
36
" input => \"%s\",\n".
37
" ret => " . (@param ? 0 : 1) . ",".
38
" iterations => %d,\n".
42
(@param ? '(?:' . join('|', @param) . ')' : ""),
48
"# rx-optimized: %6d\n".
50
" comment => \"rx2 %6d item(s)\",\n".
53
" param => qr/%s/,\n".
54
" input => \"%s\",\n".
55
" ret => " . (@param ? 0 : 1) . ",".
56
" iterations => %d,\n".
60
(@param ? $ra->as_string : ""),
68
" comment => \"pm1 %6d item(s)\",\n".
71
" param => \"%s\",\n".
72
" input => \"%s\",\n".
74
" iterations => %d,\n".
78
join(' ', @param ? @param : ("''")),
83
$i = ($i == $MIN) ? ($i + $INC) - ($i % $INC) : $i + $INC;
90
my $max = int(rand($MAXSTRLEN - $MINSTRLEN)) + $MINSTRLEN;
92
$rndstr .= $c[rand @c];
94
# We need a string that is not in another string for "last"
95
if ($match =~ m/$rndstr/) {