Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use feature 'say'; use Time::HiRes 'time'; my $x = 'a' x 1e6; my $y = 'b' . $x; my $t = time; $x =~ s/./$&-/g; say time - $t; $t = time; $y =~ s/./$&-/g; say time - $t; say $^V; __END__ 12.7103209495544 0.850119113922119 v5.32.1 12.7171239852905 0.765337944030762 v5.28.2 0.345196962356567 0.314804077148438 v5.26.3
I didn't try latest (are they still beta?) versions, was this issue fixed? Online tests (Perl on Linux, of course) don't exhibit any anomaly. Looks like at some time after 5.26 version something weird happened to Strawberry Perl. Hard to imagine just _what_ can be happening for 10+ seconds with such relatively short string, 1 core fully loaded. And why for the 1st time only.
I understand s/.\K/-/g is better (no speed anomaly if written as such), it's not the question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Substitution unexpectedly very slow, in Strawberry
by choroba (Cardinal) on Aug 06, 2023 at 20:50 UTC | |
Re: Substitution unexpectedly very slow, in Strawberry -- issue submitted
by Discipulus (Canon) on Aug 10, 2023 at 08:43 UTC | |
Re: Substitution unexpectedly very slow, in Strawberry
by swl (Prior) on Aug 06, 2023 at 22:21 UTC | |
by syphilis (Archbishop) on Aug 07, 2023 at 02:13 UTC | |
by swl (Prior) on Aug 07, 2023 at 02:43 UTC | |
by syphilis (Archbishop) on Aug 07, 2023 at 05:16 UTC | |
by swl (Prior) on Aug 07, 2023 at 08:20 UTC | |
| |
Re: Substitution unexpectedly very slow, in Strawberry
by Discipulus (Canon) on Aug 07, 2023 at 07:26 UTC |