#!/usr/bin/perl -w use strict; my $foo = <<'BAR'; my $test = 1; #ifdef UNDEF $test = 0; #endif print "\$test => $test\n"; BAR my $bar = <<'BAZ'; use constant UNDEF => 0; my $test = 1; if (UNDEF) { $test = 0; } print "\$test => $test\n"; BAZ use Benchmark; =pod this is still wrong timethese (100000, { cpp => sub { eval "perl -P -e '$foo'";}, prl => sub { eval "perl -e '$bar'";} } ); =cut timethese (1000, { cpp => sub { system "perl -P -e '$foo'";}, prl => sub { system "perl -e '$bar'";} } ); #### =pod $ perl bmp.pl Benchmark: timing 1000 iterations of cpp, prl... cpp: 88 wallclock secs ( 0.08 usr 0.54 sys + 52.56 cusr 29.98 csys = 83.16 CPU) @ 1612.90/s (n=1000) prl: 49 wallclock secs ( 0.09 usr 0.56 sys + 33.78 cusr 12.19 csys = 46.62 CPU) @ 1538.46/s (n=1000) =cut #### timethese (10000, { cpp => sub { eval "$foo"; }, prl => sub { eval "$bar"; }}); =pod $ perl -P bmp.pl Benchmark: timing 10000 iterations of cpp, prl... cpp: 1 wallclock secs ( 0.50 usr + 0.02 sys = 0.52 CPU) @ 19230.77/s (n=10000) prl: 2 wallclock secs ( 2.40 usr + 0.03 sys = 2.43 CPU) @ 4115.23/s (n=10000) =cut