seems just plain broken, and I wouldn't have been surprised if it even made Benchmark roll over and die. You shouldn't be making any assumptions about what is in @_ in your outer sub {}, much less modifiying it.cmpthese( -2,{ list => sub { &list }, shiftit => sub { &shiftit }, } );
Trying this:
shows that in fact, cmpthese's parameters are still in @_, and doing:use Benchmark 'cmpthese'; cmpthese(1, { tryit => sub { $save = \@_ }}); use Data::Dumper; $Data::Dumper::Deparse = 1; print Dumper $save; __END__ $VAR1 = [ 1, sub { $save = \@_; } ];
shows that your shift has blown them away after the first 2 iterations.cmpthese 3, { tryit => sub { push @save, [@_]; shift } }; print Dumper \@save; $VAR1 = [ [ 3, sub { push @save, [@_]; shift @_; } ], [ $VAR1->[0][1] ], [] ];
In reply to Re: Lies, Damn Lies and Benchmarks
by ysth
in thread Lies, Damn Lies and Benchmarks
by liz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |