ParamCheck.pm

filter: Statementstmt 100% 25 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 5 / 5 totaltotal 100% 39 / 39 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« ParamCheck/Implementation/DataValidator/TypeTiny.pm ↑ Summary ParamCheck/Base/PVC.pm »
1 4 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Benchmark::Featureset::ParamCheck;
6  
7 4 our $AUTHORITY = 'cpan:TOBYINK';
8 4 our $VERSION = '0.006';
9  
10 4 ▶use IO::String ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub implementations {
13 4 ▶ qw(
Subroutine implementations: called CC=1 SCAR=0.0
Pod documented
14 Benchmark::Featureset::ParamCheck::Implementation::DataValidator::Moose
15 Benchmark::Featureset::ParamCheck::Implementation::DataValidator::Mouse
16 Benchmark::Featureset::ParamCheck::Implementation::DataValidator::TypeTiny
17 Benchmark::Featureset::ParamCheck::Implementation::MXPV::Moose
18 Benchmark::Featureset::ParamCheck::Implementation::MXPV::TypeTiny
19 Benchmark::Featureset::ParamCheck::Implementation::ParamsCheck::Perl
20 Benchmark::Featureset::ParamCheck::Implementation::ParamsCheck::TypeTiny
21 Benchmark::Featureset::ParamCheck::Implementation::Perl
22 Benchmark::Featureset::ParamCheck::Implementation::PV
23 Benchmark::Featureset::ParamCheck::Implementation::PV::TypeTiny
24 Benchmark::Featureset::ParamCheck::Implementation::PVC::Moose
25 Benchmark::Featureset::ParamCheck::Implementation::PVC::Specio
26 Benchmark::Featureset::ParamCheck::Implementation::PVC::TypeTiny
27 Benchmark::Featureset::ParamCheck::Implementation::RefUtilXS
28 Benchmark::Featureset::ParamCheck::Implementation::TypeParams::Moose
29 Benchmark::Featureset::ParamCheck::Implementation::TypeParams::Mouse
30 Benchmark::Featureset::ParamCheck::Implementation::TypeParams::Specio
31 Benchmark::Featureset::ParamCheck::Implementation::TypeParams::TypeNano
32 Benchmark::Featureset::ParamCheck::Implementation::TypeParams::TypeTiny
33 );
34 }
35  
36 4 my $io = 'IO::String'->new;
37  
38 4 my %trivial = ( integer => 0, hashes => [], object => $io );
39 my %complex = (
40 integer => 1_234_567_890,
41 4 hashes => [ map { +{} } 1..10 ],
42 object => $io,
43 );
44  
45 2 ▶sub trivial_named_data { \%trivial }
Subroutine trivial_named_data: called CC=1 SCAR=0.0
Pod documented
46 2 ▶sub complex_named_data { \%complex }
Subroutine complex_named_data: called CC=1 SCAR=0.0
Pod documented
47  
48 4 my @trivial = map $trivial{$_}, qw(integer hashes object);
49 4 my @complex = map $complex{$_}, qw(integer hashes object);
50  
51 2 ▶sub trivial_positional_data { \@trivial }
Subroutine trivial_positional_data: called CC=1 SCAR=0.0
Pod documented
52 2 ▶sub complex_positional_data { \@complex }
Subroutine complex_positional_data: called CC=1 SCAR=0.0
Pod documented
53  
54 4 1;
55  
56 __END__
57  
58 =pod
59  
60 =encoding utf-8
61  
62 =head1 NAME
63  
64 Benchmark::Featureset::ParamCheck - compare different parameter validation modules
65  
66 =head1 SYNOPSIS
67  
68 use Benchmark::Featureset::ParamCheck;
69 use Module::Runtime qw(use_module);
70
71 my @impl = Benchmark::Featureset::ParamCheck->implementations;
72 my $testdata = Benchmark::Featureset::ParamCheck->trivial_named_data;
73
74 for my $i (@impl) {
75 # Check the data 10,000 times.
76 use_module($i)->run_named_check(10_000, $testdata);
77 }
78  
79 =head1 DESCRIPTION
80  
81 A whole bunch of implementations for sub paramater checking.
82  
83 Each implementation provides a method to check a hash of the form shown
84 in the example. It should have three keys, 'integer' (value should be
85 an integer), 'hashes' (value should be an arrayref of hashrefs), and
86 'object' (value should be an object with C<print> and C<close> methods).
87  
88 This is intended for benchmarking.
89  
90 =head2 Class Methods
91  
92 =over
93  
94 =item * C<implementations>
95  
96 List of implementations. Each implementation is a subclass of
97 Benchmark::Featureset::ParamCheck::Base
98  
99 =item * C<trivial_named_data>, C<trivial_positional_data>
100  
101 Returns trivial test data.
102  
103 =item * C<complex_named_data>, C<complex_positional_data>
104  
105 Returns complex test data.
106  
107 =back
108  
109 =head2 Benchmark::Featureset::ParamCheck::Base
110  
111 This class provides the following class methods:
112  
113 =over
114  
115 =item * C<< accept_array >>
116  
117 =item * C<< accept_arrayref >>
118  
119 =item * C<< accept_hash >>
120  
121 =item * C<< accept_hashref >>
122  
123 =item * C<< run_named_check($times, %parameters) >>, C<< run_named_check($times, \%parameters) >>
124  
125 =item * C<< run_postional_check($times, @parameters) >>
126  
127 =back
128  
129 =head1 BUGS
130  
131 Please report any bugs to
132 L<http://rt.cpan.org/Dist/Display.html?Queue=Benchmark-Featureset-ParamCheck>.
133  
134 =head1 SEE ALSO
135  
136 B<< Parameter validation libraries: >>
137 L<Data::Validator>,
138 L<MooseX::Params::Validate>,
139 L<Params::Check>,
140 L<Params::Validate>,
141 L<Params::ValidationCompiler>,
142 L<Ref::Util::XS>,
143 L<Type::Params>.
144  
145 B<< Type constraint libraries: >>
146 L<Moose>,
147 L<Mouse>,
148 L<Specio>,
149 L<Type::Tiny>.
150  
151 =head1 AUTHOR
152  
153 Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
154  
155 =head1 COPYRIGHT AND LICENCE
156  
157 This software is copyright (c) 2017, 2018 by Toby Inkster.
158  
159 This is free software; you can redistribute it and/or modify it under
160 the same terms as the Perl 5 programming language system itself.
161  
162 =head1 DISCLAIMER OF WARRANTIES
163  
164 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
165 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
166 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
167  
« ParamCheck/Implementation/DataValidator/TypeTiny.pm ↑ Summary ParamCheck/Base/PVC.pm »