Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Turning foreach into map?

by ikegami (Patriarch)
on Apr 04, 2005 at 22:07 UTC ( [id://444817]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Turning foreach into map?
in thread Turning foreach into map?

No difference. I reran it, and it was never more than 3% in favour of either option.

Rate t_map_b t_map_e t_map_b 28799/s -- -0% t_map_e 28844/s 0% -- This is perl, v5.6.1 built for MSWin32-x86-multi-thread
use strict; use warnings; use Benchmark (); sub t_map_b { my $url = shift; return map { "$url/$_\n" } @_; } sub t_map_e { my $url = shift; return map "$url/$_\n", @_; } my $url = 'http://www.domain.com/'; my @list = qw( file0 file1 file2 file3 file4 file5 file6 file7 file8 file9 ); sub test { my ($sub) = @_; $a = join('', $sub->($url, @list)); } Benchmark::cmpthese(-3, { t_map_b => sub { test(\&t_map_b); }, t_map_e => sub { test(\&t_map_e); }, }); $a=$a;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://444817]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-28 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found