← 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/Regex.pm
StatementsExecuted 75 statements in 1.21ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.20ms1.32msDateTime::Format::Builder::Parser::Regex::::BEGIN@12DateTime::Format::Builder::Parser::Regex::BEGIN@12
101185µs286µsDateTime::Format::Builder::Parser::Regex::::create_parserDateTime::Format::Builder::Parser::Regex::create_parser
202120µs20µsDateTime::Format::Builder::Parser::Regex::::__ANON__[:24]DateTime::Format::Builder::Parser::Regex::__ANON__[:24]
11111µs22µsDateTime::Format::Builder::Parser::Regex::::BEGIN@7DateTime::Format::Builder::Parser::Regex::BEGIN@7
1117µs39µsDateTime::Format::Builder::Parser::Regex::::BEGIN@10DateTime::Format::Builder::Parser::Regex::BEGIN@10
1117µs12µsDateTime::Format::Builder::Parser::Regex::::BEGIN@8DateTime::Format::Builder::Parser::Regex::BEGIN@8
1116µs24µsDateTime::Format::Builder::Parser::Regex::::BEGIN@9DateTime::Format::Builder::Parser::Regex::BEGIN@9
0000s0sDateTime::Format::Builder::Parser::Regex::::__ANON__[:39]DateTime::Format::Builder::Parser::Regex::__ANON__[:39]
0000s0sDateTime::Format::Builder::Parser::Regex::::do_matchDateTime::Format::Builder::Parser::Regex::do_match
0000s0sDateTime::Format::Builder::Parser::Regex::::makeDateTime::Format::Builder::Parser::Regex::make
0000s0sDateTime::Format::Builder::Parser::Regex::::post_matchDateTime::Format::Builder::Parser::Regex::post_match
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::Regex;
2{
32800ns $DateTime::Format::Builder::Parser::Regex::VERSION = '0.81';
4}
5
6
7222µs232µs
# spent 22µs (11+10) within DateTime::Format::Builder::Parser::Regex::BEGIN@7 which was called: # once (11µs+10µs) by DateTime::Format::Builder::Parser::BEGIN@1.2 at line 7
use strict;
# spent 22µs making 1 call to DateTime::Format::Builder::Parser::Regex::BEGIN@7 # spent 10µs making 1 call to strict::import
8221µs218µs
# spent 12µs (7+6) within DateTime::Format::Builder::Parser::Regex::BEGIN@8 which was called: # once (7µs+6µs) by DateTime::Format::Builder::Parser::BEGIN@1.2 at line 8
use warnings;
# spent 12µs making 1 call to DateTime::Format::Builder::Parser::Regex::BEGIN@8 # spent 6µs making 1 call to warnings::import
9224µs241µs
# spent 24µs (6+17) within DateTime::Format::Builder::Parser::Regex::BEGIN@9 which was called: # once (6µs+17µs) by DateTime::Format::Builder::Parser::BEGIN@1.2 at line 9
use vars qw( @ISA );
# spent 24µs making 1 call to DateTime::Format::Builder::Parser::Regex::BEGIN@9 # spent 17µs making 1 call to vars::import
10222µs271µs
# spent 39µs (7+32) within DateTime::Format::Builder::Parser::Regex::BEGIN@10 which was called: # once (7µs+32µs) by DateTime::Format::Builder::Parser::BEGIN@1.2 at line 10
use Params::Validate qw( validate ARRAYREF SCALARREF HASHREF CODEREF );
# spent 39µs making 1 call to DateTime::Format::Builder::Parser::Regex::BEGIN@10 # spent 32µs making 1 call to Exporter::import
11
122988µs11.32ms
# spent 1.32ms (1.20+119µs) within DateTime::Format::Builder::Parser::Regex::BEGIN@12 which was called: # once (1.20ms+119µs) by DateTime::Format::Builder::Parser::BEGIN@1.2 at line 12
use DateTime::Format::Builder::Parser::generic;
1316µs@ISA = qw( DateTime::Format::Builder::Parser::generic );
14
15__PACKAGE__->valid_params(
16
17 # How to match
18 params => {
19 type => ARRAYREF, # mapping $1,$2,... to new() args
20 },
21 regex => {
22 type => SCALARREF,
23 callbacks => {
242039µs
# spent 20µs within DateTime::Format::Builder::Parser::Regex::__ANON__[/usr/share/perl5/DateTime/Format/Builder/Parser/Regex.pm:24] which was called 20 times, avg 980ns/call: # 10 times (10µs+0s) by Params::Validate::XS::validate at line 164 of DateTime/Format/Builder/Parser.pm, avg 1µs/call # 10 times (9µs+0s) by Params::Validate::XS::validate at line 185 of DateTime/Format/Builder/Parser.pm, avg 940ns/call
'is a regex' => sub { ref(shift) eq 'Regexp' }
25 }
26 },
27
28 # How to create
29 extra => {
30 type => HASHREF,
31 optional => 1,
32 },
33 constructor => {
34 type => CODEREF | ARRAYREF,
35 optional => 1,
36 callbacks => {
37 'array has 2 elements' => sub {
38 ref( $_[0] ) eq 'ARRAY' ? ( @{ $_[0] } == 2 ) : 1;
39 }
40 }
41 },
42112µs19µs);
# spent 9µs making 1 call to DateTime::Format::Builder::Parser::valid_params
43
44sub do_match {
45 my $self = shift;
46 my $date = shift;
47 my @matches = $date =~ $self->{regex};
48 return @matches ? \@matches : undef;
49}
50
51sub post_match {
52 my $self = shift;
53 my ( $date, $matches, $p ) = @_;
54
55 # Fill %p from match
56 @{$p}{ @{ $self->{params} } } = @$matches;
57 return;
58}
59
60sub make {
61 my $self = shift;
62 my ( $date, $dt, $p ) = @_;
63 my @args = ( %$p, %{ $self->{extra} } );
64 if ( my $cons = $self->{constructor} ) {
65 if ( ref $cons eq 'ARRAY' ) {
66 my ( $class, $method ) = @$cons;
67 return $class->$method(@args);
68 }
69 elsif ( ref $cons eq 'CODE' ) {
70 return $self->$cons(@args);
71 }
72 }
73 else {
74 return DateTime->new(@args);
75 }
76}
77
78
# spent 286µs (85+200) within DateTime::Format::Builder::Parser::Regex::create_parser which was called 10 times, avg 29µs/call: # 10 times (85µs+200µs) by DateTime::Format::Builder::Parser::create_single_parser at line 186 of DateTime/Format/Builder/Parser.pm, avg 29µs/call
sub create_parser {
79108µs my ( $self, %args ) = @_;
80103µs $args{extra} ||= {};
811017µs1022µs unless ( ref $self ) {
# spent 22µs making 10 calls to DateTime::Format::Builder::Parser::generic::new, avg 2µs/call
82 $self = $self->new(%args);
83 }
84
85 # Create our parser
86 return $self->generic_parser(
87 (
881039µs10178µs map { exists $args{$_} ? ( $_ => $args{$_} ) : () }
# spent 178µs making 10 calls to DateTime::Format::Builder::Parser::generic::generic_parser, avg 18µs/call
89 qw(
90 on_match on_fail preprocess postprocess
91 )
92 ),
93 label => $args{label},
94 );
95}
96
9714µs1;
98
99# ABSTRACT: Regex based date parsing
100
101__END__