Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Remove slow debug prints with "ifdef" type of pre processor pragma.

Reply
Thread Tools

Remove slow debug prints with "ifdef" type of pre processor pragma.

 
 
kebabklubben.emp@gmail.com
Guest
Posts: n/a
 
      11-12-2007
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

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      11-12-2007

Quoth http://www.velocityreviews.com/forums/(E-Mail Removed):
>
> 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

 
Reply With Quote
 
 
 
 
Alan Stewart
Guest
Posts: n/a
 
      11-12-2007
On Mon, 12 Nov 2007 06:00:01 -0800, (E-Mail Removed) 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
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      11-13-2007
(E-Mail Removed) <(E-Mail Removed)> 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/"
 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      11-14-2007
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."
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Home Produced Prints Equal Lab Prints? Denis Boisclair Digital Photography 8 11-13-2004 03:20 PM
Durability of inkjet prints, photo prints Bill Tuthill Digital Photography 45 05-02-2004 03:04 AM
Just recieved my 15 free digital prints from Kellards- Amazing Quality Prints! Bruce Digital Photography 5 12-29-2003 02:49 AM
Why the prints from film feel more 3D then prints from digital. Victor81 Digital Photography 35 12-12-2003 07:49 AM
Epson 1280 prints NOT Waterproof, 2200 prints ARE, Right? Dr. Slick Digital Photography 12 11-29-2003 10:19 AM



Advertisments