in reply to Re: Optimize debugging subs
in thread Optimize debugging subs
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Optimize debugging subs
by ikegami (Patriarch) on Apr 05, 2006 at 05:07 UTC | |
by danb (Friar) on Apr 05, 2006 at 06:10 UTC | |
by ikegami (Patriarch) on Apr 05, 2006 at 14:22 UTC |