Help for this page

Select Code to Download


  1. or download this
    use Benchmark;
    
    ...
        'split'   => sub { my($file) = (split /\//, $img)[-1] },
        'substr'  => sub { my $file  = substr $img, rindex($img, '/') + 1 
    +}
    });
    
  2. or download this
    Benchmark: timing 1000000 iterations of regexp1, regexp2, regexp3, rep
    +lace, split, substr...
       regexp1: 26 wallclock secs (20.06 usr +  0.06 sys = 20.12 CPU)
    ...
       replace: 17 wallclock secs (13.05 usr +  0.03 sys = 13.08 CPU)
         split: 30 wallclock secs (24.56 usr +  0.09 sys = 24.65 CPU)
        substr: 11 wallclock secs ( 8.46 usr +  0.02 sys =  8.48 CPU)