07/01/09 12:09:24
>>243
散々既出だが、一応突っ込んどく。カンマの方が遲い
use Benchmark ;
my ( $hoge, $moge ) = ( 'hoge', 'moge' ) ;
sub dot { print STDERR $hoge . $moge . "\n" ; }
sub dq { print STDERR "$hoge$moge\n" ; }
sub comma{ print STDERR $hoge , $moge , "\n" ; }
timethese ( 1000000, { op1 => 'dot', op2 => 'dq', op3 => 'comma' } ) ;
$ perl Bench.pl 2> /dev/null
Benchmark: timing 1000000 iterations of op1, op2, op3...
op1: 15 wallclock secs ( 7.67 usr + 4.81 sys = 12.48 CPU) @ 80128.21/s (n=1000000)
op2: 12 wallclock secs ( 7.37 usr + 4.67 sys = 12.04 CPU) @ 83056.48/s (n=1000000)
op3: 22 wallclock secs ( 9.13 usr + 11.23 sys = 20.36 CPU) @ 49115.91/s (n=1000000)