On Mon, 10 Apr 2000, Devin Ben-Hur wrote:
> $ diff first anchored
> 1c1
> < sub first {
> ---
> > sub anchored {
> 9a10
> > my $request = join(" ",$method,$uri);
>
> The only difference between your two benchmark subroutines are their
> names, and that the anchored one also composes your $request variable.
> Of course anchored will take a little longer -- it has one extra
> statement.
>
>
Sorry, it is a Monday. I attached the right file.
J. J. Horner
Linux, Apache, Perl, Unix, Stronghold
[EMAIL PROTECTED] http://www.knoxlug.org
System has been up: 9 days.
#!/usr/bin/perl -w
#
# This script is used to benchmark various algorithms for checking the log file.
# It uses the Benchmark module and some sloppy coding.
use Benchmark;
my @internals =
("192.168","ornl.gov","134.167","199.201","128.219","198.124","198.207","160.91","198.136","198.148","fueleconomy.gov","172.17","172.20");
sub first {
my $i;
my @fields = ("134.167.1.1","","","","","GET","/","HTTP/1.0","404","");
my $source = $fields[0];
$fields[5] =~ s/\"//;
$fields[7] =~ s/\"//;
my $method = $fields[5];
my $uri = $fields[6];
my $protocol = $fields[7];
my $status = $fields[$#fields-1];
for ($i = 0; $i <= $#internals ; $i++) {
if ($source =~ /$internals[$i]/) {
}
}
}
sub anchored {
my $i;
my @fields = ("134.167.1.1","","","","","GET","/","HTTP/1.0","404","");
my $source = $fields[0];
$fields[5] =~ s/\"//;
$fields[7] =~ s/\"//;
my $method = $fields[5];
my $uri = $fields[6];
my $protocol = $fields[7];
my $status = $fields[$#fields-1];
for ($i = 0; $i <= $#internals ; $i++) {
if ($source =~ /^$internals[$i]/) {
}
}
}
timethese(5000, { first => 'first()',anchored => 'anchored()', });