Acme-Sub-Parms
view release on metacpan or search on metacpan
examples/bench-parm-parsers-ci-novalid.pl view on Meta::CPAN
#!/usr/bin/perl
package My;
use strict;
use Acme::Sub::Parms qw(:no_validation :normalize);
use Class::ParmList qw (simple_parms parse_parms);
use Params::Validate qw (validate);
use Benchmark qw(cmpthese);
$Params::Validate::NO_VALIDATION = 1;
print "Bench case insensitive parameter parsing without validation\n";
cmpthese(500000, {
'bindparms' => sub { sub_parms_bind_parms( handle => 'Test', 'thing' => 'something')},
# 'std_args' => sub { standard_args( handle => 'Test', 'thing' => 'something')},
'caseflat_std_args' => sub { caseflat_standard_args( handle => 'Test', 'thing' => 'something')},
# 'one_step_args' => sub { one_step_args( handle => 'Test', 'thing' => 'something')},
'positional_args' => sub { positional_args( 'Test', 'something')},
'null_sub' => sub { null_sub( handle => 'Test', 'thing' => 'something')},
'simple_parms' => sub { simple_parms_args( handle => 'Test', 'thing' => 'something')},
'parse_parms' => sub { parse_parms_no_valid( handle => 'Test', 'thing' => 'something')},
'params_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_bind_parms {
BindParms : (
my $handle : handle;
my $thing : thing;
)
}
sub simple_parms_args {
examples/bench-parm-parsers-ci.pl view on Meta::CPAN
#!/usr/bin/perl
package My;
use strict;
use Acme::Sub::Parms qw(:normalize);
use Class::ParmList qw (simple_parms);
use Params::Validate qw (validate validation_options validate_with);
validation_options(ignore_case => 1);
use Benchmark qw(cmpthese);
print "Bench case insensitive parameter parsing with validation (as applicable)\n";
cmpthese(500000, {
'bindparms' => sub { sub_parms_bind_parms( handle => 'Test', 'thing' => 'something')},
# 'std_args' => sub { standard_args( handle => 'Test', 'thing' => 'something')},
'caseflat_std_args' => sub { caseflat_standard_args( handle => 'Test', 'thing' => 'something')},
# 'one_step_args' => sub { one_step_args( handle => 'Test', 'thing' => 'something')},
'posistional_args' => sub { positional_args( 'Test', 'something')},
'null_sub' => sub { null_sub( handle => 'Test', 'thing' => 'something')},
'simple_parms' => sub { simple_parms_args( handle => 'Test', 'thing' => 'something')},
'params_validate' => sub { params_validate( handle => 'Test', 'thing' => 'something')},
'params_validate_with' => sub { params_validate_with( handle => 'Test', 'thing' => 'something')},
}
);
exit;
############################################################################
sub params_validate {
my ($handle, $thing) = @{(validate(@_, { handle => 1, thing => 1 }))}{'handle','thing'};
}
sub params_validate_with {
my ($handle, $thing) = @{(validate_with(params => \@_,
spec => { handle => 1, thing => 1 },
normalize_keys => sub { lc $_[0] },
))}{'handle','thing'};
}
sub sub_parms_bind_parms {
BindParms : (
my $handle : handle;
my $thing : thing;
)
examples/bench-parm-parsers-cs-novalid.pl view on Meta::CPAN
#!/usr/bin/perl
package My;
use strict;
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;
print "Bench case sensitive parameter parsing without validation (as applicable)\n";
cmpthese(1000000, {
'bindparms' => sub { sub_parms_bindparms( handle => 'Test', 'thing' => 'something')},
'std_args' => sub { std_args( handle => 'Test', 'thing' => 'something')},
# 'caseflat_args' => sub { caseflat_std_args( handle => 'Test', 'thing' => 'something')},
'one_step_args' => sub { one_step_args( handle => 'Test', 'thing' => 'something')},
'positional_args' => sub { positional_args( 'Test', 'something')},
'simple_parms (*)' => sub { simple_parms_args( handle => 'Test', 'thing' => 'something')},
'validate' => sub { params_validate( handle => 'Test', 'thing' => 'something')},
'null_sub' => sub { null_sub( handle => 'Test', 'thing' => 'something')},
# 'null_method' => sub { null_method( handle => 'Test', 'thing' => 'something')},
}
);
print "\n(*) case insensitive and validating\n";
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 {
examples/bench-parm-parsers-cs.pl view on Meta::CPAN
#!/usr/bin/perl
package My;
use strict;
use Acme::Sub::Parms;
use Class::ParmList qw (simple_parms);
use Params::Validate qw (validate);
use Benchmark qw(cmpthese);
print "Bench case sensitive parameter parsing with validation (as applicable)\n";
cmpthese(1000000, {
'bindparms' => sub { sub_parms_bindparms( handle => 'Test', 'thing' => 'something')},
'std_args (*)' => sub { std_args( handle => 'Test', 'thing' => 'something')},
# 'caseflat_args' => sub { caseflat_std_args( handle => 'Test', 'thing' => 'something')},
'one_step_args (*)' => sub { one_step_args( handle => 'Test', 'thing' => 'something')},
'positional_args (*)' => sub { positional_args( 'Test', 'something')},
'simple_parms' => sub { simple_parms_args( handle => 'Test', 'thing' => 'something')},
'validate' => sub { params_validate( handle => 'Test', 'thing' => 'something')},
'null_sub' => sub { null_sub( handle => 'Test', 'thing' => 'something')},
}
);
print "'starred' entries are not performing validation\n";
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 {
lib/Acme/Sub/Parms.pod view on Meta::CPAN
=head1 'use' options
There are three compile-time 'use' options available.
use Acme::Sub::Parms qw(:no_validation :normalize :dump_to_stdout);
=over 4
=item :no_validation
This flags that bound parameters should B<NOT> be validated according
to any validation specifications.
If this flag is used, then parameters will be bound, callbacks and
defaults applied, but validation checking will be disabled. This
provides a significant performance boost to parameter processing
in mature code that doesn't need runtime parameter assertion checking.
=item :normalize
This flags that bound parameters should ignore the difference between
( run in 0.318 second using v1.01-cache-2.11-cpan-4d50c553e7e )