in reply to Re^2: Macro in perl code?
in thread Macro in perl code?
The whole subroutine call gets optimized away:$ cat 645310.pl use strict; use warnings; use Benchmark qw/ cmpthese /; our $verbosity = 7; our $volume = 1; use constant VERBOSE => 0; cmpthese( -1, { 'Name7' => ' if ( $volume >= $verbosity ) { v_print3( "foo" ) }; ' +, 'Name8' => ' if ( VERBOSE ) { v_print3( "foo" ) }; ' +, } ); sub v_print3 { my $message = shift; print $message; } __END__ $ perl 645310.pl Rate Name7 Name8 Name7 9442579/s -- -74% Name8 35826879/s 279% --
$ perl -MO=Deparse,-x,-p -e 'use constant VERBOSE => 0; if ( VERBOSE ) + { v_print3( "foo" ) }; ' use constant ('VERBOSE', 0); '???'; -e syntax OK
|
|---|