Filename | /usr/share/perl5/DateTime/Format/Builder/Parser/Dispatch.pm |
Statements | Executed 19 statements in 495µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 14µs | 27µs | BEGIN@5 | DateTime::Format::Builder::Parser::Dispatch::
1 | 1 | 1 | 9µs | 17µs | BEGIN@6 | DateTime::Format::Builder::Parser::Dispatch::
1 | 1 | 1 | 9µs | 34µs | BEGIN@8 | DateTime::Format::Builder::Parser::Dispatch::
1 | 1 | 1 | 8µs | 28µs | BEGIN@7 | DateTime::Format::Builder::Parser::Dispatch::
1 | 1 | 1 | 7µs | 7µs | BEGIN@9 | DateTime::Format::Builder::Parser::Dispatch::
1 | 1 | 1 | 5µs | 13µs | BEGIN@14 | DateTime::Format::Builder::Parser::Dispatch::
0 | 0 | 0 | 0s | 0s | __ANON__[:45] | DateTime::Format::Builder::Parser::Dispatch::
0 | 0 | 0 | 0s | 0s | create_parser | DateTime::Format::Builder::Parser::Dispatch::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DateTime::Format::Builder::Parser::Dispatch; | ||||
2 | { | ||||
3 | 2 | 800ns | $DateTime::Format::Builder::Parser::Dispatch::VERSION = '0.81'; | ||
4 | } | ||||
5 | 2 | 26µs | 2 | 41µs | # spent 27µs (14+14) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@5 which was called:
# once (14µs+14µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 5 # spent 27µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@5
# spent 14µs making 1 call to strict::import |
6 | 2 | 203µs | 2 | 24µs | # spent 17µs (9+7) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@6 which was called:
# once (9µs+7µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 6 # spent 17µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@6
# spent 7µs making 1 call to warnings::import |
7 | 2 | 25µs | 2 | 47µs | # spent 28µs (8+19) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@7 which was called:
# once (8µs+19µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 7 # spent 28µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@7
# spent 19µs making 1 call to vars::import |
8 | 2 | 24µs | 2 | 59µs | # spent 34µs (9+25) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@8 which was called:
# once (9µs+25µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 8 # spent 34µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@8
# spent 25µs making 1 call to Exporter::import |
9 | 2 | 26µs | 1 | 7µs | # spent 7µs within DateTime::Format::Builder::Parser::Dispatch::BEGIN@9 which was called:
# once (7µs+0s) by DateTime::Format::Builder::Parser::BEGIN@1 at line 9 # spent 7µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@9 |
10 | |||||
- - | |||||
13 | { | ||||
14 | 3 | 182µs | 2 | 21µs | # spent 13µs (5+8) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@14 which was called:
# once (5µs+8µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 14 # spent 13µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@14
# spent 8µs making 1 call to strict::unimport |
15 | 1 | 1µs | *dispatch_data = *DateTime::Format::Builder::dispatch_data; | ||
16 | 1 | 700ns | *params = *DateTime::Format::Builder::Parser::params; | ||
17 | } | ||||
18 | |||||
19 | DateTime::Format::Builder::Parser->valid_params( | ||||
20 | 1 | 3µs | 1 | 8µs | Dispatch => { # spent 8µs making 1 call to DateTime::Format::Builder::Parser::valid_params |
21 | type => CODEREF, | ||||
22 | } | ||||
23 | ); | ||||
24 | |||||
25 | sub create_parser { | ||||
26 | my ( $self, %args ) = @_; | ||||
27 | my $coderef = $args{Dispatch}; | ||||
28 | |||||
29 | return sub { | ||||
30 | my ( $self, $date, $p, @args ) = @_; | ||||
31 | return unless defined $date; | ||||
32 | my $class = ref($self) || $self; | ||||
33 | |||||
34 | my @results = $coderef->($date); | ||||
35 | return unless @results; | ||||
36 | return unless defined $results[0]; | ||||
37 | |||||
38 | for my $group (@results) { | ||||
39 | my $parser = $dispatch_data{$class}{$group}; | ||||
40 | die "Unknown parsing group: $class\n" unless defined $parser; | ||||
41 | my $rv = eval { $parser->parse( $self, $date, $p, @args ) }; | ||||
42 | return $rv unless $@ or not defined $rv; | ||||
43 | } | ||||
44 | return; | ||||
45 | }; | ||||
46 | } | ||||
47 | |||||
48 | 1 | 3µs | 1; | ||
49 | |||||
50 | # ABSTRACT: Dispatch parsers by group | ||||
51 | |||||
52 | __END__ |