http://qs321.pair.com?node_id=50537


in reply to Re: Re: Re: Re: Slurp a file
in thread Slurp a file

Yes they were :) But I'm not sure I like the results. Is there a problem with this benchmarking code?

#!/usr/bin/perl -w use strict; use Benchmark; my $file = $0; open IN, $file or die "$file: $!\n"; sub joinit { my $content = join '', <IN>; } sub dollarslash { my $content = do { local $/; <IN> } } timethese(100_000, {join => \&joinit, slash => \&dollarslash} );

because it implies that the join is faster...

Benchmark: timing 100000 iterations of join, slash... join: 2 wallclock secs ( 1.52 usr + 0.29 sys = 1.81 CPU) slash: 4 wallclock secs ( 2.99 usr + 0.35 sys = 3.34 CPU)
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me