in reply to Benchmarking File Retrevial
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....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Benchmarking File Retrevial
by jpfarmer (Pilgrim) on Dec 15, 2002 at 23:14 UTC | |
by chromatic (Archbishop) on Dec 15, 2002 at 23:51 UTC | |
by demerphq (Chancellor) on Dec 16, 2002 at 00:06 UTC | |
|
Re: Re: Benchmarking File Retrevial
by jpfarmer (Pilgrim) on Dec 16, 2002 at 08:14 UTC |