Remove slow debug prints with "ifdef" type of pre processor pragma.
Remove slow debug prints with "ifdef" type of pre processor pragma.
am 12.11.2007 15:00:01 von kebabklubben.emp
Hi!
Is there a way to remove slow debug prints with some kind of "ifdef"
type of pre processor pragma?
They are to slow when I ran big batch jobs, but neat to have durinf
development. Is there a way in Perl do define that debug prints are
skipped without any loop overhead?
Best Regards,
Andreas Lundgren - Sweden
Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
am 12.11.2007 15:42:59 von Ben Morrow
Quoth kebabklubben.emp@gmail.com:
>
> Is there a way to remove slow debug prints with some kind of "ifdef"
> type of pre processor pragma?
>
> They are to slow when I ran big batch jobs, but neat to have durinf
> development. Is there a way in Perl do define that debug prints are
> skipped without any loop overhead?
perldoc constant
Ben
Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
am 12.11.2007 16:23:48 von bugbear
kebabklubben.emp@gmail.com wrote:
> Hi!
>
> Is there a way to remove slow debug prints with some kind of "ifdef"
> type of pre processor pragma?
>
> They are to slow when I ran big batch jobs, but neat to have durinf
> development. Is there a way in Perl do define that debug prints are
> skipped without any loop overhead?
This or something like it?
http://log4perl.sourceforge.net/
BugBear
Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
am 12.11.2007 23:59:19 von Alan Stewart
On Mon, 12 Nov 2007 06:00:01 -0800, kebabklubben.emp@gmail.com wrote:
>Hi!
>
>Is there a way to remove slow debug prints with some kind of "ifdef"
>type of pre processor pragma?
>
>They are to slow when I ran big batch jobs, but neat to have durinf
>development. Is there a way in Perl do define that debug prints are
>skipped without any loop overhead?
>
>Best Regards,
>Andreas Lundgren - Sweden
use Smart::Comments;
"Smart comments provide an easy way to insert debugging and tracking
code into a program. They can report the value of a variable, track
the progress of a loop, and verify that particular assertions are
true.
Best of all, when you're finished debugging, you don't have to remove
them. Simply commenting out the use Smart::Comments line turns them
back into regular comments."
Alan
Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
am 13.11.2007 02:00:12 von Tad McClellan
kebabklubben.emp@gmail.com wrote:
> Is there a way to remove slow debug prints with some kind of "ifdef"
> type of pre processor pragma?
No, but you can use constants, and let them be optimized away
by the compiler.
use constant DEBUG => 0;
if ( DEBUG ) {
# code here is optimized away
}
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
am 14.11.2007 01:23:48 von rvtol+news
Tad McClellan schreef:
> kebabklubben.emp:
>> Is there a way to remove slow debug prints with some kind of "ifdef"
>> type of pre processor pragma?
>
> No, but you can use constants, and let them be optimized away
> by the compiler.
>
> use constant DEBUG => 0;
>
> if ( DEBUG ) {
> # code here is optimized away
> }
.... and the surrounding if(){} structure as well.
perl -MO=Deparse -e'
use constant THE_END => 0;
if (THE_END and my $s = "Goodbye World") {
print "$s\n"
}
'
use constant ('THE_END', 0);
'???';
--
Affijn, Ruud
"Gewoon is een tijger."