Otherwise if the test data size is at all signifigant youll end up holidng multiple copies of it in memory. This could lead to excessive swapping and the like.@hitwords
Also I dont userstand your use of the sub run. cmpthese will execute count_it anyway so I dont see the purpose at all. A last point is that
rings a bell somewhere. Its not that same thing iirc as sayingwhile($word = <WORDS>){
Although i could be wrong. I cant remember where this opinion comes from.while (<WORDS>) {
I would have expected your benchmark to look more like:
use Benchmark qw/cmpthese/; cmpthese 1,{ read_proc => <<'EOFCODE', open(my $words,"words.txt") or die("Wordlist unavaliable.\n"); my $hitcounter=0; my @hitwords; my $counter=0; my @words = <$words>; close($words); foreach my $word (@words){ chomp $word; if ($word =~ m/[aeiouyAEIOUY]{4,}/){ push(@hitwords,$word); $hitcounter++; } $counter++; } EOFCODE for_proc => <<'EOFCODE', open(my $words,"words.txt") or die("Wordlist unavaliable.\n"); my $hitcounter=0; my @hitwords; my $counter=0; foreach my $word (<$words>){ chomp $word; if ($word =~ m/[aeiouyAEIOUY]{4,}/){ push(@hitwords,$word); $hitcounter++; } $counter++; } close($words); EOFCODE while_proc => <<'EOFCODE', open(my $words,"words.txt") or die("Wordlist unavaliable.\n"); my $hitcounter=0; my @hitwords; my $counter=0; while(<$words>){ chomp; if (m/[aeiouyAEIOUY]{4,}/){ push(@hitwords,$_); $hitcounter++; } $counter++; } close($words); EOFCODE };
--- demerphq
my friends call me, usually because I'm late....
In reply to Re: Benchmarking File Retrevial
by demerphq
in thread Benchmarking File Retrevial
by jpfarmer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |