← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:35 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Infix/Node.pm
StatementsExecuted 1782 statements in 6.77ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
219224.10ms4.10msFoswiki::Infix::Node::::newNodeFoswiki::Infix::Node::newNode
1113.26ms5.77msFoswiki::Infix::Node::::BEGIN@124Foswiki::Infix::Node::BEGIN@124
115211.41ms3.70msFoswiki::Infix::Node::::newLeafFoswiki::Infix::Node::newLeaf
11127µs35µsFoswiki::Infix::Node::::BEGIN@14Foswiki::Infix::Node::BEGIN@14
11125µs318µsFoswiki::Infix::Node::::BEGIN@22Foswiki::Infix::Node::BEGIN@22
21122µs22µsFoswiki::Infix::Node::::convertToLeafFoswiki::Infix::Node::convertToLeaf
11120µs138µsFoswiki::Infix::Node::::BEGIN@19Foswiki::Infix::Node::BEGIN@19
11116µs59µsFoswiki::Infix::Node::::BEGIN@16Foswiki::Infix::Node::BEGIN@16
11116µs33µsFoswiki::Infix::Node::::BEGIN@15Foswiki::Infix::Node::BEGIN@15
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
14244µs242µs
# spent 35µs (27+7) within Foswiki::Infix::Node::BEGIN@14 which was called: # once (27µs+7µs) by Foswiki::Infix::Parser::BEGIN@26 at line 14
use strict;
# spent 35µs making 1 call to Foswiki::Infix::Node::BEGIN@14 # spent 7µs making 1 call to strict::import
15241µs250µs
# spent 33µs (16+17) within Foswiki::Infix::Node::BEGIN@15 which was called: # once (16µs+17µs) by Foswiki::Infix::Parser::BEGIN@26 at line 15
use warnings;
# spent 33µs making 1 call to Foswiki::Infix::Node::BEGIN@15 # spent 17µs making 1 call to warnings::import
16249µs2102µs
# spent 59µs (16+43) within Foswiki::Infix::Node::BEGIN@16 which was called: # once (16µs+43µs) by Foswiki::Infix::Parser::BEGIN@26 at line 16
use Assert;
# spent 59µs making 1 call to Foswiki::Infix::Node::BEGIN@16 # spent 43µs making 1 call to Assert::import
17
18# 1 for debug
19267µs2256µs
# spent 138µs (20+118) within Foswiki::Infix::Node::BEGIN@19 which was called: # once (20µs+118µs) by Foswiki::Infix::Parser::BEGIN@26 at line 19
use constant MONITOR => 0;
# spent 138µs making 1 call to Foswiki::Infix::Node::BEGIN@19 # spent 118µs making 1 call to constant::import
20
21# Leaf token types
22
# spent 318µs (25+292) within Foswiki::Infix::Node::BEGIN@22 which was called: # once (25µs+292µs) by Foswiki::Infix::Parser::BEGIN@26 at line 28
use constant {
231292µs NAME => 1,
# spent 292µs making 1 call to constant::import
24 NUMBER => 2,
25 STRING => 3,
26 HASH => 4,
27 META => 5,
282565µs1318µs};
# spent 318µs making 1 call to Foswiki::Infix::Node::BEGIN@22
29
30=begin TML
31
32---++ ClassMethod newNode( $o, @p ) -> \$if
33
34Construct a new parse node (contract with Infix::Parser)
35
36=cut
37
38
# spent 4.10ms within Foswiki::Infix::Node::newNode which was called 219 times, avg 19µs/call: # 115 times (2.30ms+0s) by Foswiki::Infix::Node::newLeaf at line 59, avg 20µs/call # 104 times (1.81ms+0s) by Foswiki::Infix::Parser::_apply at line 350 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Infix/Parser.pm, avg 17µs/call
sub newNode {
3915334.53ms my $class = shift;
40 my $op = shift;
41 my $this = bless( {}, $class );
42 @{ $this->{params} } = @_;
43 $this->{op} = $op;
44 return $this;
45}
46
47=begin TML
48
49---++ ClassMethod newLeaf( $val, $type ) -> \$if
50
51Construct a new terminal node (contract with Infix::Parser)
52 * =$val= - the (scalar) value of the leaf
53 * =$type= - one of NAME, NUMBER, STRING
54
55=cut
56
57
# spent 3.70ms (1.41+2.30) within Foswiki::Infix::Node::newLeaf which was called 115 times, avg 32µs/call: # 114 times (1.39ms+2.27ms) by Foswiki::Query::Node::newLeaf at line 141 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Node.pm, avg 32µs/call # once (17µs+25µs) by Foswiki::Query::Node::newLeaf at line 138 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Node.pm
sub newLeaf {
582301.17ms my ( $class, $val, $type ) = @_;
591152.30ms return newNode( $class, $type, $val );
# spent 2.30ms making 115 calls to Foswiki::Infix::Node::newNode, avg 20µs/call
60}
61
62=begin TML
63
64---++ ObjectMethod convertToLeaf( $type, $val )
65
66Convert the node into a terminal node.
67 * =$type= - one of NAME, NUMBER, STRING
68 * =$val= - the (scalar) value of the leaf
69
70Not used by the Foswiki::Infix::Parser.
71
72=cut
73
74
# spent 22µs within Foswiki::Infix::Node::convertToLeaf which was called 2 times, avg 11µs/call: # 2 times (22µs+0s) by Foswiki::Query::Node::_freeze at line 374 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Node.pm, avg 11µs/call
sub convertToLeaf {
75625µs my ( $this, $type, $val ) = @_;
76 $this->{op} = $type;
77 $this->{params} = [$val];
78}
79
80=begin TML
81
82---++ ObjectMethod isLeaf() -> $boolean
83
84Return true if this node was created by =newLeaf()= (or converted by =convertToLeaf=)
85
86=cut
87
88sub isLeaf {
89 my $this = shift;
90 return !ref( $this->{op} );
91}
92
93=begin TML
94
95---++ ObjectMethod stringify() -> $string
96
97Generate a string representation of the subtree, for reporting. The representation
98generated by this function should be parseable, but is not guaranteed to be.
99
100=cut
101
102sub stringify {
103 my $this = shift;
104
105 unless ( ref( $this->{op} ) ) {
106 if ( $this->{op} == STRING ) {
107 ASSERT( ref( $this->{params}[0] ) eq '' ) if DEBUG;
108 return "'$this->{params}[0]'";
109 }
110 else {
111 if ( ref( $this->{params}[0] ) eq 'HASH' ) {
112 return join( ',',
113 map { $_ . '=>' . $this->{params}[0]->{$_} }
114 keys( %{ $this->{params}[0] } ) );
115 }
116 if ( ref( $this->{params}[0] ) eq 'Foswiki::Meta' ) {
117 return $this->{params}[0]->web . '.'
118 . $this->{params}[0]->topic;
119 }
120 return $this->{params}[0];
121 }
122 }
123 if ( $this->{op}->{arity} ) {
1242279µs15.77ms
# spent 5.77ms (3.26+2.51) within Foswiki::Infix::Node::BEGIN@124 which was called: # once (3.26ms+2.51ms) by Foswiki::Infix::Parser::BEGIN@26 at line 124
use Foswiki::Query::Node;
# spent 5.77ms making 1 call to Foswiki::Infix::Node::BEGIN@124
125 return
126 $this->{op}->{name} . '{'
127 . join( ',', map { stringify($_) } @{ $this->{params} } ) . '}';
128 }
129 else {
130 $this->{op}->{name};
131 }
132}
133
13414µs1;
135__END__