← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:01:06 2013

Filename/usr/share/perl5/DateTime/Format/Builder/Parser/generic.pm
StatementsExecuted 91 statements in 1.40ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1011264µs744µsDateTime::Format::Builder::Parser::generic::::generic_parserDateTime::Format::Builder::Parser::generic::generic_parser
101156µs56µsDateTime::Format::Builder::Parser::generic::::newDateTime::Format::Builder::Parser::generic::new
11119µs23µsDateTime::Format::Builder::Parser::generic::::BEGIN@2DateTime::Format::Builder::Parser::generic::BEGIN@2
11119µs90µsDateTime::Format::Builder::Parser::generic::::BEGIN@4DateTime::Format::Builder::Parser::generic::BEGIN@4
11112µs29µsDateTime::Format::Builder::Parser::generic::::BEGIN@171DateTime::Format::Builder::Parser::generic::BEGIN@171
11111µs63µsDateTime::Format::Builder::Parser::generic::::BEGIN@5DateTime::Format::Builder::Parser::generic::BEGIN@5
1119µs34µsDateTime::Format::Builder::Parser::generic::::BEGIN@3DateTime::Format::Builder::Parser::generic::BEGIN@3
0000s0sDateTime::Format::Builder::Parser::generic::::__ANON__[:125]DateTime::Format::Builder::Parser::generic::__ANON__[:125]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::Format::Builder::Parser::generic;
2334µs227µs
# spent 23µs (19+4) within DateTime::Format::Builder::Parser::generic::BEGIN@2 which was called: # once (19µs+4µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 2
use strict;
# spent 23µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@2 # spent 4µs making 1 call to strict::import
3339µs260µs
# spent 34µs (9+26) within DateTime::Format::Builder::Parser::generic::BEGIN@3 which was called: # once (9µs+26µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 3
use vars qw( $VERSION );
# spent 34µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@3 # spent 25µs making 1 call to vars::import
4350µs2161µs
# spent 90µs (19+71) within DateTime::Format::Builder::Parser::generic::BEGIN@4 which was called: # once (19µs+71µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 4
use Carp;
# spent 90µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@4 # spent 71µs making 1 call to Exporter::import
5152µs
# spent 63µs (11+52) within DateTime::Format::Builder::Parser::generic::BEGIN@5 which was called: # once (11µs+52µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 7
use Params::Validate qw(
# spent 52µs making 1 call to Exporter::import
6 validate SCALAR CODEREF UNDEF
73416µs163µs);
8
911µs$VERSION = '0.77';
10
11=head1 NAME
12
- -
26sub new
27
# spent 56µs within DateTime::Format::Builder::Parser::generic::new which was called 10 times, avg 6µs/call: # 10 times (56µs+0s) by DateTime::Format::Builder::Parser::Regex::create_parser at line 143 of DateTime/Format/Builder/Parser/Regex.pm, avg 6µs/call
{
282071µs my $class = shift;
29 bless { @_ }, $class;
30}
31
32=head3 generic_parser
33
- -
66
# spent 744µs (264+480) within DateTime::Format::Builder::Parser::generic::generic_parser which was called 10 times, avg 74µs/call: # 10 times (264µs+480µs) by DateTime::Format::Builder::Parser::Regex::create_parser at line 150 of DateTime/Format/Builder/Parser/Regex.pm, avg 74µs/call
sub generic_parser {
6750451µs my $class = shift;
68 my %args = validate( @_, {
691258µs10480µs ( map { $_ => { type => CODEREF, optional => 1 } } qw(
# spent 480µs making 10 calls to Params::Validate::_validate, avg 48µs/call
# spent 54µs executing statements in 10 string evals (merged)
70 on_match on_fail preprocess postprocess
71 ) ),
72 label => { type => SCALAR|UNDEF, optional => 1 },
73 });
74 my $label = $args{label};
75
76 my $callback = (exists $args{on_match} or exists $args{on_fail}) ? 1 : undef;
77
78 return sub
79 {
80 my ($self, $date, $p, @args) = @_;
81 return unless defined $date;
82 my %p;
83 %p = %$p if $p; # Look! A Copy!
84
85 my %param = (
86 self => $self,
87 ( defined $label ? ( label => $label ) : ()),
88 (@args ? (args => \@args) : ()),
89 );
90
91 # Preprocess - can modify $date and fill %p
92 if ($args{preprocess})
93 {
94 $date = $args{preprocess}->( input => $date, parsed => \%p, %param );
95 }
96
97 my $rv = $class->do_match( $date, @args ) if $class->can('do_match');
98
99 # Funky callback thing
100 if ($callback)
101 {
102 my $type = defined $rv ? "on_match" : "on_fail";
103 $args{$type}->( input => $date, %param ) if $args{$type};
104 }
105 return unless defined $rv;
106
107 my $dt;
108 $dt = $class->post_match( $date, $rv, \%p ) if $class->can('post_match');
109
110 # Allow post processing. Return undef if regarded as failure
111 if ($args{postprocess})
112 {
113 my $rv = $args{postprocess}->(
114 parsed => \%p,
115 input => $date,
116 post => $dt,
117 %param,
118 );
119 return unless $rv;
120 }
121
122 # A successful match!
123 $dt = $class->make( $date, $dt, \%p ) if $class->can('make');
124 return $dt;
125 };
126}
127
128=head2 Methods for subclassing
129
- -
170{
171461µs246µs
# spent 29µs (12+17) within DateTime::Format::Builder::Parser::generic::BEGIN@171 which was called: # once (12µs+17µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 171
no strict 'refs';
# spent 29µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@171 # spent 17µs making 1 call to strict::unimport
17211µs for (qw( valid_params params ))
173 {
174212µs *$_ = *{"DateTime::Format::Builder::Parser::$_"};
175 }
176}
177
17815µs1;
179
180__END__