Help for this page

Select Code to Download


  1. or download this
    use Benchmark;
    
    ...
                    'Regexp D&P'  => sub { $string =~ s/.(?!.{0,3}$)/x/g; 
    +},
                    'Substring'   => sub { $string = length substr($string
    +,0,-4). substr($string,-4) }
                  });
    
  2. or download this
    Benchmark: running Regexp, Regexp D&P, Substring, each for at least 5 
    +CPU seconds...
        Regexp:  6 wallclock secs ( 5.38 usr +  0.00 sys =  5.38 CPU) @ 17
    +3245.35/s (n=932060)
    Regexp D&P:  6 wallclock secs ( 5.30 usr +  0.00 sys =  5.30 CPU) @ 20
    +0480.57/s (n=1062547)
     Substring:  7 wallclock secs ( 5.45 usr +  0.00 sys =  5.45 CPU) @ 10
    +04355.05/s (n=5473735)