in reply to Concatenate or Join?
Reducing the join and concatenation to a simple example without any file i/o, I don't get the same result when Benchmarking.
use strict; use warnings; use Benchmark qw{ cmpthese }; my @arr = ( q{abc} ) x 10000; cmpthese( -5, { concat => sub { my $ret; $ret .= $_ for @arr; return $ret; }, join => sub { my $ret = join q{}, @arr; return $ret; }, } );
$ ./spw1003500 Rate concat join concat 994/s -- -70% join 3310/s 233% -- $
Perhaps something else is skewing your timing.
Cheers,
JohnGG
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Concatenate or Join?
by tobyink (Canon) on Nov 12, 2012 at 20:54 UTC |
In Section
Seekers of Perl Wisdom