perlの文字列結合におけるpreallocもしくは事前のSvGROWの効果

多少あるのかも。

use strict;
use warnings;

use Benchmark qw(:all);

my $t = "hello world! hello world! hello world! hello world!\n";
my $rep = 100;
my $prealloc_s = $t x $rep;

cmpthese(100000, {
    default => sub {
        my $s = '';
        $s .= $t
            for 1..$rep;
        $s;
    },
    prealloc => sub {
        $prealloc_s = '';
        $prealloc_s .= $t
            for 1..$rep;
        $prealloc_s;
    },
});
$ perl prealloc.pl 
            Rate  default prealloc
default  17825/s       --      -5%
prealloc 18692/s       5%       --