~ubuntu-branches/ubuntu/natty/libapache-mod-security/natty-updates

« back to all changes in this revision

Viewing changes to apache2/t/gen_rx-pm.pl.in

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Gonzalez Iniesta
  • Date: 2008-08-08 13:31:56 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080808133156-6jqb24apsw787v33
Tags: 2.5.6-1
* The 'Back to the archive!' Release (Closes: #487431)
* Drop '2' from package name, now libapache-mod-security
* New upstream release
  - Includes a new licensing exception that allows binary 
    distribution with licenses not compatible with GPLv2,
    such as Apache's. See MODSECURITY_LICENSING_EXCEPTION
* Removed debian/bug and debian/rules entry to install bug
  handling when out of the archive.
* Bumped Standards-Version to 3.8.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@PERL@
 
2
#
 
3
# Generates a test file for comparing @rx and @pm speed.
 
4
#
 
5
use strict;
 
6
use Regexp::Assemble;
 
7
 
 
8
srand(424242); # We want this static, so we can compare different runs
 
9
 
 
10
my $MIN = $ARGV[0] || 0;
 
11
my $MAX = $ARGV[1] || 5000;
 
12
my $INC = $ARGV[2] || int($MAX * .05);
 
13
my $ITERATIONS = 10000;
 
14
my $MINSTRLEN = 2;
 
15
my $MAXSTRLEN = 8;
 
16
 
 
17
my $match = join '', ('a' .. 'z');
 
18
my @param = ();
 
19
my $i=$MIN;
 
20
while ($i <= $MAX) {
 
21
        my $ra = Regexp::Assemble->new;
 
22
 
 
23
        while (@param < $i) {
 
24
                unshift @param, rndstr();
 
25
        }
 
26
 
 
27
        $ra->add(@param);
 
28
 
 
29
        printf (
 
30
                "# rx: %6d\n".
 
31
                "{\n".
 
32
                "  comment => \"rx1 %6d item(s)\",\n".
 
33
                "  type => \"op\",\n".
 
34
                "  name => \"rx\",\n".
 
35
                "  param => qr/%s/,\n".
 
36
                "  input => \"%s\",\n".
 
37
                "  ret => " . (@param ? 0 : 1) . ",".
 
38
                "  iterations => %d,\n".
 
39
                "},\n",
 
40
                $i,
 
41
                $i,
 
42
                (@param ? '(?:' . join('|', @param) . ')' : ""),
 
43
                $match,
 
44
                $ITERATIONS,
 
45
        );
 
46
 
 
47
        printf (
 
48
                "# rx-optimized: %6d\n".
 
49
                "{\n".
 
50
                "  comment => \"rx2 %6d item(s)\",\n".
 
51
                "  type => \"op\",\n".
 
52
                "  name => \"rx\",\n".
 
53
                "  param => qr/%s/,\n".
 
54
                "  input => \"%s\",\n".
 
55
                "  ret => " . (@param ? 0 : 1) . ",".
 
56
                "  iterations => %d,\n".
 
57
                "},\n",
 
58
                $i,
 
59
                $i,
 
60
                (@param ? $ra->as_string : ""),
 
61
                $match,
 
62
                $ITERATIONS,
 
63
        );
 
64
 
 
65
        printf (
 
66
                "# pm: %6d\n".
 
67
                "{\n".
 
68
                "  comment => \"pm1 %6d item(s)\",\n".
 
69
                "  type => \"op\",\n".
 
70
                "  name => \"pm\",\n".
 
71
                "  param => \"%s\",\n".
 
72
                "  input => \"%s\",\n".
 
73
                "  ret => 0,".
 
74
                "  iterations => %d,\n".
 
75
                "},\n",
 
76
                $i,
 
77
                $i,
 
78
                join(' ', @param ? @param : ("''")),
 
79
                $match,
 
80
                $ITERATIONS,
 
81
        );
 
82
 
 
83
        $i = ($i == $MIN) ? ($i + $INC) - ($i % $INC) : $i + $INC;
 
84
 
 
85
}
 
86
 
 
87
sub rndstr {
 
88
        my @c = ('a' .. 'z');
 
89
        my $rndstr;
 
90
  my $max = int(rand($MAXSTRLEN - $MINSTRLEN)) + $MINSTRLEN;
 
91
        foreach (1 .. $max) {
 
92
                $rndstr .= $c[rand @c];
 
93
        }
 
94
        # We need a string that is not in another string for "last"
 
95
        if ($match =~ m/$rndstr/) {
 
96
                $rndstr = rndstr();
 
97
        }
 
98
        return $rndstr;
 
99
}