#! perl -slw use strict; use Benchmark qw[ cmpthese ]; open O, '>', 'with.pl'; print O '# a comment', ' ' x 60, for 1 .. 100; print O 'sub with{ $_[ 0 ]++; }'; print O 'our $with++'; close O; open O, '>', 'without.pl'; print O ' ' x 80, for 1 .. 100; print O 'sub without{ $_[ 0 ]++; }'; print O 'our $without++'; close O; our( $with, $without ); { local $^W; ( $with, $without ) = ( 0 ) x 2; cmpthese -1, { compile_with => q[ do 'with.pl'; ], compile_without => q[ do 'without.pl'; ] }; print "With:$with without:$without\n"; } { ( $with, $without ) = ( 0 ) x 2; cmpthese -1, { A_call_with => q[ with( $with ); ], B_call_without => q[ without( $without ); ] }; print "With:$with without:$without\n"; } { ( $with, $without ) = ( 0 ) x 2; cmpthese -1, { B_call_with => q[ with( $with ); ], A_call_without => q[ without( $without ); ] }; print "With:$with without:$without\n"; } __END__ C:\test>junk Rate compile_without compile_with compile_without 3046/s -- -13% compile_with 3507/s 15% -- With:4863 without:4447 Rate B_call_without A_call_with B_call_without 1541400/s -- -4% A_call_with 1602739/s 4% -- With:2476423 without:2258362 Rate A_call_without B_call_with A_call_without 1552179/s -- -5% B_call_with 1632288/s 5% -- With:2386728 without:2124584 C:\test>junk Rate compile_without compile_with compile_without 3001/s -- -11% compile_with 3368/s 12% -- With:4863 without:4447 Rate B_call_without A_call_with B_call_without 1405856/s -- -14% A_call_with 1630859/s 16% -- With:2386728 without:1996218 Rate A_call_without B_call_with A_call_without 1480385/s -- -11% B_call_with 1655503/s 12% -- With:2386728 without:2142348 C:\test>junk Rate compile_without compile_with compile_without 3023/s -- -10% compile_with 3365/s 11% -- With:4863 without:4469 Rate B_call_without A_call_with B_call_without 1671100/s -- -0% A_call_with 1676092/s 0% -- With:2277479 without:2250533 Rate A_call_without B_call_with A_call_without 1575095/s -- -4% B_call_with 1636763/s 4% -- With:2288717 without:2124584