← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:15 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Infix/Node.pm
StatementsExecuted 2102 statements in 3.12ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.80ms3.08msFoswiki::Infix::Node::::BEGIN@131Foswiki::Infix::Node::BEGIN@131
259221.19ms1.19msFoswiki::Infix::Node::::newNodeFoswiki::Infix::Node::newNode
14721735µs1.54msFoswiki::Infix::Node::::newLeafFoswiki::Infix::Node::newLeaf
8011282µs282µsFoswiki::Infix::Node::::convertToLeafFoswiki::Infix::Node::convertToLeaf
11113µs25µsFoswiki::Infix::Node::::BEGIN@14Foswiki::Infix::Node::BEGIN@14
11111µs69µsFoswiki::Infix::Node::::BEGIN@29Foswiki::Infix::Node::BEGIN@29
1119µs13µsFoswiki::Infix::Node::::BEGIN@15Foswiki::Infix::Node::BEGIN@15
1119µs31µsFoswiki::Infix::Node::::BEGIN@16Foswiki::Infix::Node::BEGIN@16
1119µs42µsFoswiki::Infix::Node::::BEGIN@26Foswiki::Infix::Node::BEGIN@26
1114µs4µsFoswiki::Infix::Node::::BEGIN@18Foswiki::Infix::Node::BEGIN@18
0000s0sFoswiki::Infix::Node::::isLeafFoswiki::Infix::Node::isLeaf
0000s0sFoswiki::Infix::Node::::stringifyFoswiki::Infix::Node::stringify
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2
3=begin TML
4
5---+ package Foswiki::Infix::Node
6
7Base class for node types generated by Infix::Parser (and its subclasses). This
8defines the interface used to construct nodes from the parser.
9
10=cut
11
12package Foswiki::Infix::Node;
13
14236µs237µs
# spent 25µs (13+12) within Foswiki::Infix::Node::BEGIN@14 which was called: # once (13µs+12µs) by Foswiki::Infix::Parser::BEGIN@26 at line 14
use strict;
# spent 25µs making 1 call to Foswiki::Infix::Node::BEGIN@14 # spent 12µs making 1 call to strict::import
15225µs217µs
# spent 13µs (9+4) within Foswiki::Infix::Node::BEGIN@15 which was called: # once (9µs+4µs) by Foswiki::Infix::Parser::BEGIN@26 at line 15
use warnings;
# spent 13µs making 1 call to Foswiki::Infix::Node::BEGIN@15 # spent 4µs making 1 call to warnings::import
16243µs254µs
# spent 31µs (9+22) within Foswiki::Infix::Node::BEGIN@16 which was called: # once (9µs+22µs) by Foswiki::Infix::Parser::BEGIN@26 at line 16
use Assert;
# spent 31µs making 1 call to Foswiki::Infix::Node::BEGIN@16 # spent 22µs making 1 call to Exporter::import
17
18
# spent 4µs within Foswiki::Infix::Node::BEGIN@18 which was called: # once (4µs+0s) by Foswiki::Infix::Parser::BEGIN@26 at line 23
BEGIN {
1919µs if ( $Foswiki::cfg{UseLocale} ) {
20 require locale;
21 import locale();
22 }
23121µs14µs}
# spent 4µs making 1 call to Foswiki::Infix::Node::BEGIN@18
24
25# 1 for debug
26241µs276µs
# spent 42µs (9+34) within Foswiki::Infix::Node::BEGIN@26 which was called: # once (9µs+34µs) by Foswiki::Infix::Parser::BEGIN@26 at line 26
use constant MONITOR => 0;
# spent 42µs making 1 call to Foswiki::Infix::Node::BEGIN@26 # spent 34µs making 1 call to constant::import
27
28# Leaf token types
29
# spent 69µs (11+58) within Foswiki::Infix::Node::BEGIN@29 which was called: # once (11µs+58µs) by Foswiki::Infix::Parser::BEGIN@26 at line 35
use constant {
3018µs158µs NAME => 1,
# spent 58µs making 1 call to constant::import
31 NUMBER => 2,
32 STRING => 3,
33 HASH => 4,
34 META => 5,
351320µs169µs};
# spent 69µs making 1 call to Foswiki::Infix::Node::BEGIN@29
36
37=begin TML
38
39---++ ClassMethod newNode( $o, @p ) -> \$if
40
41Construct a new parse node (contract with Infix::Parser)
42
43=cut
44
45
# spent 1.19ms within Foswiki::Infix::Node::newNode which was called 259 times, avg 5µs/call: # 147 times (802µs+0s) by Foswiki::Infix::Node::newLeaf at line 66, avg 5µs/call # 112 times (390µs+0s) by Foswiki::Infix::Parser::_apply at line 363 of /var/www/foswikidev/core/lib/Foswiki/Infix/Parser.pm, avg 3µs/call
sub newNode {
4625977µs my $class = shift;
4725948µs my $op = shift;
48259277µs my $this = bless( {}, $class );
49259351µs @{ $this->{params} } = @_;
50259112µs $this->{op} = $op;
51259702µs return $this;
52}
53
54=begin TML
55
56---++ ClassMethod newLeaf( $val, $type ) -> \$if
57
58Construct a new terminal node (contract with Infix::Parser)
59 * =$val= - the (scalar) value of the leaf
60 * =$type= - one of NAME, NUMBER, STRING
61
62=cut
63
64
# spent 1.54ms (735µs+802µs) within Foswiki::Infix::Node::newLeaf which was called 147 times, avg 10µs/call: # 144 times (719µs+787µs) by Foswiki::Query::Node::newLeaf at line 141 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm, avg 10µs/call # 3 times (16µs+16µs) by Foswiki::Query::Node::newLeaf at line 138 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm, avg 10µs/call
sub newLeaf {
65147105µs my ( $class, $val, $type ) = @_;
66147432µs147802µs return newNode( $class, $type, $val );
# spent 802µs making 147 calls to Foswiki::Infix::Node::newNode, avg 5µs/call
67}
68
69=begin TML
70
71---++ ObjectMethod convertToLeaf( $type, $val )
72
73Convert the node into a terminal node.
74 * =$type= - one of NAME, NUMBER, STRING
75 * =$val= - the (scalar) value of the leaf
76
77Not used by the Foswiki::Infix::Parser.
78
79=cut
80
81
# spent 282µs within Foswiki::Infix::Node::convertToLeaf which was called 80 times, avg 4µs/call: # 80 times (282µs+0s) by Foswiki::Query::Node::_freeze at line 379 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm, avg 4µs/call
sub convertToLeaf {
828070µs my ( $this, $type, $val ) = @_;
838035µs $this->{op} = $type;
8480235µs $this->{params} = [$val];
85}
86
87=begin TML
88
89---++ ObjectMethod isLeaf() -> $boolean
90
91Return true if this node was created by =newLeaf()= (or converted by =convertToLeaf=)
92
93=cut
94
95sub isLeaf {
96 my $this = shift;
97 return !ref( $this->{op} );
98}
99
100=begin TML
101
102---++ ObjectMethod stringify() -> $string
103
104Generate a string representation of the subtree, for reporting. The representation
105generated by this function should be parseable, but is not guaranteed to be.
106
107=cut
108
109sub stringify {
110 my $this = shift;
111
112 unless ( ref( $this->{op} ) ) {
113 if ( $this->{op} == STRING ) {
114 ASSERT( ref( $this->{params}[0] ) eq '' ) if DEBUG;
115 return "'$this->{params}[0]'";
116 }
117 else {
118 if ( ref( $this->{params}[0] ) eq 'HASH' ) {
119 return join( ',',
120 map { $_ . "=>'" . $this->{params}[0]->{$_} . "'" }
121 sort keys( %{ $this->{params}[0] } ) );
122 }
123 if ( ref( $this->{params}[0] ) eq 'Foswiki::Meta' ) {
124 return $this->{params}[0]->web . '.'
125 . $this->{params}[0]->topic;
126 }
127 return $this->{params}[0];
128 }
129 }
130 if ( $this->{op}->{arity} ) {
1312168µs13.08ms
# spent 3.08ms (1.80+1.28) within Foswiki::Infix::Node::BEGIN@131 which was called: # once (1.80ms+1.28ms) by Foswiki::Infix::Parser::BEGIN@26 at line 131
use Foswiki::Query::Node;
# spent 3.08ms making 1 call to Foswiki::Infix::Node::BEGIN@131
132 return
133 $this->{op}->{name} . '{'
134 . join( ',', map { stringify($_) } @{ $this->{params} } ) . '}';
135 }
136 else {
137 $this->{op}->{name};
138 }
139}
140
14112µs1;
142__END__