in reply to Re: 5.8.1 Released!
in thread 5.8.1 Released!
map in void context is no longer a sin, but still it can't be used lightly instead of for, which is 25% faster than map.
It has been a great improvement from previous versions, though.
use Benchmark; print "Perl $]\n"; timethese (10000,{ "map"=> sub { map { $_ } ( 1 .. 1000 ) }, "for"=> sub { $_ for ( 1 .. 1000 ) } } ); __END__ Perl 5.006001 Benchmark: timing 10000 iterations of for, map... for: 3 wallclock secs ( 2.81 usr + 0.00 sys = 2.81 CPU) map: 5 wallclock secs ( 5.16 usr + 0.01 sys = 5.17 CPU) Perl 5.008 Benchmark: timing 10000 iterations of for, map... for: 3 wallclock secs ( 2.19 usr + 0.01 sys = 2.20 CPU) map: 4 wallclock secs ( 4.65 usr + 0.02 sys = 4.67 CPU) Perl 5.008001 Benchmark: timing 10000 iterations of for, map... for: 2 wallclock secs ( 1.72 usr + 0.00 sys = 1.72 CPU) map: 2 wallclock secs ( 2.27 usr + 0.02 sys = 2.29 CPU) Perl 5.008001 Benchmark: timing 50000 iterations of for, map... for: 9 wallclock secs ( 8.71 usr + 0.01 sys = 8.72 CPU) map: 12 wallclock secs (11.53 usr + 0.04 sys = 11.57 CPU)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 5.8.1 Released!
by Abigail-II (Bishop) on Sep 25, 2003 at 14:17 UTC |