$s = '0123456789'; printf "%x\n", unpack 'Q', pack 'P', $s while $s =~ /\G./g; # 55fd180fcc60 # 55fd18107f30 # 55fd18107ed0 # 55fd180e6700 # 55fd180fcc60 # 55fd18107f30 # 55fd18107ed0 # 55fd180e6700 # 55fd180fcc60 # 55fd18107f30
Looks like patterns don't matter, both between slashes (the above is for illusion of being useful, supposedly performed daily by thousands) and alternation of addresses, it just picks what's available.
use strict; use warnings; use feature 'say'; use Config; say "$^V / $Config{ archname }"; for my $len ( 1e4, 1e5, 1e6, 1e7 ) { my $s = 'a' x $len; my %h; my @before = times; $s =~ /\G./gs and ++ $h{ pack 'P', $s } for 1 .. $len / 100; # do just 1% !!! my @after = times; printf "Length: %8d, addresses: %6d, user: %6g, system: %6g\n", $len, scalar( keys %h ), $after[ 0 ] - $before[ 0 ], $after[ 1 ] - $before[ 1 ] } __END__ v5.40.3 / x86_64-linux-thread-multi Length: 10000, addresses: 1, user: 0, system: 0 Length: 100000, addresses: 1, user: 0, system: 0 Length: 1000000, addresses: 1, user: 0.01, system: 0 Length: 10000000, addresses: 1, user: 0.02, system: 0 v5.42.0 / x86_64-linux-thread-multi Length: 10000, addresses: 2, user: 0, system: 0 Length: 100000, addresses: 3, user: 0.01, system: 0 Length: 1000000, addresses: 3, user: 0.39, system: 0 Length: 10000000, addresses: 3, user: 139.87, system: 0 v5.43.8 / x86_64-linux Length: 10000, addresses: 2, user: 0, system: 0 Length: 100000, addresses: 3, user: 0.01, system: 0 Length: 1000000, addresses: 3, user: 0.38, system: 0 Length: 10000000, addresses: 3, user: 138.75, system: 0.01 v5.42.0 / MSWin32-x64-multi-thread Length: 10000, addresses: 2, user: 0, system: 0 Length: 100000, addresses: 2, user: 0, system: 0 Length: 1000000, addresses: 2, user: 0.844, system: 1.063 Length: 10000000, addresses: 70, user: 154.453, system: 253.812
It's much worse on Windows, with absurdly grotesque "system" time (I understand it's approximation for that OS); I can only assume buffers, when long enough (?), are continuously requested to be de-allocated and allocated, from OS, again and again, which is not the case with Perl on Linux.
If there's a bug it's a shock it goes unnoticed, I'm just a no-one. In fact I'm grateful that yesterday it wasn't possible to post, I now see the above is separate from another similar issue from 5.20 and on; better not to mix them together
In reply to 5.42: Does m// toss a string around? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |