# bm_theorbtwo_assign.pl # benchmark saw ampersand -- theorbtwo use strict; use warnings; use Benchmark qw(timethis); use Data::Dumper; my $count=$ARGV[0] || -1; my $unc =$ARGV[1] || '\\\\server_name\\sys_share'; print "Matching $unc for $count\n"; print Dumper(timethis($count,sub { $unc =~ m/^\\\\([^\\]+)\\/; my $server = $1; }, 'theorbtwo' )); __END__ # run_bm.pl use Benchmark 'cmpthese'; use Data::Dumper; sub run_bm($){ my $str=shift; my $h; $str=~s/\A(.*)\$VAR1 =/$h=$1;''/se; print $h; my $v=eval($str); die $@ if $@; $v } my $opts='-5 \\\\\\\\foo\\\\bar\\\\baz.exe'; my $hash={ blackadder => run_bm(`perl bm_blackadder.pl $opts`), theorbtwo => run_bm(`perl bm_theorbtwo.pl $opts`), theorbtwo_assign => run_bm(`perl bm_theorbtwo_assign.pl $opts`), }; cmpthese($hash); __END__ Matching \\foo\bar\baz.exe for -5 blackadder: 4 wallclock secs ( 5.05 usr + 0.00 sys = 5.05 CPU) @ 71109.11/s ( n=359101) Matching \\foo\bar\baz.exe for -5 theorbtwo: 5 wallclock secs ( 5.23 usr + 0.00 sys = 5.23 CPU) @ 171489.10/s (n=896888) Matching \\foo\bar\baz.exe for -5 theorbtwo: 5 wallclock secs ( 5.31 usr + 0.00 sys = 5.31 CPU) @ 90857.63/s ( n=482454) Rate blackadder theorbtwo_assign theorbtwo blackadder 71109/s -- -22% -59% theorbtwo_assign 90858/s 28% -- -47% theorbtwo 171489/s 141% 89% --