There was a possibly related thread here a few months ago about character repetitions and COW but I can't locate it right now.

It would be interesting to compare with a perl that was built without the COW.
How might that be achieved on Windows ? (In fact, how is it even done on Linux ? IIRC it's fairly easily do-able on *nix but I can't find the relevant documentation.)

On Windows, I'm seeing the same thing, irrespective of whether perl-5.38.0 is built with a mingw-w64 port of gcc or with Microsoft's Visual Studio 2022. Unthreaded builds of perl fare just as poorly as the multi-thread builds.
The one thing that does make a big difference is to use a 32-bit build of perl.
For example, with a 64-bit MSVC-built perl-5.38.0:
>perl time.pl 6.13913488388062 0.530965089797974 v5.38.0
For a 32-bit perl-5.38.0 built using the same MSVC compiler (VS2022) in 32-bit mode:
>perl time.pl 0.0664510726928711 0.0533270835876465 v5.38.0
But even with that 32-bit build of perl, the same issue becomes evident when "1e6" is changed to "2e6":
>perl time.pl 6.67774796485901 1.07769107818604 v5.38.0
Cheers,
Rob

In reply to Re^2: Substitution unexpectedly very slow, in Strawberry by syphilis
in thread Substitution unexpectedly very slow, in Strawberry by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.