← 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 17:10:45 2013
Reported on Tue Oct 15 17:11:55 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
1011236µs670µsDateTime::Format::Builder::Parser::generic::::generic_parserDateTime::Format::Builder::Parser::generic::generic_parser
101154µs54µsDateTime::Format::Builder::Parser::generic::::newDateTime::Format::Builder::Parser::generic::new
11120µs120µsDateTime::Format::Builder::Parser::generic::::BEGIN@5DateTime::Format::Builder::Parser::generic::BEGIN@5
11119µs23µsDateTime::Format::Builder::Parser::generic::::BEGIN@2DateTime::Format::Builder::Parser::generic::BEGIN@2
11119µs101µsDateTime::Format::Builder::Parser::generic::::BEGIN@4DateTime::Format::Builder::Parser::generic::BEGIN@4
11118µs64µsDateTime::Format::Builder::Parser::generic::::BEGIN@3DateTime::Format::Builder::Parser::generic::BEGIN@3
11114µs32µsDateTime::Format::Builder::Parser::generic::::BEGIN@171DateTime::Format::Builder::Parser::generic::BEGIN@171
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;
2332µs228µ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
3341µs2111µs
# spent 64µs (18+47) within DateTime::Format::Builder::Parser::generic::BEGIN@3 which was called: # once (18µs+47µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 3
use vars qw( $VERSION );
# spent 64µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@3 # spent 47µs making 1 call to vars::import
4366µs2183µs
# spent 101µs (19+82) within DateTime::Format::Builder::Parser::generic::BEGIN@4 which was called: # once (19µs+82µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 4
use Carp;
# spent 101µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@4 # spent 82µs making 1 call to Exporter::import
51100µs
# spent 120µs (20+100) within DateTime::Format::Builder::Parser::generic::BEGIN@5 which was called: # once (20µs+100µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 7
use Params::Validate qw(
# spent 100µs making 1 call to Exporter::import
6 validate SCALAR CODEREF UNDEF
73452µs1120µs);
8
912µs$VERSION = '0.77';
10
11=head1 NAME
12
- -
26sub new
27
# spent 54µs within DateTime::Format::Builder::Parser::generic::new which was called 10 times, avg 5µs/call: # 10 times (54µs+0s) by DateTime::Format::Builder::Parser::Regex::create_parser at line 143 of DateTime/Format/Builder/Parser/Regex.pm, avg 5µs/call
{
282068µs my $class = shift;
29 bless { @_ }, $class;
30}
31
32=head3 generic_parser
33
- -
66
# spent 670µs (236+434) within DateTime::Format::Builder::Parser::generic::generic_parser which was called 10 times, avg 67µs/call: # 10 times (236µs+434µs) by DateTime::Format::Builder::Parser::Regex::create_parser at line 150 of DateTime/Format/Builder/Parser/Regex.pm, avg 67µs/call
sub generic_parser {
6750413µs my $class = shift;
68 my %args = validate( @_, {
691231µs10434µs ( map { $_ => { type => CODEREF, optional => 1 } } qw(
# spent 434µs making 10 calls to Params::Validate::_validate, avg 43µs/call
# spent 42µ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{
171474µs252µs
# spent 32µs (14+19) within DateTime::Format::Builder::Parser::generic::BEGIN@171 which was called: # once (14µs+19µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@73 at line 171
no strict 'refs';
# spent 32µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@171 # spent 19µs making 1 call to strict::unimport
17212µs for (qw( valid_params params ))
173 {
174216µs *$_ = *{"DateTime::Format::Builder::Parser::$_"};
175 }
176}
177
17816µs1;
179
180__END__