Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions devel/bench-all.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sub time_them {
$results{$k} = $iter_s;
}

printf( "%20s %10s%s\n", $_, int( $results{$_} ) . "/s", $_ =~ /^h:o/ ? " *" : "" )
printf( "%20s %10s%s\n", $_, int( $results{$_} ) . "/s", $_ =~ /^h:o/ ? " *" : $_ =~ /^t:h:i/ ? " ~" : "" )
for sort { $results{$b} <=> $results{$a} } keys %results;

say "";
Expand Down Expand Up @@ -81,7 +81,11 @@ sub time_them {
tie my %h, 'Tie::LLHash', @{ $PAIRS{$size} };
};

$mark{"t:h:i"} = sub {
$mark{"t:h:i_oo"} = sub {
my $h = Tie::Hash::Indexed->new( @{ $PAIRS{$size} } );
};

$mark{"t:h:i_th"} = sub {
tie my %h, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };
};

Expand Down Expand Up @@ -123,10 +127,11 @@ sub time_them {
my $aah = Array::AsHash->new( { array => [ @{ $PAIRS{$size} } ] } );
my $dxh = Data::XHash::xh( @{ $PAIRS{$size} } );
my $aoh = Array::OrdHash->new( @{ $PAIRS{$size} } );
my $thi_oo = Tie::Hash::Indexed->new( @{ $PAIRS{$size} } );
tie my %ho_th, 'Hash::Ordered', @{ $PAIRS{$size} };
tie my %tix_th, 'Tie::IxHash', @{ $PAIRS{$size} };
tie my %tllh, 'Tie::LLHash', @{ $PAIRS{$size} };
tie my %thi, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };
tie my %thi_th, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };

my ( %mark, $v );
my @keys = keys %{ { @{ $PAIRS{$size} } } };
Expand All @@ -139,7 +144,8 @@ sub time_them {
$mark{"t:ix_oo"} = sub { $v = $tix_oo->FETCH($_) for @lookup };
$mark{"t:ix_th"} = sub { $v = $tix_th{$_} for @lookup };
$mark{"t:llh"} = sub { $v = $tllh{$_} for @lookup };
$mark{"t:h:i"} = sub { $v = $thi{$_} for @lookup };
$mark{"t:h:i_oo"} = sub { $v = $thi_oo->get($_) for @lookup };
$mark{"t:h:i_th"} = sub { $v = $thi_th{$_} for @lookup };
$mark{"a:ah"} = sub { $v = $aah->get($_) for @lookup };
$mark{"d:xh_oo"} = sub { $v = $dxh->fetch($_) for @lookup };
$mark{"d:xh_rf"} = sub { $v = $dxh->{$_} for @lookup };
Expand All @@ -163,10 +169,11 @@ sub time_them {
my $aah = Array::AsHash->new( { array => [ @{ $PAIRS{$size} } ] } );
my $dxh = Data::XHash::xh( @{ $PAIRS{$size} } );
my $aoh = Array::OrdHash->new( @{ $PAIRS{$size} } );
my $thi_oo = Tie::Hash::Indexed->new( @{ $PAIRS{$size} } );
tie my %ho_th, 'Hash::Ordered', @{ $PAIRS{$size} };
tie my %tix_th, 'Tie::IxHash', @{ $PAIRS{$size} };
tie my %tllh, 'Tie::LLHash', @{ $PAIRS{$size} };
tie my %thi, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };
tie my %thi_th, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };

my ( %mark, $v );
my @keys = keys %{ { @{ $PAIRS{$size} } } };
Expand All @@ -180,7 +187,8 @@ sub time_them {
$mark{"t:ix_oo"} = sub { $tix_oo->STORE( $_, $new_value ) for @lookup };
$mark{"t:ix_th"} = sub { $tix_th{$_} = $new_value for @lookup };
$mark{"t:llh"} = sub { $tllh{$_} = $new_value for @lookup };
$mark{"t:h:i"} = sub { $thi{$_} = $new_value for @lookup };
$mark{"t:h:i_oo"} = sub { $thi_oo->set( $_, $new_value ) for @lookup };
$mark{"t:h:i_th"} = sub { $thi_th{$_} = $new_value for @lookup };
$mark{"a:ah"} = sub { $aah->put( $_, $new_value ) for @lookup };
$mark{"d:xh_oo"} = sub { $dxh->store( $_, $new_value ) for @lookup };
$mark{"d:xh_rf"} = sub { $dxh->{$_} = $new_value for @lookup };
Expand Down Expand Up @@ -231,9 +239,14 @@ sub time_them {
tied(%tllh)->last( irand(), 42 ) for 1 .. $n;
};

$mark{"t:h:i"} = sub {
tie my %thi, 'Tie::Hash::Indexed';
$thi{ irand() } = 42 for 1 .. $n;
$mark{"t:h:i_oo"} = sub {
my $thi_oo = Tie::Hash::Indexed->new;
$thi_oo->set( irand(), 42 ) for 1 .. $n;
};

$mark{"t:h:i_th"} = sub {
tie my %thi_th, 'Tie::Hash::Indexed';
$thi_th{ irand() } = 42 for 1 .. $n;
};

$mark{"a:ah"} = sub {
Expand Down Expand Up @@ -304,9 +317,14 @@ sub time_them {
delete $tllh{$_} for @lookup;
};

$mark{"t:h:i"} = sub {
tie my %thi, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };
delete $thi{$_} for @lookup;
$mark{"t:h:i_oo"} = sub {
my $thi_oo = Tie::Hash::Indexed->new( @{ $PAIRS{$size} } );
$thi_oo->delete($_) for @lookup;
};

$mark{"t:h:i_th"} = sub {
tie my %thi_th, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };
delete $thi_th{$_} for @lookup;
};

$mark{"a:ah"} = sub {
Expand Down Expand Up @@ -347,10 +365,11 @@ sub time_them {
my $aah = Array::AsHash->new( { array => [ @{ $PAIRS{$size} } ] } );
my $dxh = Data::XHash::xh( @{ $PAIRS{$size} } );
my $aoh = Array::OrdHash->new( @{ $PAIRS{$size} } );
my $thi_oo = Tie::Hash::Indexed->new( @{ $PAIRS{$size} } );
tie my %ho_th, 'Hash::Ordered', @{ $PAIRS{$size} };
tie my %tix_th, 'Tie::IxHash', @{ $PAIRS{$size} };
tie my %tllh, 'Tie::LLHash', @{ $PAIRS{$size} };
tie my %thi, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };
tie my %thi_th, 'Tie::Hash::Indexed', @{ $PAIRS{$size} };

my ( %mark, @list );

Expand All @@ -361,7 +380,8 @@ sub time_them {
};
$mark{"t:ix_th"} = sub { @list = %tix_th };
$mark{"t:llh"} = sub { @list = %tllh };
$mark{"t:h:i"} = sub { @list = %thi };
$mark{"t:h:i_oo"} = sub { @list = $thi_oo->as_list };
$mark{"t:h:i_th"} = sub { @list = %thi_th };
$mark{"a:ah"} = sub { @list = $aah->get_array };
$mark{"d:xh"} = sub { @list = $dxh->as_array };
$mark{"a:oh"} = sub { @list = %$aoh };
Expand Down