← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Infix/Node.pm
StatementsExecuted 1764 statements in 2.96ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
246221.32ms1.32msFoswiki::Infix::Node::::newNodeFoswiki::Infix::Node::newNode
14021732µs1.58msFoswiki::Infix::Node::::newLeafFoswiki::Infix::Node::newLeaf
11124µs46µsFoswiki::Infix::Node::::BEGIN@14Foswiki::Infix::Node::BEGIN@14
11116µs25µsFoswiki::Infix::Node::::BEGIN@15Foswiki::Infix::Node::BEGIN@15
0000s0sFoswiki::Infix::Node::::MONITOR_EVALFoswiki::Infix::Node::MONITOR_EVAL
0000s0sFoswiki::Infix::Node::::evaluateFoswiki::Infix::Node::evaluate
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. You don't *have* to use
8it, but it may be useful.
9
10=cut
11
12package Foswiki::Infix::Node;
13
14250µs268µs
# spent 46µs (24+22) within Foswiki::Infix::Node::BEGIN@14 which was called: # once (24µs+22µs) by Foswiki::Infix::Parser::BEGIN@21 at line 14
use strict;
# spent 46µs making 1 call to Foswiki::Infix::Node::BEGIN@14 # spent 22µs making 1 call to strict::import
152652µs234µs
# spent 25µs (16+9) within Foswiki::Infix::Node::BEGIN@15 which was called: # once (16µs+9µs) by Foswiki::Infix::Parser::BEGIN@21 at line 15
use warnings;
# spent 25µs making 1 call to Foswiki::Infix::Node::BEGIN@15 # spent 9µs making 1 call to warnings::import
16
17# 1 for debug
18sub MONITOR_EVAL { 0 }
19
20# Leaf token types
211700nsour $NAME = 1;
221200nsour $NUMBER = 2;
231200nsour $STRING = 3;
24
25=begin TML
26
27---++ ClassMethod newNode( $o, @p ) -> \$if
28
29Construct a new parse node (contract with Infix::Parser)
30
31=cut
32
33
# spent 1.32ms within Foswiki::Infix::Node::newNode which was called 246 times, avg 5µs/call: # 140 times (848µs+0s) by Foswiki::Infix::Node::newLeaf at line 52, avg 6µs/call # 106 times (468µs+0s) by Foswiki::Infix::Parser::_apply at line 319 of /var/www/foswiki11/lib/Foswiki/Infix/Parser.pm, avg 4µs/call
sub newNode {
3424683µs my $class = shift;
3524664µs my $op = shift;
36246290µs my $this = bless( {}, $class );
37246412µs @{ $this->{params} } = @_;
38246139µs $this->{op} = $op;
39246681µs return $this;
40}
41
42=begin TML
43
44---++ ClassMethod newLeaf( $val, $type ) -> \$if
45
46Construct a new terminal node (contract with Infix::Parser)
47
48=cut
49
50
# spent 1.58ms (732µs+848µs) within Foswiki::Infix::Node::newLeaf which was called 140 times, avg 11µs/call: # 139 times (722µs+838µs) by Foswiki::Query::Node::newLeaf at line 91 of /var/www/foswiki11/lib/Foswiki/Query/Node.pm, avg 11µs/call # once (10µs+10µs) by Foswiki::Query::Node::newLeaf at line 88 of /var/www/foswiki11/lib/Foswiki/Query/Node.pm
sub newLeaf {
51140113µs my ( $class, $val, $type ) = @_;
52140473µs140848µs return newNode( $class, $type, $val );
# spent 848µs making 140 calls to Foswiki::Infix::Node::newNode, avg 6µs/call
53}
54
55=begin TML
56
57---++ ObjectMethod evaluate(...) -> $result
58
59Execute the parse node. The parameter array is passed on, by reference,
60to the evaluation functions.
61
62=cut
63
64sub evaluate {
65 my ( $this, $clientData ) = @_;
66
67 my $result;
68 if ( !ref( $this->{op} ) ) {
69 $result = $this->{params}[0];
70 if (MONITOR_EVAL) {
71 print STDERR "LEAF: ", ( defined($result) ? $result : 'undef' ),
72 "\n";
73 }
74 }
75 else {
76 my $fn = $this->{op}->{evaluate};
77 $result = &$fn( $clientData, @{ $this->{params} } );
78 if (MONITOR_EVAL) {
79 print STDERR "NODE: ", $this->stringify(), " -> ",
80 ( defined($result) ? $result : 'undef' ), "\n";
81 }
82 }
83 return $result;
84}
85
86sub stringify {
87 my $this = shift;
88
89 unless ( ref( $this->{op} ) ) {
90 if ( $this->{op} == $Foswiki::Infix::Node::STRING ) {
91 return "'$this->{params}[0]'";
92 }
93 else {
94 return $this->{params}[0];
95 }
96 }
97
98 return
99 $this->{op}->{name} . '{'
100 . join( ',', map { $_->stringify() } @{ $this->{params} } ) . '}';
101}
102
10316µs1;
104__END__