Moose::Autoboxの速度
#!perl use Moose::Autobox; use Benchmark qw/timethese cmpthese/; cmpthese( timethese( 0, { autobox => sub { my $array = [ 1, 2, 3 ]; $array->push(4); }, normal => sub { my $array = [ 1, 2, 3 ]; push @{$array}, 4; }, } ) );
Rate autobox normal autobox 342974/s -- -55% normal 756560/s 121% --
もっと差があると思っていたけれど、さほど差がないんだなぁ。それでも2倍は遅いということかぁ。Runtimeの速度で2倍違うというとさすがに使うのは厳しいかもしれないなぁ。autoboxの機能はPerl6待ちなのかな。
# 追記.
#!perl use Moose::Autobox; use Benchmark qw/timethese cmpthese/; my $array1 = [ 1, 2, 3 ]; my $array2 = [ 1, 2, 3 ]; cmpthese( timethese( 0, { autobox => sub { $array1->push(4); }, normal => sub { push @{$array2}, 4; }, } ) );
Rate autobox normal autobox 555226/s -- -88% normal 4764859/s 758% --
あぁ...