On Sun, Oct 02, 2016 at 11:59:12PM +0300, Niko Tyni wrote:
> It seems to have to do with the size of the input file rather
> than its contents, but I'm not quite sure yet.
It looks like none of the gory regexps are necessary to trigger it.
Here's a short test case, resulting here in
Rate concat assign sprintf
concat 2928/s -- -94% -94%
assign 47733/s 1530% -- -0%
sprintf 47733/s 1530% 0% --
so showing the 'concat' option has pathologic performance.
It goes away if the length of the base string $s is varied
even slightly, and seems to reappear in 8-byte increments
or decrements. Some of those, like 2**16 - 3, also blow
up the 'sprintf' performance.
The results don't vary much between jessie (Perl 5.20) and sid (5.24)
for me on amd64.
I'll test/bisect this on upstream code next and try to find out if it's
really copy-on-write related or something else.
--
Niko Tyni [email protected]
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark 'cmpthese';
my $s = "A"x (2**16 + 5);
my $cat = 'B' . $s . 'B';
my $spr = sprintf "B%sB", $s;
cmpthese(-1, {
"assign" => sub {my $i=0; $s =~ /./ while $i++ < 100 },
"concat" => sub {my $i=0; $cat =~ /./ while $i++ < 100 },
"sprintf" => sub {my $i=0; $spr =~ /./ while $i++ < 100 },
});