smile4me has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/env perl use constant DEBUG => $ENV{DEBUG_LEVEL}; sub debug { my $level = shift; return if ($level > DEBUG); print STDERR "($level/" . DEBUG . ") @_\n"; } sub helpful { my $int = shift; debug(1, "called with: ", $int); ## do stuff here ... my $val = $int * $int; debug(3, "output: ", $val); print "$int becomes: $val \n"; } for ( 1..5 ) { helpful( $_ ); }
After a while, the debug() statements become sprinkled all over the place. For me, it is helpful. But I am wondering if there is a cost to all these calls.
I tried testing this theory with:
DEBUG_LEVEL=3 perl -MO=Concise ./debug_onoff.pl
DEBUG_LEVEL=2 perl -MO=Concise ./debug_onoff.pl
DEBUG_LEVEL=0 perl -MO=Concise ./debug_onoff.pl
but the output is the same. See for related topic.
So the questions is:
Thanks for your insight.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: perl compiler optimizer curiosity
by Athanasius (Archbishop) on Mar 12, 2022 at 04:23 UTC | |
Re: perl compiler optimizer curiosity (Troubleshooting and Logging/Debugging References)
by eyepopslikeamosquito (Archbishop) on Mar 12, 2022 at 06:33 UTC | |
by Fletch (Bishop) on Mar 12, 2022 at 07:00 UTC | |
by 1nickt (Canon) on Mar 12, 2022 at 17:43 UTC | |
Re: perl compiler optimizer curiosity
by LanX (Saint) on Mar 12, 2022 at 18:29 UTC | |
by cavac (Prior) on Mar 15, 2022 at 11:11 UTC | |
by LanX (Saint) on Mar 15, 2022 at 11:50 UTC | |
by afoken (Chancellor) on Mar 15, 2022 at 11:58 UTC | |
by LanX (Saint) on Mar 15, 2022 at 12:16 UTC | |
Re: perl compiler optimizer curiosity
by cavac (Prior) on Mar 15, 2022 at 11:12 UTC |