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