← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:49 2015

Filename/usr/share/perl5/DateTime/Format/Builder/Parser/generic.pm
StatementsExecuted 87 statements in 788µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1011113µs178µsDateTime::Format::Builder::Parser::generic::::generic_parserDateTime::Format::Builder::Parser::generic::generic_parser
101122µs22µsDateTime::Format::Builder::Parser::generic::::newDateTime::Format::Builder::Parser::generic::new
11112µs22µsDateTime::Format::Builder::Parser::generic::::BEGIN@5DateTime::Format::Builder::Parser::generic::BEGIN@5
1117µs12µsDateTime::Format::Builder::Parser::generic::::BEGIN@6DateTime::Format::Builder::Parser::generic::BEGIN@6
1117µs35µsDateTime::Format::Builder::Parser::generic::::BEGIN@7DateTime::Format::Builder::Parser::generic::BEGIN@7
1117µs16µsDateTime::Format::Builder::Parser::generic::::BEGIN@89DateTime::Format::Builder::Parser::generic::BEGIN@89
1116µs34µsDateTime::Format::Builder::Parser::generic::::BEGIN@8DateTime::Format::Builder::Parser::generic::BEGIN@8
0000s0sDateTime::Format::Builder::Parser::generic::::__ANON__[:84]DateTime::Format::Builder::Parser::generic::__ANON__[:84]
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;
2{
32800ns $DateTime::Format::Builder::Parser::generic::VERSION = '0.81';
4}
5227µs232µs
# spent 22µs (12+10) within DateTime::Format::Builder::Parser::generic::BEGIN@5 which was called: # once (12µs+10µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@12 at line 5
use strict;
# spent 22µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@5 # spent 10µs making 1 call to strict::import
6218µs216µs
# spent 12µs (7+4) within DateTime::Format::Builder::Parser::generic::BEGIN@6 which was called: # once (7µs+4µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@12 at line 6
use warnings;
# spent 12µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@6 # spent 4µs making 1 call to warnings::import
7230µs262µs
# spent 35µs (7+27) within DateTime::Format::Builder::Parser::generic::BEGIN@7 which was called: # once (7µs+27µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@12 at line 7
use Carp;
# spent 35µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@7 # spent 27µs making 1 call to Exporter::import
813µs128µs
# spent 34µs (6+28) within DateTime::Format::Builder::Parser::generic::BEGIN@8 which was called: # once (6µs+28µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@12 at line 10
use Params::Validate qw(
# spent 28µs making 1 call to Exporter::import
9 validate SCALAR CODEREF UNDEF
101429µs134µs);
11
- -
14
# spent 22µs within DateTime::Format::Builder::Parser::generic::new which was called 10 times, avg 2µs/call: # 10 times (22µs+0s) by DateTime::Format::Builder::Parser::Regex::create_parser at line 81 of DateTime/Format/Builder/Parser/Regex.pm, avg 2µs/call
sub new {
15102µs my $class = shift;
161033µs bless {@_}, $class;
17}
18
19
20
# spent 178µs (113+65) within DateTime::Format::Builder::Parser::generic::generic_parser which was called 10 times, avg 18µs/call: # 10 times (113µs+65µs) by DateTime::Format::Builder::Parser::Regex::create_parser at line 88 of DateTime/Format/Builder/Parser/Regex.pm, avg 18µs/call
sub generic_parser {
21102µs my $class = shift;
22 my %args = validate(
23 @_,
24 {
25 (
2610140µs1065µs map { $_ => { type => CODEREF, optional => 1 } }
# spent 65µs making 10 calls to Params::Validate::XS::validate, avg 7µs/call
27 qw(
28 on_match on_fail preprocess postprocess
29 )
30 ),
31 label => { type => SCALAR | UNDEF, optional => 1 },
32 }
33 );
34102µs my $label = $args{label};
35
36104µs my $callback
37 = ( exists $args{on_match} or exists $args{on_fail} ) ? 1 : undef;
38
39 return sub {
40 my ( $self, $date, $p, @args ) = @_;
41 return unless defined $date;
42 my %p;
43 %p = %$p if $p; # Look! A Copy!
44
45 my %param = (
46 self => $self,
47 ( defined $label ? ( label => $label ) : () ),
48 ( @args ? ( args => \@args ) : () ),
49 );
50
51 # Preprocess - can modify $date and fill %p
52 if ( $args{preprocess} ) {
53 $date = $args{preprocess}
54 ->( input => $date, parsed => \%p, %param );
55 }
56
57 my $rv = $class->do_match( $date, @args ) if $class->can('do_match');
58
59 # Funky callback thing
60 if ($callback) {
61 my $type = defined $rv ? "on_match" : "on_fail";
62 $args{$type}->( input => $date, %param ) if $args{$type};
63 }
64 return unless defined $rv;
65
66 my $dt;
67 $dt = $class->post_match( $date, $rv, \%p )
68 if $class->can('post_match');
69
70 # Allow post processing. Return undef if regarded as failure
71 if ( $args{postprocess} ) {
72 my $rv = $args{postprocess}->(
73 parsed => \%p,
74 input => $date,
75 post => $dt,
76 %param,
77 );
78 return unless $rv;
79 }
80
81 # A successful match!
82 $dt = $class->make( $date, $dt, \%p ) if $class->can('make');
83 return $dt;
841042µs };
85}
86
87
88{
89346µs225µs
# spent 16µs (7+9) within DateTime::Format::Builder::Parser::generic::BEGIN@89 which was called: # once (7µs+9µs) by DateTime::Format::Builder::Parser::Regex::BEGIN@12 at line 89
no strict 'refs';
# spent 16µs making 1 call to DateTime::Format::Builder::Parser::generic::BEGIN@89 # spent 9µs making 1 call to strict::unimport
901400ns for (qw( valid_params params )) {
9126µs *$_ = *{"DateTime::Format::Builder::Parser::$_"};
92 }
93}
94
9513µs1;
96
97# ABSTRACT: Useful routines
98
99__END__