← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:14:19 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Markdent/Parser.pm
StatementsExecuted 46 statements in 6.07ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117.3ms5.69sMarkdent::Parser::::BEGIN@11Markdent::Parser::BEGIN@11
11113.1ms5.19sMarkdent::Parser::::BEGIN@10Markdent::Parser::BEGIN@10
11152µs52µsMarkdent::Parser::::BEGIN@2Markdent::Parser::BEGIN@2
11149µs28.1msMarkdent::Parser::::BEGIN@19Markdent::Parser::BEGIN@19
11147µs23.7msMarkdent::Parser::::BEGIN@18Markdent::Parser::BEGIN@18
11145µs27.4msMarkdent::Parser::::BEGIN@12Markdent::Parser::BEGIN@12
11144µs255µsMarkdent::Parser::::BEGIN@14Markdent::Parser::BEGIN@14
11144µs892µsMarkdent::Parser::::BEGIN@13Markdent::Parser::BEGIN@13
11142µs23.0msMarkdent::Parser::::BEGIN@17Markdent::Parser::BEGIN@17
11140µs298µsMarkdent::Parser::::BEGIN@16Markdent::Parser::BEGIN@16
11138µs57µsMarkdent::Parser::::BEGIN@6Markdent::Parser::BEGIN@6
11138µs107µsMarkdent::Parser::::BEGIN@7Markdent::Parser::BEGIN@7
11124µs24µsMarkdent::Parser::::BEGIN@9Markdent::Parser::BEGIN@9
0000s0sMarkdent::Parser::::BUILDMarkdent::Parser::BUILD
0000s0sMarkdent::Parser::::__ANON__[:120]Markdent::Parser::__ANON__[:120]
0000s0sMarkdent::Parser::::__ANON__[:126]Markdent::Parser::__ANON__[:126]
0000s0sMarkdent::Parser::::_build_block_parserMarkdent::Parser::_build_block_parser
0000s0sMarkdent::Parser::::_build_span_parserMarkdent::Parser::_build_span_parser
0000s0sMarkdent::Parser::::_class_name_for_dialectMarkdent::Parser::_class_name_for_dialect
0000s0sMarkdent::Parser::::_clean_textMarkdent::Parser::_clean_text
0000s0sMarkdent::Parser::::_set_classes_for_dialectMarkdent::Parser::_set_classes_for_dialect
0000s0sMarkdent::Parser::::parseMarkdent::Parser::parse
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Markdent::Parser;
2
# spent 52µs within Markdent::Parser::BEGIN@2 which was called: # once (52µs+0s) by Markdent::Simple::Document::BEGIN@10 at line 4
BEGIN {
3128µs $Markdent::Parser::VERSION = '0.17';
4174µs152µs}
# spent 52µs making 1 call to Markdent::Parser::BEGIN@2
5
6396µs275µs
# spent 57µs (38+19) within Markdent::Parser::BEGIN@6 which was called: # once (38µs+19µs) by Markdent::Simple::Document::BEGIN@10 at line 6
use strict;
# spent 57µs making 1 call to Markdent::Parser::BEGIN@6 # spent 19µs making 1 call to strict::import
7398µs2176µs
# spent 107µs (38+69) within Markdent::Parser::BEGIN@7 which was called: # once (38µs+69µs) by Markdent::Simple::Document::BEGIN@10 at line 7
use warnings;
# spent 107µs making 1 call to Markdent::Parser::BEGIN@7 # spent 69µs making 1 call to warnings::import
8
9394µs124µs
# spent 24µs within Markdent::Parser::BEGIN@9 which was called: # once (24µs+0s) by Markdent::Simple::Document::BEGIN@10 at line 9
use Class::MOP;
# spent 24µs making 1 call to Markdent::Parser::BEGIN@9
103620µs15.19s
# spent 5.19s (13.1ms+5.17) within Markdent::Parser::BEGIN@10 which was called: # once (13.1ms+5.17s) by Markdent::Simple::Document::BEGIN@10 at line 10
use Markdent::Dialect::Standard::BlockParser;
# spent 5.19s making 1 call to Markdent::Parser::BEGIN@10
113662µs15.69s
# spent 5.69s (17.3ms+5.67) within Markdent::Parser::BEGIN@11 which was called: # once (17.3ms+5.67s) by Markdent::Simple::Document::BEGIN@10 at line 11
use Markdent::Dialect::Standard::SpanParser;
# spent 5.69s making 1 call to Markdent::Parser::BEGIN@11
123164µs254.7ms
# spent 27.4ms (45µs+27.3) within Markdent::Parser::BEGIN@12 which was called: # once (45µs+27.3ms) by Markdent::Simple::Document::BEGIN@10 at line 12
use Markdent::Types qw( Str HashRef BlockParserClass SpanParserClass );
# spent 27.4ms making 1 call to Markdent::Parser::BEGIN@12 # spent 27.3ms making 1 call to MooseX::Types::Combine::import
133148µs21.74ms
# spent 892µs (44+848) within Markdent::Parser::BEGIN@13 which was called: # once (44µs+848µs) by Markdent::Simple::Document::BEGIN@10 at line 13
use MooseX::Params::Validate qw( validated_list );
# spent 892µs making 1 call to Markdent::Parser::BEGIN@13 # spent 848µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
143110µs2466µs
# spent 255µs (44+211) within Markdent::Parser::BEGIN@14 which was called: # once (44µs+211µs) by Markdent::Simple::Document::BEGIN@10 at line 14
use Try::Tiny;
# spent 255µs making 1 call to Markdent::Parser::BEGIN@14 # spent 211µs making 1 call to Exporter::import
15
163114µs2556µs
# spent 298µs (40+258) within Markdent::Parser::BEGIN@16 which was called: # once (40µs+258µs) by Markdent::Simple::Document::BEGIN@10 at line 16
use namespace::autoclean;
# spent 298µs making 1 call to Markdent::Parser::BEGIN@16 # spent 258µs making 1 call to namespace::autoclean::import
173162µs245.9ms
# spent 23.0ms (42µs+22.9) within Markdent::Parser::BEGIN@17 which was called: # once (42µs+22.9ms) by Markdent::Simple::Document::BEGIN@10 at line 17
use Moose;
# spent 23.0ms making 1 call to Markdent::Parser::BEGIN@17 # spent 22.9ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456]
183159µs247.3ms
# spent 23.7ms (47µs+23.6) within Markdent::Parser::BEGIN@18 which was called: # once (47µs+23.6ms) by Markdent::Simple::Document::BEGIN@10 at line 18
use MooseX::SemiAffordanceAccessor;
# spent 23.7ms making 1 call to Markdent::Parser::BEGIN@18 # spent 23.6ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456]
1933.09ms256.2ms
# spent 28.1ms (49µs+28.1) within Markdent::Parser::BEGIN@19 which was called: # once (49µs+28.1ms) by Markdent::Simple::Document::BEGIN@10 at line 19
use MooseX::StrictConstructor;
# spent 28.1ms making 1 call to Markdent::Parser::BEGIN@19 # spent 28.1ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456]
20
21116µs141.0mswith 'Markdent::Role::AnyParser';
# spent 41.0ms making 1 call to Moose::with
22
23130µs217.3mshas _block_parser_class => (
# spent 17.0ms making 1 call to Moose::has # spent 330µs making 1 call to __TYPE__::Markdent::Types::Internal::BlockParserClass
24 is => 'rw',
25 isa => BlockParserClass,
26 init_arg => 'block_parser_class',
27 default => 'Markdent::Dialect::Standard::BlockParser',
28);
29
30118µs113.8mshas _block_parser => (
# spent 13.8ms making 1 call to Moose::has
31 is => 'ro',
32 does => 'Markdent::Role::BlockParser',
33 lazy => 1,
34 init_arg => undef,
35 builder => '_build_block_parser',
36);
37
38126µs217.3mshas _block_parser_args => (
# spent 17.0ms making 1 call to Moose::has # spent 350µs making 1 call to __TYPE__::HashRef
39 is => 'rw',
40 does => HashRef,
41 init_arg => undef,
42);
43
44126µs217.4mshas _span_parser_class => (
# spent 17.0ms making 1 call to Moose::has # spent 332µs making 1 call to __TYPE__::Markdent::Types::Internal::SpanParserClass
45 is => 'rw',
46 does => SpanParserClass,
47 init_arg => 'span_parser_class',
48 default => 'Markdent::Dialect::Standard::SpanParser',
49);
50
51124µs217.3mshas _span_parser_args => (
# spent 17.0ms making 1 call to Moose::has # spent 333µs making 1 call to __TYPE__::HashRef
52 is => 'rw',
53 does => HashRef,
54 init_arg => undef,
55);
56
57116µs113.9mshas _span_parser => (
# spent 13.9ms making 1 call to Moose::has
58 is => 'ro',
59 does => 'Markdent::Role::SpanParser',
60 lazy => 1,
61 init_arg => undef,
62 builder => '_build_span_parser',
63);
64
65sub BUILD {
66 my $self = shift;
67 my $args = shift;
68
69 $self->_set_classes_for_dialect($args);
70
71 my %sp_args;
72 for my $key (
73 grep {defined}
74 map { $_->init_arg() }
75 $self->_span_parser_class()->meta()->get_all_attributes()
76 ) {
77
78 $sp_args{$key} = $args->{$key}
79 if exists $args->{$key};
80 }
81
82 $sp_args{handler} = $self->handler();
83
84 $self->_set_span_parser_args(\%sp_args);
85
86 my %bp_args;
87 for my $key (
88 grep {defined}
89 map { $_->init_arg() }
90 $self->_block_parser_class()->meta()->get_all_attributes()
91 ) {
92
93 $bp_args{$key} = $args->{$key}
94 if exists $args->{$key};
95 }
96
97 $bp_args{handler} = $self->handler();
98 $bp_args{span_parser} = $self->_span_parser();
99
100 $self->_set_block_parser_args(\%bp_args);
101}
102
103sub _set_classes_for_dialect {
104 my $self = shift;
105 my $args = shift;
106
107 my $dialect = delete $args->{dialect}
108 or return;
109
110 for my $pair (
111 map { [ $_, $self->_class_name_for_dialect( $dialect, $_ ) ] }
112 qw( block_parser span_parser ) ) {
113
114 my ( $thing, $class ) = @{$pair};
115
116 my $loaded;
117 try {
118 Class::MOP::load_class($class);
119 $loaded = 1;
120 }
121 catch {
122
123 # XXX - This is kind of broken, since a user can typo a dialect
124 # and that will just get ignored.
125 die $_ unless $_ =~ /Can't locate/;
126 };
127
128 next unless $loaded;
129
130 if ( exists $args->{ $thing . '_class' } ) {
131 die
132 "You specified a dialect ($dialect) which has its own $thing class"
133 . " and you also specified an explicit $thing class."
134 . " You cannot specify both when creating a Markdent::Parser.";
135 }
136
137 my $meth = '_set_' . $thing . '_class';
138 $self->$meth($class);
139 }
140}
141
142sub _class_name_for_dialect {
143 my $self = shift;
144 my $dialect = shift;
145 my $type = shift;
146
147 my $suffix = join q{}, map {ucfirst} split /_/, $type;
148
149 if ( $dialect =~ /::/ ) {
150 return join '::', $dialect, $suffix;
151 }
152 else {
153 return join '::', 'Markdent::Dialect', $dialect, $suffix;
154 }
155}
156
157sub _build_block_parser {
158 my $self = shift;
159
160 return $self->_block_parser_class()->new( $self->_block_parser_args() );
161}
162
163sub _build_span_parser {
164 my $self = shift;
165
166 return $self->_span_parser_class()->new( $self->_span_parser_args() );
167}
168
169sub parse {
170 my $self = shift;
171 my ($text) = validated_list(
172 \@_,
173 markdown => { isa => Str },
174 );
175
176 $self->_clean_text(\$text);
177
178 $self->_send_event('StartDocument');
179
180 $self->_block_parser()->parse_document(\$text);
181
182 $self->_send_event('EndDocument');
183
184 return;
185}
186
187sub _clean_text {
188 my $self = shift;
189 my $text = shift;
190
191 ${$text} =~ s/\r\n?/\n/g;
192 ${$text} .= "\n"
193 unless substr( ${$text}, -1, 1 ) eq "\n";
194
195 return;
196}
197
198126µs222.7ms__PACKAGE__->meta()->make_immutable();
# spent 22.5ms making 1 call to Class::MOP::Class::make_immutable # spent 172µs making 1 call to Markdent::Parser::meta
199
2001175µs1;
201
202# ABSTRACT: A markdown parser
203
- -
206=pod
207
- -
310190µs130.5ms__END__