On Mon, Mar 13, 2000 at 08:40:29PM +0000, David L. Nicol wrote: > "defined" is implemented as a function call in these > cases, and profiling indicates that a performance hit is taken, > contrary to the performance improvement I had hoped for I don't see any performance drop when reading in a fairly large file: #!/usr/bin/perl -w use Benchmark; # Might be /usr/dict/words $FILE = "/usr/share/dict/words"; timethese(shift || -3, { "defined" => sub { open(FILE, $FILE) or die $!; while(defined($line = <FILE>)) { 1 } }, "no defined" => sub { open(FILE, $FILE) or die $!; while($line = <FILE>) { 1 } }, } ); $ perl -w src/bench/defined_vs_not -10 Benchmark: running defined, no defined, each for at least 10 CPU seconds... defined: 13 wallclock secs (12.86 usr + 0.32 sys = 13.18 CPU) @ 5.84/s (n=77) no defined: 13 wallclock secs (12.86 usr + 0.22 sys = 13.08 CPU) @ 5.89/s (n=77) (Similar results under 5.6 as under 5.005_03, similar results with a small file) -- Michael G Schwern http://www.pobox.com/~schwern/ schwern@pobox.com Sometimes these hairstyles are exaggerated beyond the laws of physics - Unknown narrator speaking about Anime ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe