← Index
NYTProf Performance Profile   « line view »
For opt.pl
  Run on Fri May 8 15:08:12 2015
Reported on Fri May 8 15:08:16 2015

Filename/home/lbr/.plenv/versions/5.20.2/lib/perl5/site_perl/5.20.2/Petal/Tiny.pm
StatementsExecuted 2158861 statements in 3.43s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
8793031889ms1.58sPetal::Tiny::::tag_openPetal::Tiny::tag_open
417041553ms3.43sPetal::Tiny::::makeitsoPetal::Tiny::makeitso (recurses: max depth 48, inclusive time 38.8s)
8255021512ms548msPetal::Tiny::::tag_closePetal::Tiny::tag_close
2329021448ms685msPetal::Tiny::::extract_attributesPetal::Tiny::extract_attributes
712230161275ms275msPetal::Tiny::::CORE:matchPetal::Tiny::CORE:match (opcode)
495031107ms163msPetal::Tiny::::resolvePetal::Tiny::resolve (recurses: max depth 1, inclusive time 64.3ms)
93307190.1ms105msPetal::Tiny::::trimPetal::Tiny::trim
12894022187.1ms87.1msPetal::Tiny::::CORE:substPetal::Tiny::CORE:subst (opcode)
77002182.3ms151msPetal::Tiny::::tag_self_closePetal::Tiny::tag_self_close
30701177.3ms2.97sPetal::Tiny::::makeitso_blockPetal::Tiny::makeitso_block (recurses: max depth 11, inclusive time 12.5s)
30701146.0ms54.9msPetal::Tiny::::has_instructionsPetal::Tiny::has_instructions
30701141.8ms43.4msPetal::Tiny::::namespacePetal::Tiny::namespace
654027140.3ms40.3msPetal::Tiny::::CORE:regcompPetal::Tiny::CORE:regcomp (opcode)
21906125.7ms230msPetal::Tiny::::resolve_expressionPetal::Tiny::resolve_expression
15202122.6ms25.5msPetal::Tiny::::node2tagPetal::Tiny::node2tag
38701120.6ms22.2msPetal::Tiny::::_interpolate_dollarPetal::Tiny::_interpolate_dollar
15001119.5ms1.58sPetal::Tiny::::tal_attributesPetal::Tiny::tal_attributes (recurses: max depth 4, inclusive time 3.03s)
16801116.4ms1.64sPetal::Tiny::::tal_conditionPetal::Tiny::tal_condition (recurses: max depth 4, inclusive time 3.13s)
15502114.9ms1.60sPetal::Tiny::::tal_contentPetal::Tiny::tal_content (recurses: max depth 4, inclusive time 3.11s)
15002110.7ms1.56sPetal::Tiny::::tal_omit_tagPetal::Tiny::tal_omit_tag (recurses: max depth 4, inclusive time 2.88s)
16801110.3ms1.64sPetal::Tiny::::tal_definePetal::Tiny::tal_define (recurses: max depth 4, inclusive time 3.14s)
2150118.28ms9.60msPetal::Tiny::::xmlencodePetal::Tiny::xmlencode
1680116.90ms1.65sPetal::Tiny::::tal_on_errorPetal::Tiny::tal_on_error (recurses: max depth 4, inclusive time 3.14s)
8250316.65ms6.65msPetal::Tiny::::reftypePetal::Tiny::reftype
1550215.28ms1.58sPetal::Tiny::::tal_replacePetal::Tiny::tal_replace (recurses: max depth 4, inclusive time 3.04s)
1550214.79ms1.60sPetal::Tiny::::tal_repeatPetal::Tiny::tal_repeat (recurses: max depth 4, inclusive time 3.12s)
1113.25ms3.54msPetal::Tiny::::BEGIN@5Petal::Tiny::BEGIN@5
1111.69ms1.72msPetal::Tiny::::BEGIN@3Petal::Tiny::BEGIN@3
21021723µs11.2msPetal::Tiny::::modifier_truePetal::Tiny::modifier_true
5011473µs625µsPetal::Tiny::::newPetal::Tiny::new
5011463µs3.43sPetal::Tiny::::processPetal::Tiny::process
1011303µs1.96msPetal::Tiny::::_do_repeatPetal::Tiny::_do_repeat
8011285µs2.50msPetal::Tiny::::modifier_falsePetal::Tiny::modifier_false
111217µs247µsPetal::Tiny::::BEGIN@4Petal::Tiny::BEGIN@4
101180µs738µsPetal::Tiny::::__ANON__[:133]Petal::Tiny::__ANON__[:133]
201118µs18µsPetal::Tiny::::CORE:substcontPetal::Tiny::CORE:substcont (opcode)
2213µs3µsPetal::Tiny::::CORE:qrPetal::Tiny::CORE:qr (opcode)
0000s0sPetal::Tiny::::modifier_stringPetal::Tiny::modifier_string
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Petal::Tiny;
21500ns$Petal::Tiny::VERSION = '1.13';
321.62ms21.73ms
# spent 1.72ms (1.69+35µs) within Petal::Tiny::BEGIN@3 which was called: # once (1.69ms+35µs) by main::BEGIN@2 at line 3
use warnings;
# spent 1.72ms making 1 call to Petal::Tiny::BEGIN@3 # spent 6µs making 1 call to warnings::import
42232µs2260µs
# spent 247µs (217+31) within Petal::Tiny::BEGIN@4 which was called: # once (217µs+31µs) by main::BEGIN@2 at line 4
use strict;
# spent 247µs making 1 call to Petal::Tiny::BEGIN@4 # spent 12µs making 1 call to strict::import
523.10ms23.61ms
# spent 3.54ms (3.25+292µs) within Petal::Tiny::BEGIN@5 which was called: # once (3.25ms+292µs) by main::BEGIN@2 at line 5
use Carp;
# spent 3.54ms making 1 call to Petal::Tiny::BEGIN@5 # spent 75µs making 1 call to Exporter::import
6
7# REX/Perl 1.0
8# Robert D. Cameron "REX: XML Shallow Parsing with Regular Expressions",
9# Technical Report TR 1998-17, School of Computing Science, Simon Fraser
10# University, November, 1998.
11# Copyright (c) 1998, Robert D. Cameron.
12# The following code may be freely used and distributed provided that
13# this copyright and citation notice remains intact and that modifications
14# or additions are clearly identified.
151200nsour $TextSE = "[^<]+";
161100nsour $UntilHyphen = "[^-]*-";
171900nsour $Until2Hyphens = "$UntilHyphen(?:[^-]$UntilHyphen)*-";
181500nsour $CommentCE = "$Until2Hyphens>?";
191200nsour $UntilRSBs = "[^\\]]*](?:[^\\]]+])*]+";
201600nsour $CDATA_CE = "$UntilRSBs(?:[^\\]>]$UntilRSBs)*>";
211200nsour $S = "[ \\n\\t\\r]+";
221200nsour $NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]";
231200nsour $NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]";
241800nsour $Name = "(?:$NameStrt)(?:$NameChar)*";
251100nsour $QuoteSE = "\"[^\"]*\"|'[^']*'";
2612µsour $DT_IdentSE = "$S$Name(?:$S(?:$Name|$QuoteSE))*";
271500nsour $MarkupDeclCE = "(?:[^\\]\"'><]+|$QuoteSE)*>";
281100nsour $S1 = "[\\n\\r\\t ]";
291100nsour $UntilQMs = "[^?]*\\?+";
301700nsour $PI_Tail = "\\?>|$S1$UntilQMs(?:[^>?]$UntilQMs)*>";
3111µsour $DT_ItemSE = "<(?:!(?:--$Until2Hyphens>|[^-]$MarkupDeclCE)|\\?$Name(?:$PI_Tail))|%$Name;|$S";
3211µsour $DocTypeCE = "$DT_IdentSE(?:$S)?(?:\\[(?:$DT_ItemSE)*](?:$S)?)?>?";
3311µsour $DeclCE = "--(?:$CommentCE)?|\\[CDATA\\[(?:$CDATA_CE)?|DOCTYPE(?:$DocTypeCE)?";
341600nsour $PI_CE = "$Name(?:$PI_Tail)?";
351500nsour $EndTagCE = "$Name(?:$S)?>?";
361200nsour $AttValSE = "\"[^<\"]*\"|'[^<']*'";
3711µsour $ElemTagCE = "$Name(?:$S$Name(?:$S)?=(?:$S)?(?:$AttValSE))*(?:$S)?/?>?";
3811µsour $ElemTagCE_Mod = "$S($Name)(?:$S)?=(?:$S)?($AttValSE)";
3911µsour $MarkupSPE = "<(?:!(?:$DeclCE)?|\\?(?:$PI_CE)?|/(?:$EndTagCE)?|(?:$ElemTagCE)?)";
4013µsour $XML_SPE = "$TextSE|$MarkupSPE";
41# REX END - thank you Robert for this 26 line XML parser - awesome ...
42
43
44159µs249µsour $RE_1 = qr /$ElemTagCE/;
# spent 47µs making 1 call to Petal::Tiny::CORE:regcomp # spent 2µs making 1 call to Petal::Tiny::CORE:qr
45129µs226µsour $RE_2 = qr /$ElemTagCE_Mod/;
# spent 25µs making 1 call to Petal::Tiny::CORE:regcomp # spent 800ns making 1 call to Petal::Tiny::CORE:qr
461100nsour $VARIABLE_RE_SIMPLE = qq |\$[A-Za-z_][A-Za-z0-9_\.:\/]+|;
471100nsour $VARIABLE_RE_BRACKETS = qq |(?<!\$)\\{.*?(?<!\\\\)\\}|;
481700nsour $STRING_TOKEN_RE = "($VARIABLE_RE_SIMPLE|$VARIABLE_RE_BRACKETS)";
49
501100nsour $TAL = 'petal';
51
521300nsour $STOP_RECURSE = 0;
53
54
55
# spent 625µs (473+152) within Petal::Tiny::new which was called 50 times, avg 13µs/call: # 50 times (473µs+152µs) by main::RUNTIME at line 59 of opt.pl, avg 13µs/call
sub new {
565023µs my $class = shift;
575028µs $class = ref $class || $class;
5850132µs my $thing = shift;
595052µs my $self = bless {}, $class;
6050304µs50152µs if (defined $thing and $thing =~ /(\<|\n|\>)/) { $self->{xmldata} = $thing }
# spent 152µs making 50 calls to Petal::Tiny::CORE:match, avg 3µs/call
61 elsif (defined $thing) {
62 $self->{xmldata} = do {
63 open my $xmldatafile, "<", $thing or die "cannot read open $thing";
64 my $xmldata = join '', <$xmldatafile>;
65 close $xmldatafile;
66 $xmldata;
67 };
68 }
6950100µs return $self;
70}
71
72
73
# spent 3.43s (463µs+3.43) within Petal::Tiny::process which was called 50 times, avg 68.5ms/call: # 50 times (463µs+3.43s) by main::RUNTIME at line 60 of opt.pl, avg 68.5ms/call
sub process {
745014µs my $self = shift;
7550162µs my $context = { @_ };
765032µs my $data = $self->{xmldata};
775019µs defined $data or return; # empty data, empty result.
7850221µs503.43s return $self->makeitso($data, $context); # earl grey. hot.
# spent 3.43s making 50 calls to Petal::Tiny::makeitso, avg 68.5ms/call
79}
80
81
82
# spent 3.43s (553ms+2.87) within Petal::Tiny::makeitso which was called 4170 times, avg 821µs/call: # 2880 times (293ms+-293ms) by Petal::Tiny::makeitso at line 119, avg 0s/call # 990 times (110ms+-110ms) by Petal::Tiny::makeitso_block at line 176, avg 0s/call # 250 times (59.5ms+-59.5ms) by Petal::Tiny::tal_omit_tag at line 335, avg 0s/call # 50 times (90.6ms+3.33s) by Petal::Tiny::process at line 78, avg 68.5ms/call
sub makeitso {
834170766µs my $self = shift;
844170605µs my $xml = shift;
85417035.1ms10015.4ms my @xml = ref $xml ? @{$xml} : ( $xml =~ /$XML_SPE/g );
# spent 15.2ms making 50 calls to Petal::Tiny::CORE:match, avg 303µs/call # spent 233µs making 50 calls to Petal::Tiny::CORE:regcomp, avg 5µs/call
8641701.01ms my $context = shift || {};
8741701.03ms my @head = ();
884170972µs my @body = ();
894170883µs my @tail = ();
9041701.14ms while (@xml) {
9169401.76ms my $elem = shift @xml;
9269404.96ms6940116ms tag_self_close ($elem) and do {
# spent 116ms making 6940 calls to Petal::Tiny::tag_self_close, avg 17µs/call
93760248µs push @body, $elem;
947602.62ms @tail = @xml;
95760864µs last;
96 };
9761804.17ms6180161ms my $opentag = tag_open ($elem);
# spent 161ms making 6180 calls to Petal::Tiny::tag_open, avg 26µs/call
9861801.06ms $opentag and do {
992310689µs push @body, $elem;
1002310553µs my $balance = 1;
1012310755µs while ($balance) {
1027868011.3ms @xml or confess "cannot find closing tag for $elem";
1037868015.5ms my $elem = shift @xml;
1047868049.0ms786801.29s tag_open ($elem) and $balance++;
# spent 1.29s making 78680 calls to Petal::Tiny::tag_open, avg 16µs/call
1057868050.9ms78680520ms tag_close ($elem) and $balance--;
# spent 520ms making 78680 calls to Petal::Tiny::tag_close, avg 7µs/call
1067868029.8ms push @body, $elem;
107 }
10823109.06ms @tail = @xml;
10923102.30ms last;
110 };
11138702.59ms387027.9ms tag_close ($elem) and confess "cannot find opening tag for $elem";
# spent 27.9ms making 3870 calls to Petal::Tiny::tag_close, avg 7µs/call
112
11338704.08ms387022.2ms $elem = $self->_interpolate_dollar($context, $elem, 'resolve_expression');
# spent 22.2ms making 3870 calls to Petal::Tiny::_interpolate_dollar, avg 6µs/call
11438702.64ms push @head, $elem;
115 }
11641701.10ms my @res = ();
11741701.61ms push @res, @head if (@head);
11841709.29ms30702.97s push @res, $self->makeitso_block(\@body, $context) if (@body);
# spent 15.5s making 3070 calls to Petal::Tiny::makeitso_block, avg 5.04ms/call, recursion: max depth 11, sum of overlapping time 12.5s
11941704.29ms28800s push @res, $self->makeitso(\@tail, $context) if (@tail);
# spent 24.0s making 2880 calls to Petal::Tiny::makeitso, avg 8.35ms/call, recursion: max depth 48, sum of overlapping time 24.0s
120417025.3ms return join '', @res;
121}
122
123
124
# spent 22.2ms (20.6+1.60) within Petal::Tiny::_interpolate_dollar which was called 3870 times, avg 6µs/call: # 3870 times (20.6ms+1.60ms) by Petal::Tiny::makeitso at line 113, avg 6µs/call
sub _interpolate_dollar {
12538701.75ms my ($self, $context, $string, $method) = @_;
126
127
# spent 738µs (80+658) within Petal::Tiny::__ANON__[/home/lbr/.plenv/versions/5.20.2/lib/perl5/site_perl/5.20.2/Petal/Tiny.pm:133] which was called 10 times, avg 74µs/call: # 10 times (80µs+658µs) by Petal::Tiny::_interpolate_dollar at line 136, avg 74µs/call
my $subst = sub {
1281036µs my $what = shift;
1291020µs10658µs my $res = $self->$method($what, $context);
# spent 658µs making 10 calls to Petal::Tiny::resolve_expression, avg 66µs/call
1301022µs return $res if defined $res;
131 carp "'$what' in \$-interpolation resolved to undef";
132 return "";
13338706.26ms };
134
13538705.12ms3870795µs if ($string =~ /\$/) {
# spent 795µs making 3870 calls to Petal::Tiny::CORE:match, avg 205ns/call
13620121µs40795µs $string =~ s/(?<!\$) \$\{ ( [^{}]+ ) \} / $subst->($1) /xegi;
# spent 738µs making 10 calls to Petal::Tiny::__ANON__[Petal/Tiny.pm:133], avg 74µs/call # spent 39µs making 10 calls to Petal::Tiny::CORE:subst, avg 4µs/call # spent 18µs making 20 calls to Petal::Tiny::CORE:substcont, avg 925ns/call
1371017µs103µs $string =~ s/(?<!\$) \$\{? ( [a-z0-9-\/\:\_]+ ) \}? / $subst->($1) /xegi;
# spent 3µs making 10 calls to Petal::Tiny::CORE:subst, avg 330ns/call
1381017µs102µs $string =~ s/\$\$/\$/g;
# spent 2µs making 10 calls to Petal::Tiny::CORE:subst, avg 180ns/call
139 }
140387010.4ms return $string;
141}
142
143
144
# spent 43.4ms (41.8+1.54) within Petal::Tiny::namespace which was called 3070 times, avg 14µs/call: # 3070 times (41.8ms+1.54ms) by Petal::Tiny::makeitso_block at line 168, avg 14µs/call
sub namespace {
1453070562µs my $self = shift;
1463070435µs my $node = shift;
14730706.88ms for my $k (keys %{$node}) {
1481444032.9ms144401.49ms $k =~ /^xmlns\:/ or next;
# spent 1.49ms making 14440 calls to Petal::Tiny::CORE:match, avg 103ns/call
1495049µs my $v = $node->{$k};
1505058µs if ($v eq 'http://purl.org/petal/1.0/') {
1515062µs delete $node->{$k};
15250126µs5056µs $k =~ s/^xmlns\://;
# spent 56µs making 50 calls to Petal::Tiny::CORE:subst, avg 1µs/call
15350123µs return $k;
154 }
155 }
15630208.45ms return;
157}
158
159
160
# spent 2.97s (77.3ms+2.90) within Petal::Tiny::makeitso_block which was called 3070 times, avg 968µs/call: # 3070 times (77.3ms+2.90s) by Petal::Tiny::makeitso at line 118, avg 968µs/call
sub makeitso_block {
1613070604µs my $self = shift;
1623070522µs my $xml = shift;
1633070420µs my $context = shift;
164307010.0ms my @xml = ref $xml ? @{$xml} : ( $xml =~ /$XML_SPE/g );
1653070992µs my $tag = shift (@xml);
1663070889µs my $gat = pop (@xml);
16730703.01ms3830166ms my $node = tag_open ($tag) || tag_self_close ($tag);
# spent 130ms making 3070 calls to Petal::Tiny::tag_open, avg 42µs/call # spent 35.5ms making 760 calls to Petal::Tiny::tag_self_close, avg 47µs/call
16830703.05ms307043.4ms my $ns = $self->namespace($node);
# spent 43.4ms making 3070 calls to Petal::Tiny::namespace, avg 14µs/call
16930701.28ms local $TAL = $ns || $TAL;
17030703.00ms307054.9ms if (has_instructions ($node)) {
# spent 54.9ms making 3070 calls to Petal::Tiny::has_instructions, avg 18µs/call
17116807.50ms $context = { %{$context} };
17216807.99ms16801.65s return $self->tal_on_error($node, \@xml, $gat, $context);
# spent 4.79s making 1680 calls to Petal::Tiny::tal_on_error, avg 2.85ms/call, recursion: max depth 4, sum of overlapping time 3.14s
173 }
174 else {
1751390319µs50816µs $tag = node2tag ($node) if ($ns);
# spent 816µs making 50 calls to Petal::Tiny::node2tag, avg 16µs/call
17613904.75ms9900s if ($gat) { return $tag . $self->makeitso(\@xml, $context) . $gat }
# spent 10.3s making 990 calls to Petal::Tiny::makeitso, avg 10.4ms/call, recursion: max depth 35, sum of overlapping time 10.3s
177400970µs else { return $tag } # self-closing tag
178 }
179}
180
181
182
# spent 1.65s (6.90ms+1.64) within Petal::Tiny::tal_on_error which was called 1680 times, avg 980µs/call: # 1680 times (6.90ms+1.64s) by Petal::Tiny::makeitso_block at line 172, avg 980µs/call
sub tal_on_error {
1831680925µs my ($self, $node, $xml, $end, $context) = @_;
18416801.96ms my $stuff = delete $node->{"$TAL:on-error"};
185168014.4ms16801.64s defined $stuff or return $self->tal_define($node, $xml, $end, $context);
# spent 4.78s making 1680 calls to Petal::Tiny::tal_define, avg 2.85ms/call, recursion: max depth 4, sum of overlapping time 3.14s
186 my $nodeCopy = { %{$node} };
187 my $res = eval { $self->tal_define($node, $xml, $end, $context) };
188 if ($@) {
189 my @result = ();
190 for my $k (keys %{$nodeCopy}) { delete $nodeCopy->{$k} if $k =~ /^$TAL:/ }
191 delete $nodeCopy->{_close} and $end = "</$nodeCopy->{_tag}>"; # deal with self closing tags
192 push @result, node2tag ($nodeCopy);
193 push @result, $self->resolve_expression($stuff, $context);
194 push @result, $end;
195 return join '', @result;
196 }
197 else {
198 return $res;
199 }
200}
201
202
203
# spent 1.64s (10.3ms+1.63) within Petal::Tiny::tal_define which was called 1680 times, avg 979µs/call: # 1680 times (10.3ms+1.63s) by Petal::Tiny::tal_on_error at line 185, avg 979µs/call
sub tal_define {
2041680611µs my ($self, $node, $xml, $end, $context) = @_;
20516801.21ms my $stuff = delete $node->{"$TAL:define"};
20616808.26ms16801.64s defined $stuff || return $self->tal_condition($node, $xml, $end, $context);
# spent 4.77s making 1680 calls to Petal::Tiny::tal_condition, avg 2.84ms/call, recursion: max depth 4, sum of overlapping time 3.13s
207 my $newContext = { %{$context} };
208 my $define = trim ($stuff);
209 for my $def (split /;(?!;)/, $define) {
210 $def = trim($def);
211 my ($symbol, $expression) = split /\s+/, $def, 2;
212 $newContext->{$symbol} = $self->resolve_expression($expression, $newContext);
213 }
214 return $self->tal_condition($node, $xml, $end, $newContext);
215}
216
217
218
# spent 1.64s (16.4ms+1.63) within Petal::Tiny::tal_condition which was called 1680 times, avg 978µs/call: # 1680 times (16.4ms+1.63s) by Petal::Tiny::tal_define at line 206, avg 978µs/call
sub tal_condition {
2191680531µs my ($self, $node, $xml, $end, $context) = @_;
22016801.42ms my $stuff = delete $node->{"$TAL:condition"};
22116803.13ms147036.0ms defined $stuff or return $self->tal_repeat($node, $xml, $end, $context);
# spent 3.15s making 1470 calls to Petal::Tiny::tal_repeat, avg 2.14ms/call, recursion: max depth 4, sum of overlapping time 3.12s
222
223210223µs2105.00ms my $condition = trim ($stuff);
# spent 5.00ms making 210 calls to Petal::Tiny::trim, avg 24µs/call
224210292µs for my $cond (split /;(?!;)/, $condition) {
225210185µs2101.15ms $cond = trim($cond);
# spent 1.15ms making 210 calls to Petal::Tiny::trim, avg 5µs/call
226210531µs21027.8ms $self->resolve_expression($cond, $context) or return '';
# spent 27.8ms making 210 calls to Petal::Tiny::resolve_expression, avg 132µs/call
227 }
22880198µs801.57s return $self->tal_repeat($node, $xml, $end, $context);
# spent 1.57s making 80 calls to Petal::Tiny::tal_repeat, avg 19.6ms/call
229}
230
231
232
# spent 1.60s (4.79ms+1.60) within Petal::Tiny::tal_repeat which was called 1550 times, avg 1.03ms/call: # 1470 times (4.51ms+31.5ms) by Petal::Tiny::tal_condition at line 221, avg 24µs/call # 80 times (283µs+1.57s) by Petal::Tiny::tal_condition at line 228, avg 19.6ms/call
sub tal_repeat {
2331550454µs my ($self, $node, $xml, $end, $context) = @_;
23415501.02ms my $stuff = delete $node->{"$TAL:repeat"};
235155012.9ms15401.60s defined $stuff or return $self->tal_content($node, $xml, $end, $context);
# spent 4.71s making 1540 calls to Petal::Tiny::tal_content, avg 3.06ms/call, recursion: max depth 4, sum of overlapping time 3.11s
236
2371021µs my @loops = split /;/, $stuff;
238104µs my $count = 0;
2391068µs101.96ms return $self->_do_repeat(\$count, 1, \@loops, $node, $xml, $end, { %$context });
# spent 1.96ms making 10 calls to Petal::Tiny::_do_repeat, avg 196µs/call
240}
241
242
# spent 1.96ms (303µs+1.66) within Petal::Tiny::_do_repeat which was called 10 times, avg 196µs/call: # 10 times (303µs+1.66ms) by Petal::Tiny::tal_repeat at line 239, avg 196µs/call
sub _do_repeat {
243108µs my ($self, $count, $last, $loops_ref, $node, $xml, $end, $context) = @_;
244
245108µs my @loops = @$loops_ref;
246105µs my $stuff = shift @loops;
2471014µs1087µs my $repeat = trim ($stuff);
# spent 87µs making 10 calls to Petal::Tiny::trim, avg 9µs/call
2481016µs my ($symbol, $expression) = split /\s+/, $repeat, 2;
2491016µs10485µs my $array = $self->resolve_expression($expression, $context);
# spent 485µs making 10 calls to Petal::Tiny::resolve_expression, avg 48µs/call
2501010µs $array = [ $array ] unless ref $array; # we don't judge
251103µs my @result;
2521022µs foreach my $idx (0 .. $#$array) {
253106µs my $item = $array->[$idx];
2541010µs $context->{$symbol} = $item;
2551020µs if (@loops) {
256 push @result, $self->_do_repeat($count, $last && $idx == $#$array, \@loops, $node, $xml, $end, $context);
257 }
258 else {
259105µs $$count++;
2601010µs $context->{repeat} = {};
261109µs $context->{repeat}->{index} = $$count;
262107µs $context->{repeat}->{number} = $$count;
2631013µs $context->{repeat}->{even} = $$count%2 ? 0 : 1;
264107µs $context->{repeat}->{odd} = $$count%2 ? 1 : 0;
265107µs $context->{repeat}->{start} = $$count == 1 ? 1 : 0;
266109µs $context->{repeat}->{end} = $last && $idx == $#$array ? 1 : 0;
2671013µs $context->{repeat}->{inner} = $context->{repeat}->{start} || $context->{repeat}->{end} ? 0 : 1;
2681040µs101.09ms push @result, $self->tal_content({ %$node }, $xml, $end, $context);
# spent 1.09ms making 10 calls to Petal::Tiny::tal_content, avg 109µs/call
269 }
270 }
2711030µs return join '', @result;
272}
273
274
275
# spent 1.60s (14.9ms+1.59) within Petal::Tiny::tal_content which was called 1550 times, avg 1.03ms/call: # 1540 times (14.9ms+1.58s) by Petal::Tiny::tal_repeat at line 235, avg 1.04ms/call # 10 times (56µs+1.03ms) by Petal::Tiny::_do_repeat at line 268, avg 109µs/call
sub tal_content {
2761550470µs my ($self, $node, $xml, $end, $context) = @_;
27715501.52ms my $stuff = delete $node->{"$TAL:content"};
27815501.56ms6201.57s defined $stuff or return $self->tal_replace($node, $xml, $end, $context);
# spent 4.54s making 620 calls to Petal::Tiny::tal_replace, avg 7.33ms/call, recursion: max depth 4, sum of overlapping time 2.97s
279
280930982µs93079.6ms my $res = $self->resolve_expression($stuff, $context);
# spent 79.6ms making 930 calls to Petal::Tiny::resolve_expression, avg 86µs/call
281930829µs $xml = defined $res ? [ $res ] : [];
282930626µs delete $node->{_close} and $end = "</$node->{_tag}>"; # deal with self closing tags
283
284 # set the stop recurse flag so that if content contains $foo and $bar,
285 # those aren't interpolated as variables.
286930430µs local ( $STOP_RECURSE ) = ( 1 );
2879302.59ms9305.62ms return $self->tal_replace($node, $xml, $end, $context);
# spent 76.4ms making 930 calls to Petal::Tiny::tal_replace, avg 82µs/call, recursion: max depth 4, sum of overlapping time 70.8ms
288}
289
290
291
# spent 1.58s (5.28ms+1.57) within Petal::Tiny::tal_replace which was called 1550 times, avg 1.02ms/call: # 930 times (3.20ms+2.41ms) by Petal::Tiny::tal_content at line 287, avg 6µs/call # 620 times (2.07ms+1.57s) by Petal::Tiny::tal_content at line 278, avg 2.53ms/call
sub tal_replace {
2921550552µs my ($self, $node, $xml, $end, $context) = @_;
29315501.10ms my $stuff = delete $node->{"$TAL:replace"};
29415508.94ms15001.58s defined $stuff or return $self->tal_attributes($node, $xml, $end, $context);
# spent 4.61s making 1500 calls to Petal::Tiny::tal_attributes, avg 3.07ms/call, recursion: max depth 4, sum of overlapping time 3.03s
2955062µs504.19ms my $res = $self->resolve_expression($stuff, $context);
# spent 4.19ms making 50 calls to Petal::Tiny::resolve_expression, avg 84µs/call
29650106µs return defined $res ? $res : '';
297}
298
299
300
# spent 1.58s (19.5ms+1.56) within Petal::Tiny::tal_attributes which was called 1500 times, avg 1.05ms/call: # 1500 times (19.5ms+1.56s) by Petal::Tiny::tal_replace at line 294, avg 1.05ms/call
sub tal_attributes {
3011500511µs my ($self, $node, $xml, $end, $context) = @_;
30215001.41ms my $stuff = delete $node->{"$TAL:attributes"};
30315001.88ms7201.56s defined $stuff or return $self->tal_omit_tag($node, $xml, $end, $context);
# spent 1.57s making 720 calls to Petal::Tiny::tal_omit_tag, avg 2.18ms/call, recursion: max depth 4, sum of overlapping time 8.24ms
304
305780747µs78016.8ms my $attributes = trim ($stuff);
# spent 16.8ms making 780 calls to Petal::Tiny::trim, avg 21µs/call
3067801.55ms for my $att (split /;(?!;)/, $attributes) {
307980904µs98013.0ms $att = trim ($att);
# spent 13.0ms making 980 calls to Petal::Tiny::trim, avg 13µs/call
3089801.16ms my ($symbol, $expression) = split /\s+/, $att, 2;
3099805.60ms980720µs my $add = ($symbol =~ s/^\+//);
# spent 720µs making 980 calls to Petal::Tiny::CORE:subst, avg 734ns/call
3109801000µs980117ms my $new = $self->resolve_expression($expression, $context);
# spent 117ms making 980 calls to Petal::Tiny::resolve_expression, avg 120µs/call
3119801.04ms if (defined $new) {
31238087µs if ($add) {
3137039µs my $old = $node->{$symbol};
3147036µs $old = "" unless defined $old;
3157046µs $new = $old . $new;
316 }
317380338µs $node->{$symbol} = $new;
318 }
319 else {
320600197µs delete $node->{$symbol} unless $add;
321 }
322 }
3237801.98ms7803.58ms return $self->tal_omit_tag($node, $xml, $end, $context);
# spent 2.87s making 780 calls to Petal::Tiny::tal_omit_tag, avg 3.68ms/call, recursion: max depth 4, sum of overlapping time 2.87s
324}
325
326
327
# spent 1.56s (10.7ms+1.55) within Petal::Tiny::tal_omit_tag which was called 1500 times, avg 1.04ms/call: # 780 times (5.69ms+-2.12ms) by Petal::Tiny::tal_attributes at line 323, avg 5µs/call # 720 times (5.05ms+1.55s) by Petal::Tiny::tal_attributes at line 303, avg 2.17ms/call
sub tal_omit_tag {
3281500565µs my ($self, $node, $xml, $end, $context) = @_;
32915001.19ms my $stuff = delete $node->{"$TAL:omit-tag"};
3301500468µs my $omit = defined $stuff ? do { $stuff eq '' ? 1 : $self->resolve_expression($stuff, $context) } : undef;
3311500287µs $omit and not $end and return ''; # omit-tag on a self-closing tag means *poof*, nothing left
3321500465µs my @result = ();
33315001.65ms147024.7ms push @result, node2tag ($node) unless ($omit);
# spent 24.7ms making 1470 calls to Petal::Tiny::node2tag, avg 17µs/call
3341500455µs if ($end) {
33511801.16ms2500s push @result, do { $STOP_RECURSE ? join '', @{$xml} : $self->makeitso($xml, $context) };
# spent 4.41s making 250 calls to Petal::Tiny::makeitso, avg 17.6ms/call, recursion: max depth 45, sum of overlapping time 4.41s
3361180489µs push @result, $end unless ($omit);
337 }
33815003.60ms return join '', @result;
339}
340
341
342
# spent 230ms (25.7+204) within Petal::Tiny::resolve_expression which was called 2190 times, avg 105µs/call: # 980 times (9.51ms+108ms) by Petal::Tiny::tal_attributes at line 310, avg 120µs/call # 930 times (9.62ms+69.9ms) by Petal::Tiny::tal_content at line 280, avg 86µs/call # 210 times (5.72ms+22.1ms) by Petal::Tiny::tal_condition at line 226, avg 132µs/call # 50 times (561µs+3.63ms) by Petal::Tiny::tal_replace at line 295, avg 84µs/call # 10 times (116µs+543µs) by Petal::Tiny::__ANON__[/home/lbr/.plenv/versions/5.20.2/lib/perl5/site_perl/5.20.2/Petal/Tiny.pm:133] at line 129, avg 66µs/call # 10 times (122µs+363µs) by Petal::Tiny::_do_repeat at line 249, avg 48µs/call
sub resolve_expression {
3432190424µs my $self = shift;
34421901.88ms219029.3ms my $expr = trim(shift);
# spent 29.3ms making 2190 calls to Petal::Tiny::trim, avg 13µs/call
3452190592µs my $context = shift || confess "resolve_expression() : no context";
34621902.94ms2190772µs $expr =~ s/\;\;/;/g;
# spent 772µs making 2190 calls to Petal::Tiny::CORE:subst, avg 352ns/call
34721902.67ms2190584µs $expr =~ s/\$\$/\$/g;
# spent 584µs making 2190 calls to Petal::Tiny::CORE:subst, avg 267ns/call
3482190668µs $expr eq 'nothing' and return undef;
34921902.85ms2190498µs $expr =~ s/^fresh\s+//;
# spent 498µs making 2190 calls to Petal::Tiny::CORE:subst, avg 228ns/call
35021903.09ms2190576µs my $structure = ($expr =~ s/^structure\s+//);
# spent 576µs making 2190 calls to Petal::Tiny::CORE:subst, avg 263ns/call
35121902.25ms2190163ms my $resolved = $self->resolve($expr, $context);
# spent 163ms making 2190 calls to Petal::Tiny::resolve, avg 74µs/call
35221905.03ms21509.60ms return $structure ? $resolved : xmlencode($resolved);
# spent 9.60ms making 2150 calls to Petal::Tiny::xmlencode, avg 4µs/call
353}
354
355
# spent 6.65ms within Petal::Tiny::reftype which was called 8250 times, avg 805ns/call: # 4120 times (3.79ms+0s) by Petal::Tiny::resolve at line 387, avg 921ns/call # 4120 times (2.84ms+0s) by Petal::Tiny::resolve at line 407, avg 690ns/call # 10 times (6µs+0s) by Petal::Tiny::modifier_true at line 441, avg 650ns/call
sub reftype {
35682501.67ms my ($self, $obj) = @_;
357825016.8ms return ref $obj;
358}
359
360
# spent 163ms (107+56.2) within Petal::Tiny::resolve which was called 4950 times, avg 33µs/call: # 2550 times (26.9ms+-26.9ms) by Petal::Tiny::resolve at line 381, avg 0s/call # 2190 times (71.0ms+91.9ms) by Petal::Tiny::resolve_expression at line 351, avg 74µs/call # 210 times (8.81ms+-8.81ms) by Petal::Tiny::modifier_true at line 440, avg 0s/call
sub resolve {
3614950776µs my $self = shift;
36249503.33ms495040.2ms my $expr = trim(shift);
# spent 40.2ms making 4950 calls to Petal::Tiny::trim, avg 8µs/call
3634950975µs my $context = shift || confess "resolve() : no context";
364495011.4ms49501.20ms $expr =~ /:(?!pattern)/ and do {
# spent 1.20ms making 4950 calls to Petal::Tiny::CORE:match, avg 243ns/call
365210354µs my ($mod, $expr) = split /:(?!pattern)/, $expr, 2;
366210145µs my $meth = "modifier_$mod";
3672101.39ms42011.9ms $self->can("modifier_$mod") and return $self->$meth($expr, $context);
# spent 9.02ms making 130 calls to Petal::Tiny::modifier_true, avg 69µs/call # spent 2.50ms making 80 calls to Petal::Tiny::modifier_false, avg 31µs/call # spent 371µs making 210 calls to UNIVERSAL::can, avg 2µs/call
368 confess "unknown modifier $mod";
369 };
37047406.12ms47401.46ms $expr =~ /^--/ and do {
# spent 1.46ms making 4740 calls to Petal::Tiny::CORE:match, avg 308ns/call
371253012.5ms25302.44ms $expr =~ s/^--//;
# spent 2.44ms making 2530 calls to Petal::Tiny::CORE:subst, avg 966ns/call
372253011.9ms return $expr;
373 };
37422107.93ms2210588µs $expr =~ s/\r/ /g;
# spent 588µs making 2210 calls to Petal::Tiny::CORE:subst, avg 266ns/call
37522103.39ms my ($what, @args) = split /\s+/, $expr;
3762210362µs defined $what or return;
377
37822102.42ms my (@path) = split /\//, $what;
3792210565µs my @resolved = ();
3802210520µs my $obj = $context;
38147605.62ms25500s @args = map { $self->resolve($_, $context) } @args;
# spent 53.8ms making 2550 calls to Petal::Tiny::resolve, avg 21µs/call, recursion: max depth 1, sum of overlapping time 53.8ms
3822210945µs while (@path) {
38341201.03ms my $attribute_or_method = shift @path;
38441201.17ms push @resolved, $attribute_or_method;
38541201.99ms my $resolved = join '/', @resolved;
3864120698µs $obj or confess "cannot fetch $what, because $resolved is undefined";
38741203.25ms41203.79ms my $reftype = $self->reftype($obj);
# spent 3.79ms making 4120 calls to Petal::Tiny::reftype, avg 921ns/call
3884120564µs $reftype or confess "cannot fetch $what, because $resolved is not a reference";
389
39041203.37ms if ($reftype eq 'ARRAY') {
391 $obj = $obj->[$attribute_or_method];
392 }
393 elsif ($reftype eq 'HASH') {
394 $obj = $obj->{$attribute_or_method};
395 }
396 elsif ($obj->can($attribute_or_method)) {
397 if (@path) {
398 $obj = $obj->$attribute_or_method();
399 }
400 else {
401 $obj = $obj->$attribute_or_method(@args);
402 @args = ();
403 }
404 }
405
406 # now, check if what we found was a code-ref
40741202.68ms41202.84ms $reftype = $self->reftype($obj);
# spent 2.84ms making 4120 calls to Petal::Tiny::reftype, avg 690ns/call
40841201.24ms if ($reftype eq 'CODE') {
4091880676µs if (@path) {
410 $obj = $obj->();
411 }
412 else {
41318802.39ms18802.34ms $obj = $obj->(@args);
# spent 914µs making 570 calls to main::__ANON__[opt.pl:19], avg 2µs/call # spent 410µs making 450 calls to main::__ANON__[opt.pl:17], avg 911ns/call # spent 395µs making 370 calls to main::__ANON__[opt.pl:18], avg 1µs/call # spent 215µs making 180 calls to main::__ANON__[opt.pl:16], avg 1µs/call # spent 87µs making 60 calls to main::__ANON__[opt.pl:13], avg 1µs/call # spent 76µs making 80 calls to main::__ANON__[opt.pl:14], avg 952ns/call # spent 74µs making 50 calls to main::__ANON__[opt.pl:12], avg 1µs/call # spent 52µs making 40 calls to main::__ANON__[opt.pl:15], avg 1µs/call # spent 44µs making 30 calls to main::__ANON__[opt.pl:11], avg 1µs/call # spent 28µs making 20 calls to main::__ANON__[opt.pl:10], avg 1µs/call # spent 17µs making 10 calls to main::__ANON__[opt.pl:8], avg 2µs/call # spent 17µs making 10 calls to main::__ANON__[opt.pl:9], avg 2µs/call # spent 15µs making 10 calls to main::__ANON__[opt.pl:25], avg 1µs/call
4141880912µs @args = ();
415 }
416 }
417
418 # if we're done with @path and there's a single arg, use it to look up in array/hash
41941201.49ms if (not @path and @args == 1) {
420 $reftype = $self->reftype($obj);
421
422 if ($reftype eq 'ARRAY') {
423 $obj = $obj->[ $args[0] ];
424 last;
425 }
426 elsif ($reftype eq 'HASH') {
427 $obj = $obj->{ $args[0] };
428 last;
429 }
430 }
431
43241202.55ms not @path and @args and confess "cannot resolve expression $expr";
433 }
43422103.86ms return $obj;
435}
436
437
438
# spent 11.2ms (723µs+10.5) within Petal::Tiny::modifier_true which was called 210 times, avg 54µs/call: # 130 times (456µs+8.57ms) by Petal::Tiny::resolve at line 367, avg 69µs/call # 80 times (267µs+1.95ms) by Petal::Tiny::modifier_false at line 448, avg 28µs/call
sub modifier_true {
43921046µs my $self = shift;
440210225µs2100s my $arg = $self->resolve(shift(), shift());
# spent 10.5ms making 210 calls to Petal::Tiny::resolve, avg 50µs/call, recursion: max depth 1, sum of overlapping time 10.5ms
44121074µs106µs ref $arg and $self->reftype($arg) eq 'ARRAY' and return @{$arg};
# spent 6µs making 10 calls to Petal::Tiny::reftype, avg 650ns/call
442200319µs return $arg ? 1 : 0;
443}
444
445
446
# spent 2.50ms (285µs+2.22) within Petal::Tiny::modifier_false which was called 80 times, avg 31µs/call: # 80 times (285µs+2.22ms) by Petal::Tiny::resolve at line 367, avg 31µs/call
sub modifier_false {
4478024µs my $self = shift;
44880250µs802.22ms return not $self->modifier_true(@_);
# spent 2.22ms making 80 calls to Petal::Tiny::modifier_true, avg 28µs/call
449}
450
451
452sub modifier_string {
453 my $self = shift;
454 my $string = shift;
455 my $context = shift;
456 $string = $self->_interpolate_dollar($context, $string, 'resolve');
457 return $string;
458}
459
460
461
# spent 25.5ms (22.6+2.88) within Petal::Tiny::node2tag which was called 1520 times, avg 17µs/call: # 1470 times (21.9ms+2.80ms) by Petal::Tiny::tal_omit_tag at line 333, avg 17µs/call # 50 times (727µs+89µs) by Petal::Tiny::makeitso_block at line 175, avg 16µs/call
sub node2tag {
4621520293µs my $node = shift;
4631520872µs my $tag = delete $node->{_tag};
464582014.9ms86002.88ms for (keys %{$node}) { /^($TAL:)/ and delete $node->{$_} }
# spent 2.17ms making 4300 calls to Petal::Tiny::CORE:regcomp, avg 505ns/call # spent 714µs making 4300 calls to Petal::Tiny::CORE:match, avg 166ns/call
4651520888µs my $open = delete $node->{_open} || 0;
4661520658µs my $close = delete $node->{_close} || 0;
46715204.56ms my $att = join ' ', map { qq|$_="$node->{$_}"| } keys %{$node};
46815201.23ms $open and $close and return $att ? "<$tag $att />" : "<$tag />";
4691200200µs $close and return "</$tag>";
47012003.00ms $open and return $att ? "<$tag $att>" : "<$tag>";
471 die "There is probably a bug somewhere. A tag that's not and open tag and not a close tag?";
472}
473
474
475
# spent 105ms (90.1+15.4) within Petal::Tiny::trim which was called 9330 times, avg 11µs/call: # 4950 times (33.9ms+6.27ms) by Petal::Tiny::resolve at line 362, avg 8µs/call # 2190 times (25.3ms+4.05ms) by Petal::Tiny::resolve_expression at line 344, avg 13µs/call # 980 times (10.9ms+2.07ms) by Petal::Tiny::tal_attributes at line 307, avg 13µs/call # 780 times (14.3ms+2.44ms) by Petal::Tiny::tal_attributes at line 305, avg 21µs/call # 210 times (4.66ms+341µs) by Petal::Tiny::tal_condition at line 223, avg 24µs/call # 210 times (965µs+181µs) by Petal::Tiny::tal_condition at line 225, avg 5µs/call # 10 times (61µs+25µs) by Petal::Tiny::_do_repeat at line 247, avg 9µs/call
sub trim {
47693301.75ms my $string = shift;
47793301.09ms $string or return $string;
478933024.3ms93302.93ms $string =~ s/\r//g;
# spent 2.93ms making 9330 calls to Petal::Tiny::CORE:subst, avg 314ns/call
479933028.8ms93302.38ms $string =~ s/\n/ /g;
# spent 2.38ms making 9330 calls to Petal::Tiny::CORE:subst, avg 255ns/call
480933016.1ms93303.94ms $string =~ s/^\s+//;
# spent 3.94ms making 9330 calls to Petal::Tiny::CORE:subst, avg 422ns/call
481933027.5ms93306.14ms $string =~ s/\s+$//;
# spent 6.14ms making 9330 calls to Petal::Tiny::CORE:subst, avg 658ns/call
482933011.5ms return $string;
483}
484
485
486
# spent 54.9ms (46.0+8.88) within Petal::Tiny::has_instructions which was called 3070 times, avg 18µs/call: # 3070 times (46.0ms+8.88ms) by Petal::Tiny::makeitso_block at line 170, avg 18µs/call
sub has_instructions {
4873070527µs my $node = shift;
488307061.8ms289408.88ms return grep /^$TAL:/, keys %{$node};
# spent 6.33ms making 14470 calls to Petal::Tiny::CORE:regcomp, avg 437ns/call # spent 2.56ms making 14470 calls to Petal::Tiny::CORE:match, avg 177ns/call
489}
490
491
492
# spent 1.58s (889ms+690ms) within Petal::Tiny::tag_open which was called 87930 times, avg 18µs/call: # 78680 times (760ms+529ms) by Petal::Tiny::makeitso at line 104, avg 16µs/call # 6180 times (76.9ms+84.0ms) by Petal::Tiny::makeitso at line 97, avg 26µs/call # 3070 times (52.6ms+77.7ms) by Petal::Tiny::makeitso_block at line 167, avg 42µs/call
sub tag_open {
4938793013.8ms my $elem = shift;
494879309.32ms my $node = undef;
4958793010.4ms not defined $elem and confess ('undefined elem');
496
497 $elem !~ /^<\!/ and
498 $elem !~ /^<\// and
499 $elem !~ /\/>$/ and
500 $elem !~ /^<\?/ and
50187930728ms36741053.5ms $elem =~ /^</ and do {
# spent 53.5ms making 367410 calls to Petal::Tiny::CORE:match, avg 146ns/call
5022177029.8ms21770623ms my %node = extract_attributes ($elem);
# spent 623ms making 21770 calls to Petal::Tiny::extract_attributes, avg 29µs/call
5032177065.8ms2177014.0ms ($node{_tag}) = $elem =~ /.*?([A-Za-z0-9][A-Za-z0-9_:-]*)/;
# spent 14.0ms making 21770 calls to Petal::Tiny::CORE:match, avg 644ns/call
504217705.15ms $node{_open} = 1;
505217704.56ms $node{_close} = 0;
506217707.96ms $node = \%node;
507 };
50887930185ms return $node;
509}
510
511
512
# spent 548ms (512+36.0) within Petal::Tiny::tag_close which was called 82550 times, avg 7µs/call: # 78680 times (485ms+35.1ms) by Petal::Tiny::makeitso at line 105, avg 7µs/call # 3870 times (27.0ms+877µs) by Petal::Tiny::makeitso at line 111, avg 7µs/call
sub tag_close {
5138255012.7ms my $elem = shift;
514825508.83ms my $node = undef;
515 $elem !~ /^<\!/ and
516 $elem =~ /^<\// and
51782550418ms18422024.1ms $elem !~ /\/>$/ and do {
# spent 24.1ms making 184220 calls to Petal::Tiny::CORE:match, avg 131ns/call
518194604.85ms my %node = ();
5191946050.1ms1946011.8ms ($node{_tag}) = $elem =~ /.*?([A-Za-z0-9][A-Za-z0-9_:-]*)/;
# spent 11.8ms making 19460 calls to Petal::Tiny::CORE:match, avg 607ns/call
520194604.29ms $node{_open} = 0;
521194603.75ms $node{_close} = 1;
522194605.56ms $node = \%node;
523 };
52482550175ms return $node;
525}
526
527
528
# spent 151ms (82.3+68.7) within Petal::Tiny::tag_self_close which was called 7700 times, avg 20µs/call: # 6940 times (74.9ms+40.6ms) by Petal::Tiny::makeitso at line 92, avg 17µs/call # 760 times (7.37ms+28.1ms) by Petal::Tiny::makeitso_block at line 167, avg 47µs/call
sub tag_self_close {
52977001.51ms my $elem = shift;
53077001.05ms my $node = undef;
531 $elem !~ /^<\!/ and
532 $elem !~ /^<\// and
533 $elem =~ /\/>$/ and
534770071.3ms244004.96ms $elem =~ /^</ and do {
# spent 4.96ms making 24400 calls to Petal::Tiny::CORE:match, avg 203ns/call
53515202.70ms152062.3ms my %node = extract_attributes ($elem);
# spent 62.3ms making 1520 calls to Petal::Tiny::extract_attributes, avg 41µs/call
53615204.16ms15201.43ms ($node{_tag}) = $elem =~ /.*?([A-Za-z0-9][A-Za-z0-9_:-]*)/;
# spent 1.43ms making 1520 calls to Petal::Tiny::CORE:match, avg 942ns/call
5371520599µs $node{_open} = 1;
5381520465µs $node{_close} = 1;
5391520723µs $node = \%node;
540 };
541770027.3ms return $node;
542}
543
544
545
# spent 685ms (448+237) within Petal::Tiny::extract_attributes which was called 23290 times, avg 29µs/call: # 21770 times (409ms+214ms) by Petal::Tiny::tag_open at line 502, avg 29µs/call # 1520 times (39.1ms+23.2ms) by Petal::Tiny::tag_self_close at line 535, avg 41µs/call
sub extract_attributes {
546232903.78ms my $tag = shift;
54723290185ms4658087.0ms my ($tags) = $tag =~ /$RE_1/g;
# spent 71.0ms making 23290 calls to Petal::Tiny::CORE:match, avg 3µs/call # spent 16.0ms making 23290 calls to Petal::Tiny::CORE:regcomp, avg 686ns/call
54823290185ms4658085.8ms my %attr = $tag =~ /$RE_2/g;
# spent 70.2ms making 23290 calls to Petal::Tiny::CORE:match, avg 3µs/call # spent 15.5ms making 23290 calls to Petal::Tiny::CORE:regcomp, avg 667ns/call
5492329020.5ms foreach my $key (keys %attr)
550 {
5513573013.5ms my $val = $attr{$key};
55235730110ms3573033.5ms $val =~ s/^(\"|\')//;
# spent 33.5ms making 35730 calls to Petal::Tiny::CORE:subst, avg 938ns/call
55335730109ms3573030.6ms $val =~ s/(\"|\')$//;
# spent 30.6ms making 35730 calls to Petal::Tiny::CORE:subst, avg 856ns/call
5543573029.5ms $attr{$key} = $val;
555 }
556
5572329065.6ms %attr;
558}
559
560
561
# spent 9.60ms (8.28+1.32) within Petal::Tiny::xmlencode which was called 2150 times, avg 4µs/call: # 2150 times (8.28ms+1.32ms) by Petal::Tiny::resolve_expression at line 352, avg 4µs/call
sub xmlencode {
5622150486µs my $string = shift;
56321505.34ms return $string if !$string or ref $string;
56411201.53ms1120339µs $string =~ s/&/&amp;/g;
# spent 339µs making 1120 calls to Petal::Tiny::CORE:subst, avg 303ns/call
56511201.39ms1120257µs $string =~ s/</&lt;/g;
# spent 257µs making 1120 calls to Petal::Tiny::CORE:subst, avg 230ns/call
56611201.39ms1120248µs $string =~ s/>/&gt;/g;
# spent 248µs making 1120 calls to Petal::Tiny::CORE:subst, avg 222ns/call
56711201.29ms1120240µs $string =~ s/"/&quot;/g;
# spent 240µs making 1120 calls to Petal::Tiny::CORE:subst, avg 215ns/call
56811201.31ms1120233µs $string =~ s/'/&apos;/g;
# spent 233µs making 1120 calls to Petal::Tiny::CORE:subst, avg 208ns/call
56911201.46ms return $string;
570}
571
572
573114µs1;
574
575
576__END__
 
# spent 275ms within Petal::Tiny::CORE:match which was called 712230 times, avg 386ns/call: # 367410 times (53.5ms+0s) by Petal::Tiny::tag_open at line 501, avg 146ns/call # 184220 times (24.1ms+0s) by Petal::Tiny::tag_close at line 517, avg 131ns/call # 24400 times (4.96ms+0s) by Petal::Tiny::tag_self_close at line 534, avg 203ns/call # 23290 times (71.0ms+0s) by Petal::Tiny::extract_attributes at line 547, avg 3µs/call # 23290 times (70.2ms+0s) by Petal::Tiny::extract_attributes at line 548, avg 3µs/call # 21770 times (14.0ms+0s) by Petal::Tiny::tag_open at line 503, avg 644ns/call # 19460 times (11.8ms+0s) by Petal::Tiny::tag_close at line 519, avg 607ns/call # 14470 times (2.56ms+0s) by Petal::Tiny::has_instructions at line 488, avg 177ns/call # 14440 times (1.49ms+0s) by Petal::Tiny::namespace at line 148, avg 103ns/call # 4950 times (1.20ms+0s) by Petal::Tiny::resolve at line 364, avg 243ns/call # 4740 times (1.46ms+0s) by Petal::Tiny::resolve at line 370, avg 308ns/call # 4300 times (714µs+0s) by Petal::Tiny::node2tag at line 464, avg 166ns/call # 3870 times (795µs+0s) by Petal::Tiny::_interpolate_dollar at line 135, avg 205ns/call # 1520 times (1.43ms+0s) by Petal::Tiny::tag_self_close at line 536, avg 942ns/call # 50 times (15.2ms+0s) by Petal::Tiny::makeitso at line 85, avg 303µs/call # 50 times (152µs+0s) by Petal::Tiny::new at line 60, avg 3µs/call
sub Petal::Tiny::CORE:match; # opcode
# spent 3µs within Petal::Tiny::CORE:qr which was called 2 times, avg 1µs/call: # once (2µs+0s) by main::BEGIN@2 at line 44 # once (800ns+0s) by main::BEGIN@2 at line 45
sub Petal::Tiny::CORE:qr; # opcode
# spent 40.3ms within Petal::Tiny::CORE:regcomp which was called 65402 times, avg 617ns/call: # 23290 times (16.0ms+0s) by Petal::Tiny::extract_attributes at line 547, avg 686ns/call # 23290 times (15.5ms+0s) by Petal::Tiny::extract_attributes at line 548, avg 667ns/call # 14470 times (6.33ms+0s) by Petal::Tiny::has_instructions at line 488, avg 437ns/call # 4300 times (2.17ms+0s) by Petal::Tiny::node2tag at line 464, avg 505ns/call # 50 times (233µs+0s) by Petal::Tiny::makeitso at line 85, avg 5µs/call # once (47µs+0s) by main::BEGIN@2 at line 44 # once (25µs+0s) by main::BEGIN@2 at line 45
sub Petal::Tiny::CORE:regcomp; # opcode
# spent 87.1ms within Petal::Tiny::CORE:subst which was called 128940 times, avg 675ns/call: # 35730 times (33.5ms+0s) by Petal::Tiny::extract_attributes at line 552, avg 938ns/call # 35730 times (30.6ms+0s) by Petal::Tiny::extract_attributes at line 553, avg 856ns/call # 9330 times (6.14ms+0s) by Petal::Tiny::trim at line 481, avg 658ns/call # 9330 times (3.94ms+0s) by Petal::Tiny::trim at line 480, avg 422ns/call # 9330 times (2.93ms+0s) by Petal::Tiny::trim at line 478, avg 314ns/call # 9330 times (2.38ms+0s) by Petal::Tiny::trim at line 479, avg 255ns/call # 2530 times (2.44ms+0s) by Petal::Tiny::resolve at line 371, avg 966ns/call # 2210 times (588µs+0s) by Petal::Tiny::resolve at line 374, avg 266ns/call # 2190 times (772µs+0s) by Petal::Tiny::resolve_expression at line 346, avg 352ns/call # 2190 times (584µs+0s) by Petal::Tiny::resolve_expression at line 347, avg 267ns/call # 2190 times (576µs+0s) by Petal::Tiny::resolve_expression at line 350, avg 263ns/call # 2190 times (498µs+0s) by Petal::Tiny::resolve_expression at line 349, avg 228ns/call # 1120 times (339µs+0s) by Petal::Tiny::xmlencode at line 564, avg 303ns/call # 1120 times (257µs+0s) by Petal::Tiny::xmlencode at line 565, avg 230ns/call # 1120 times (248µs+0s) by Petal::Tiny::xmlencode at line 566, avg 222ns/call # 1120 times (240µs+0s) by Petal::Tiny::xmlencode at line 567, avg 215ns/call # 1120 times (233µs+0s) by Petal::Tiny::xmlencode at line 568, avg 208ns/call # 980 times (720µs+0s) by Petal::Tiny::tal_attributes at line 309, avg 734ns/call # 50 times (56µs+0s) by Petal::Tiny::namespace at line 152, avg 1µs/call # 10 times (39µs+0s) by Petal::Tiny::_interpolate_dollar at line 136, avg 4µs/call # 10 times (3µs+0s) by Petal::Tiny::_interpolate_dollar at line 137, avg 330ns/call # 10 times (2µs+0s) by Petal::Tiny::_interpolate_dollar at line 138, avg 180ns/call
sub Petal::Tiny::CORE:subst; # opcode
# spent 18µs within Petal::Tiny::CORE:substcont which was called 20 times, avg 925ns/call: # 20 times (18µs+0s) by Petal::Tiny::_interpolate_dollar at line 136, avg 925ns/call
sub Petal::Tiny::CORE:substcont; # opcode