use strictures; use Benchmark "cmpthese"; use List::Util "min"; # This is XS. cmpthese -1, { list_util_nb => q[ my( $x, $y ) = ( 0, 1 ); my $m = min( $x, $y ) for 1 .. 1000; ], ternary_nb => q[ my( $x, $y ) = ( 0, 1 ); my $m = $x < $y ? $x : $y for 1 .. 1000; ], clever_nb => q[ my( $x, $y ) = ( 0, 1 ); my $m = [ $x, $y ]->[ $x <= $y ] for 1 .. 1000; ], list_util_b => q[ my( $x, $y ) = ( 1, 0 ); my $m = min( $x, $y ) for 1 .. 1000; ], ternary_b => q[ my( $x, $y ) = ( 1, 0 ); my $m = $x < $y ? $x : $y for 1 .. 1000; ], clever_b => q[ my( $x, $y ) = ( 1, 0 ); my $m = [ $x, $y ]->[ $x <= $y ] for 1 .. 1000; ], }; __END__ C:\test>junk30 Rate clever_b clever_nb list_util_nb list_util_b ternary_b ternary_nb clever_b 1210/s -- -11% -67% -70% -79% -80% clever_nb 1356/s 12% -- -63% -67% -76% -78% list_util_nb 3694/s 205% 172% -- -9% -34% -40% list_util_b 4062/s 236% 200% 10% -- -28% -33% ternary_b 5630/s 365% 315% 52% 39% -- -8% ternary_nb 6107/s 405% 351% 65% 50% 8% -- C:\test>junk30 Rate clever_nb clever_b list_util_b list_util_nb ternary_b ternary_nb clever_nb 1297/s -- -5% -68% -69% -75% -77% clever_b 1372/s 6% -- -66% -67% -74% -75% list_util_b 4078/s 214% 197% -- -3% -22% -27% list_util_nb 4190/s 223% 205% 3% -- -20% -25% ternary_b 5228/s 303% 281% 28% 25% -- -6% ternary_nb 5556/s 328% 305% 36% 33% 6% --