On 15 October 2014 04:06, H.Merijn Brand <h.m.brand@xs4all.nl> wrote: > cmpthese (-3, { > arg3 => sub { my $foo = "foo"; substr ($foo, 1, 0) = "x"; }, > arg4 => sub { my $foo = "foo"; substr $foo, 1, 0, "x"; }, > }); > What will really bake your noodle, put them both in void context instead of in the return at the end of a sub. use Benchmark qw( :hireswallclock cmpthese ); cmpthese( -3, { arg3 => sub { my $foo = "foo"; substr( $foo, 1, 0 ) = "x";}, arg4 => sub { my $foo = "foo"; substr $foo, 1, 0, "x";}, arg3_void => sub { my $foo = "foo"; substr( $foo, 1, 0 ) = "x"; 1 }, arg4_void => sub { my $foo = "foo"; substr $foo, 1, 0, "x"; 1 }, } ); Rate arg3 arg4_void arg4 arg3_void arg3 2278016/s -- -61% -65% -66% arg4_void 5845748/s 157% -- -11% -13% arg4 6556081/s 188% 12% -- -2% arg3_void 6712231/s 195% 15% 2% -- that lone '1' on the end makes a difference of 200% :D -- Kent *KENTNL* - https://metacpan.org/author/KENTNLThread Previous | Thread Next