Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    use strict;
    use Benchmark 'cmpthese';
    ...
            $res = $short_string =~ /\Q$substr\E/;
        }
    });
    
  2. or download this
    Benchmark: timing 10000000 iterations of index, regex, shortindex, sho
    +rtregex, substrindex, substrregex...
         index: 18 wallclock secs (17.29 usr +  0.00 sys = 17.29 CPU) @ 57
    +8369.00/s (n=10000000)
    ...
    substrregex  600962/s    95%        63%    4%          --        -9%  
    +      -44%
    shortindex   660066/s   115%        79%   14%         10%         --  
    +      -38%
    substrindex 1064963/s   246%       189%   84%         77%        61%  
    +        --