develooper Front page | perl.perl5.porters | Postings from November 2009

Re: Speeding up mktables; NYTprof

Thread Previous | Thread Next
From:
Eric Brine
Date:
November 26, 2009 10:18
Subject:
Re: Speeding up mktables; NYTprof
Message ID:
f86994700911261018x14c34fc2pf66a848ad37429a3@mail.gmail.com
On Thu, Nov 26, 2009 at 10:46 AM, karl williamson
<public@khwilliamson.com>wrote:

> I looked and actually it is that:
> sub DEBUG () { 0 }  # Set to 0 for production; 1 for development
>
> so it isn't getting optimized out, nonetheless.
>

$ perl -Ilib -MO=Concise,-exec -e'sub DEBUG () { 1 }  foo() if DEBUG'
1  <0> enter
2  <;> nextstate(main 2 -e:1) v:{
3  <0> pushmark s
4  <#> gv[*foo] s/EARLYCV
5  <1> entersub[t2] vKS/TARG,1
6  <@> leave[1 ref] vKP/REFC
-e syntax OK

$ perl -Ilib -MO=Concise,-exec -e'sub DEBUG () { 0 }  foo() if DEBUG'
1  <0> enter
2  <;> nextstate(main 2 -e:1) v:{
3  <@> leave[1 ref] vKP/REFC
-e syntax OK

In both cases, the "if" is opimised away. And in the case where DEBUG
returns 0, so is the function call.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About