public
Created

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# SORTED FROM SLOWEST TO FASTEST
 
# Data::Validation
$ perl -MBench -e'package P; use Validation::Class; field f1=> {required=>1}; field f2=>{required=>1}; field f3=>{}; package main; my $p=P->new(f1=>1, f2=>2); bench sub { $p->validate(qw/f1 f2 f3/) }, -2'
8449 calls (4030/s), 2.097s (0.248ms/call)
 
# Data::Domain 1.01 (also not exactly equivalent, can't assign default value)
$ perl -MBench -MData::Domain=:all -E'$d=Struct(a => Whatever(-defined=>1), b=>Whatever(-defined=>1), c=>Whatever); bench sub { {} ~~ $d }, -2'
14061 calls (6642/s), 2.117s (0.151ms/call)
 
# Data::Verifier 0.54 (how to supply default value?)
$ perl -MBench -MData::Verifier -MData::Verifier -E'$dv=Data::Verifier->new(profile=>{a=>{required=>1, type=>"Item"}, b=>{type=>"Item"}, c=>{type=>"Item"}}); bench sub { $dv->verify({a=>1, b=>1.1}) }, -2'
14085 calls (5639/s), 2.498s (0.177ms/call)
 
# Data::FormValidator
$ perl -MBench -MData::FormValidator -e'bench sub { Data::FormValidator->check({a=>1, b=>1.1}, {required=>[qw/a b/], defaults=>{c=>1}}) }, -2'
26905 calls (13140/s), 2.048s (0.0761ms/call)
 
# Config::Validator (made valid, because by default validate() dies)
$ perl -MBench -MConfig::Validator -E'$v=Config::Validator->new({type=>"struct", fields=>{a=>{type=>"integer"}, b=>{type=>"integer"}, c=>{type=>"integer", optional=>"true"}}}); bench sub { $v->validate({a=>1, b=>1}) }, -2'
85105 calls (32062/s), 2.654s (0.0312ms/call)
 
# FormValidator::Lite (not exactly equivalent, can't assign default value)
$ perl -MBench -MFormValidator::Lite -MCGI -e'$q=CGI->new; $q->param(-name=>"a", -value=>1); $q->param(-name=>"b", -value=>1); $v=FormValidator::Lite->new($q); bench sub { $v->check(a=>[qw/NOT_NULL/], b=>[qw/NOT_NULL/], c=>[]) }, -2'
93021 calls (43351/s), 2.146s (0.0231ms/call)
 
# Data::Sah
$ perl -MBench -MData::Sah=gen_validator -e'$v=gen_validator(["hash*"=>keys=>{a=>"any*", b=>"any*", c=>["any*", default=>1]}], {return_type=>"full"}); bench sub { $v->({a=>1, b=>1.1}) }, -2'
375001 calls (187288/s), 2.002s (0.0053ms/call)
 
# Params::Validate
$ perl -MParams::Validate=:all -MBench -e'%spec = (a=>1, b=>1, c=>{default=>1}); @ary = (a=>1, b=>1.1); bench sub { validate(@ary, \%spec) }, -2'
608693 calls (303162/s), 2.008s (0.0033ms/call)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.