Output:sub ENABLE_DEBUG () { 0 } sub debug_inelegant { print $_[0]; } sub debug_elegant { print $_[0] if ENABLE_DEBUG; } use Benchmark qw(:all) ; cmpthese( 30000000, { 'inelegant' => "debug_inelegant 'test' if ENABLE_DEBUG;", 'elegant' => "debug_elegant 'test';" }, );
Rate elegant inelegant elegant 3337041/s -- -95% inelegant 62500000/s 1773% --
--Dan
In reply to Re^2: Optimize debugging subs
by danb
in thread Optimize debugging subs
by danb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |