← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:24:10 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DateTime/Format/Builder/Parser/Dispatch.pm
StatementsExecuted 21 statements in 302µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11114µs17µsDateTime::Format::Builder::Parser::Dispatch::::BEGIN@2DateTime::Format::Builder::Parser::Dispatch::BEGIN@2
1119µs9µsDateTime::Format::Builder::Parser::Dispatch::::BEGIN@5DateTime::Format::Builder::Parser::Dispatch::BEGIN@5
1119µs41µsDateTime::Format::Builder::Parser::Dispatch::::BEGIN@4DateTime::Format::Builder::Parser::Dispatch::BEGIN@4
1118µs39µsDateTime::Format::Builder::Parser::Dispatch::::BEGIN@3DateTime::Format::Builder::Parser::Dispatch::BEGIN@3
1117µs16µsDateTime::Format::Builder::Parser::Dispatch::::BEGIN@78DateTime::Format::Builder::Parser::Dispatch::BEGIN@78
0000s0sDateTime::Format::Builder::Parser::Dispatch::::__ANON__[:111]DateTime::Format::Builder::Parser::Dispatch::__ANON__[:111]
0000s0sDateTime::Format::Builder::Parser::Dispatch::::create_parserDateTime::Format::Builder::Parser::Dispatch::create_parser
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::Dispatch;
2323µs220µs
# spent 17µs (14+3) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@2 which was called: # once (14µs+3µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 2
use strict;
# spent 17µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@2 # spent 3µs making 1 call to strict::import
3325µs270µs
# spent 39µs (8+31) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@3 which was called: # once (8µs+31µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 3
use vars qw( $VERSION %dispatch_data );
# spent 39µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@3 # spent 31µs making 1 call to vars::import
4321µs273µs
# spent 41µs (9+32) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@4 which was called: # once (9µs+32µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 4
use Params::Validate qw( CODEREF validate );
# spent 41µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@4 # spent 32µs making 1 call to Exporter::import
5354µs19µs
# spent 9µs within DateTime::Format::Builder::Parser::Dispatch::BEGIN@5 which was called: # once (9µs+0s) by DateTime::Format::Builder::Parser::BEGIN@1 at line 5
use DateTime::Format::Builder::Parser;
6
7=head1 NAME
8
9DateTime::Format::Builder::Parser::Dispatch - Dispatch parsers by group
10
11=head1 SYNOPSIS
12
13 package SampleDispatch;
14 use DateTime::Format::Builder
15 (
16 parsers => {
17 parse_datetime => [
18 {
19 Dispatch => sub {
20 return 'fnerk';
21 }
22 }
23 ]
24 },
25 groups => {
26 fnerk => [
27 {
28 regex => qr/^(\d{4})(\d\d)(\d\d)$/,
29 params => [qw( year month day )],
30 },
31 ]
32 }
33 );
34
35=head1 DESCRIPTION
36
37C<Dispatch> adds another parser type to C<Builder> permitting
38dispatch of parsing according to group names.
39
40=head1 SPECIFICATION
41
42C<Dispatch> has just one key: C<Dispatch>. The value should be a
43reference to a subroutine that returns one of:
44
45=over 4
46
47=item *
48
49C<undef>, meaning no groups could be found.
50
51=item *
52
53An empty list, meaning no groups could be found.
54
55=item *
56
57A single string, meaning: use this group
58
59=item *
60
61A list of strings, meaning: use these groups in this order.
62
63=back
64
65Groups are specified much like the example in the L<SYNOPSIS>.
66They follow the same format as when you specify them for methods.
67
68=head1 SIDEEFFECTS
69
70Your group parser can also be a Dispatch parser. Thus you could
71potentially end up with an infinitely recursive parser.
72
73=cut
74
751600ns$VERSION = '0.78';
76
77{
784169µs226µs
# spent 16µs (7+9) within DateTime::Format::Builder::Parser::Dispatch::BEGIN@78 which was called: # once (7µs+9µs) by DateTime::Format::Builder::Parser::BEGIN@1 at line 78
no strict 'refs';
# spent 16µs making 1 call to DateTime::Format::Builder::Parser::Dispatch::BEGIN@78 # spent 9µs making 1 call to strict::unimport
7911µs *dispatch_data = *DateTime::Format::Builder::dispatch_data;
801700ns *params = *DateTime::Format::Builder::Parser::params;
81}
82
83DateTime::Format::Builder::Parser->valid_params(
8413µs110µs Dispatch => {
# spent 10µs making 1 call to DateTime::Format::Builder::Parser::valid_params
85 type => CODEREF,
86 }
87);
88
89sub create_parser
90{
91 my ($self, %args) = @_;
92 my $coderef = $args{Dispatch};
93
94 return sub {
95 my ($self, $date, $p, @args) = @_;
96 return unless defined $date;
97 my $class = ref($self)||$self;
98
99 my @results = $coderef->( $date );
100 return unless @results;
101 return unless defined $results[0];
102
103 for my $group (@results)
104 {
105 my $parser = $dispatch_data{$class}{$group};
106 die "Unknown parsing group: $class\n" unless defined $parser;
107 my $rv = eval { $parser->parse( $self, $date, $p, @args ) };
108 return $rv unless $@ or not defined $rv;
109 }
110 return;
111 };
112}
113
11414µs1;
115
116__END__