According to perlreguts, the RE engine also uses fbm_index() to scan for the leftmost atom. There shouldn't be any reason why the performance of the two should differ by a large margin, and I would expect the regular expression to be a bit slower in the general case due to the setup. So I think it's either that your data somehow favours a branch in the RE engine that goes to fbm_index faster, or that the benchmark is not measuring what you want. But I also vaguely remember some thread about such a discrepancy on this site, but I can't find it is index faster than regexp for fixed text token?.

git blame tells me nobody touched index since 2009, and that change was some refcounting change. The other changes were in 2006.


In reply to Re^3: How Index function works?? by Corion
in thread How Index function works?? by saranrsm

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.