My first foray into Benchmark with the code below produced these results; 

The file is 22000 lines, and there are 2 matches in the file.

[EMAIL PROTECTED] PerlScripts]$ perl benchmark.pl

Regex with modifer
YES
YES
timethis 1000000:  5 wallclock secs ( 4.84 usr +  0.50 sys =  5.34 CPU) @ 187265.92/s 
(n=1000000)

Regex without  modifer
YES
YES
timethis 1000000:  7 wallclock secs ( 4.75 usr +  0.57 sys =  5.32 CPU) @ 187969.92/s 
(n=1000000)

It would seem to me that the /o modifier makes little difference, or is it that I am 
using the modifer incorrectly or even using Benchmark incorrectly?


TIA


Owen




----------------------------------------------------------------
#!/usr/bin/perl -w

           use Benchmark qw(:all) ;
           use strict;
           
           my $count = 1000000;
           my $name = "STILL";
           my $file = "test.data";
           my $line;
           open (FH,"$file") || die "Can't open $file $!\n";
           print "\nRegex with modifer\n";
                   
           timethis ($count, 
                sub{
                while(<FH>){
                chomp;$line=$_;
                if ($line=~/$name/o){print "YES\n"}
                }});
                close FH;
                
           open (FH,"$file") || die "Can't open $file $!\n";
           print "\nRegex without  modifer\n";
                        
                timethis ($count, 
                sub{
                while(<FH>){
                chomp;$line=$_;
                if ($line=~/$name/){print "YES\n"}
                }}); 

__END__

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to