File Coverage

blib/lib/Benchmark/Featureset/ParamCheck.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 5 5 100.0
total 30 30 100.0


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