Thank you - this is excellent. You have confirmed my suspicion that my tests were not good. Now I need to find a test that tricks the optimizer. Given that the ex-stringify sK/1 ->a op was removed, I guess using constant strings is not the way to test.

I always understood that 'abc' was better than "abc", because of the interpolation, but it seems that the optimizer sees through this, given the constant strings, so all I am doing is being kinder to the optimizer. Premature optimization.

The following now uses a string read from <>, and therefore not a constant:

% perl -MO=Concise my $s=<>; my $t="$s"; b <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -:1) v ->3 - <1> null vKS/2 ->6 3 <0> padsv[$s:1,3] sRM*/LVINTRO ->4 5 <1> readline[t3] sKS/1 ->6 4 <#> gv[*ARGV] s ->5 6 <;> nextstate(main 2 -:2) v ->7 a <2> sassign vKS/2 ->b 8 <@> stringify[t5] sK/1 ->9 - <0> ex-pushmark s ->7 7 <0> padsv[$s:1,3] s ->8 9 <0> padsv[$t:2,3] sRM*/LVINTRO ->a
I'll recreate tests based on this. Thank you all.


In reply to Re: Re: String Concatenation Performance by pbeckingham
in thread String Concatenation Performance by pbeckingham

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.