Search::InvertedIndex::Update->new({
-group => $group,
-index => $index,
-data => $index_data,
-keys => {
$key0 => 10,
$key1 => 20,
$key2 => 15,
},
});
####
Search::InvertedIndex::Update->new($group, $index, $index_data, {
$key0 => 10,
$key1 => 20,
$key2 => 15,
}
);
####
use Params::Validate qw (validate);
$Params::Validate::NO_VALIDATION = 1;
sub params_validate {
my ($handle, $thing) = @{(validate(@_, { handle => 1, thing => 1 }))}{'handle','thing'};
}
####
use Class::ParmList qw (simple_parms);
sub simple_parms_args {
my ($handle, $thing) = simple_parms(['handle','thing'], @_);
}
####
use Acme::Sub::Parms qw(:no_validation);
sub sub_parms_bindparms {
BindParms : (
my $handle : handle;
my $thing : thing;
)
}
####
sub one_step_args {
my ($handle, $thing) = @{{@_}}{'handle','thing'};
}
####
sub std_args {
my %args = @_;
my ($handle, $thing) = @args{'handle','thing'};
}
####
sub caseflat_std_args {
my %args;
{
my %raw_args = @_;
%args = map { lc($_) => $raw_args{$_} } keys %raw_args;
}
my ($handle, $thing) = @args{'handle','thing'};
}
####
sub positional_args {
my ($handle, $thing) = @_;
}
####
#!/usr/bin/perl
use strict;
use warnings;
use Acme::Sub::Parms qw(:no_validation);
use Class::ParmList qw (simple_parms);
use Params::Validate qw (validate);
use Benchmark qw(cmpthese);
$Params::Validate::NO_VALIDATION = 1;
cmpthese(1000000, {
'bindparms' => sub { sub_parms_bindparms( handle => 'Test', 'thing' => 'something')},
'std_args' => sub { std_args( handle => 'Test', 'thing' => 'something')},
'caseflat' => sub { caseflat_std_args( handle => 'Test', 'thing' => 'something')},
'one_step' => sub { one_step_args( handle => 'Test', 'thing' => 'something')},
'postnl_args' => sub { positional_args( 'Test', 'something')},
'simple_parms' => sub { simple_parms_args( handle => 'Test', 'thing' => 'something')},
'validate' => sub { params_validate( handle => 'Test', 'thing' => 'something')},
}
);
exit;
############################################################################
sub params_validate {
my ($handle, $thing) = @{(validate(@_, { handle => 1, thing => 1 }))}{'handle','thing'};
}
sub sub_parms_bindparms {
BindParms : (
my $handle : handle;
my $thing : thing;
)
}
sub simple_parms_args {
my ($handle, $thing) = simple_parms(['handle','thing'], @_);
}
sub positional_args {
my ($handle, $thing) = @_;
}
sub one_step_args {
my ($handle, $thing) = @{{@_}}{'handle','thing'};
}
sub caseflat_std_args {
my %args;
{
my %raw_args = @_;
%args = map { lc($_) => $raw_args{$_} } keys %raw_args;
}
my ($handle, $thing) = @args{'handle','thing'};
}
sub std_args {
my %args = @_;
my ($handle, $thing) = @args{'handle','thing'};
}
####
Rate validate simple_parms caseflat bindparms one_step std_args postnl_args
validate 24851/s -- -40% -74% -90% -90% -92% -97%
simple_parms 41203/s 66% -- -57% -83% -84% -86% -96%
caseflat 95969/s 286% 133% -- -62% -62% -68% -90%
bindparms 249377/s 903% 505% 160% -- -1% -16% -73%
one_step 251889/s 914% 511% 162% 1% -- -15% -73%
std_args 296736/s 1094% 620% 209% 19% 18% -- -68%
postnl_args 925926/s 3626% 2147% 865% 271% 268% 212% --
####
#!/usr/bin/perl
use strict;
use warnings;
my @parms = ('handle','thing');
@_ = ('handle','thing');
use Benchmark qw(cmpthese);
cmpthese(2000000, {
'one_sub' => \&one_sub,
'anon_sub' => sub { my ($handle, $thing) = @_; },
'double_sub' => sub { one_sub(); },
'parm2_sub' => sub { double_sub('handle','thing'); },
'std_args' => sub { std_args('handle','thing'); },
'std_args_d' => sub { std_args('handle','thing'); },
}
);
exit;
############################################################################
sub one_sub {
my ($handle, $thing) = @_;
}
sub d_sub { "1"; }
sub double_sub {
d_sub(@_);
my ($handle, $thing) = @_;
}
sub std_args_d {
my %args = @_;
d_sub(@_);
my ($handle, $thing) = @args{'handle','thing'};
}
sub std_args {
my %args = @_;
my ($handle, $thing) = @args{'handle','thing'};
}
####
Rate std_args_d std_args parm2_sub double_sub anon_sub one_sub
std_args_d 392157/s -- -0% -34% -65% -84% -85%
std_args 393701/s 0% -- -33% -64% -84% -85%
parm2_sub 589971/s 50% 50% -- -47% -76% -78%
double_sub 1104972/s 182% 181% 87% -- -55% -59%
anon_sub 2469136/s 530% 527% 319% 123% -- -9%
one_sub 2702703/s 589% 586% 358% 145% 9% --