The inefficiency is true and very important if you are using Unicode strings, because lowercasing Unicode characters is slow. Consider this modified benchmark:

use utf8; use Benchmark 'cmpthese'; my $y = "HELLO ΑΙΝΣΪ" x 100; # make sure your script is encoded in UTF-8 when you save it! # ... the rest of the code is the same as in the parent node

Results:

                 Rate i_complex cc_complex complex complex_fail i_simple simple_fail simple cc_simple
i_complex       672/s        --       -68%    -70%         -71%     -98%       -100%  -100%     -100%
cc_complex     2078/s      209%         --     -9%         -10%     -94%        -99%  -100%     -100%
complex        2278/s      239%        10%      --          -2%     -94%        -99%  -100%     -100%
complex_fail   2317/s      245%        12%      2%           --     -94%        -99%  -100%     -100%
i_simple      35860/s     5234%      1626%   1474%        1448%       --        -79%   -95%      -95%
simple_fail  168298/s    24935%      8001%   7289%        7164%     369%          --   -76%      -78%
simple       703114/s   104489%     33744%  30771%       30248%    1861%        318%     --      -10%
cc_simple    780570/s   116011%     37472%  34172%       33591%    2077%        364%    11%        --

Character classes are 3 times faster than /i for the complex case and 21 times faster for the simple case!


In reply to Re: Re: Did the inefficiency of /i get fixed? by itub
in thread Did the inefficiency of /i get fixed? by Cody Pendant

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.