← 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/Query/OP.pm
StatementsExecuted 211 statements in 2.44ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
9115151.35ms1.35msFoswiki::Query::OP::::newFoswiki::Query::OP::new
2422268µs395µsFoswiki::Query::OP::::isNumberFoswiki::Query::OP::isNumber
2411127µs127µsFoswiki::Query::OP::::CORE:matchFoswiki::Query::OP::CORE:match (opcode)
11126µs33µsFoswiki::Query::OP::::BEGIN@16Foswiki::Query::OP::BEGIN@16
11116µs33µsFoswiki::Query::OP::::BEGIN@17Foswiki::Query::OP::BEGIN@17
0000s0sFoswiki::Query::OP::::collectFoswiki::Query::OP::collect
0000s0sFoswiki::Query::OP::::evaluateFoswiki::Query::OP::evaluate
0000s0sFoswiki::Query::OP::::evaluatesToConstantFoswiki::Query::OP::evaluatesToConstant
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
2package Foswiki::Query::OP;
3
4=begin TML
5
6---+ package Foswiki::Query::OP
7Base class of operators used in queries. Operators are singleton
8objects that specify the parser behaviour and are attached to
9nodes in the parse tree to provide semantics for the nodes.
10
11See Foswiki::Infix::OP for details of the different options used
12to define operator nodes.
13
14=cut
15
16244µs240µs
# spent 33µs (26+7) within Foswiki::Query::OP::BEGIN@16 which was called: # once (26µs+7µs) by Foswiki::Query::OP_empty::BEGIN@14 at line 16
use strict;
# spent 33µs making 1 call to Foswiki::Query::OP::BEGIN@16 # spent 7µs making 1 call to strict::import
172453µs250µs
# spent 33µs (16+17) within Foswiki::Query::OP::BEGIN@17 which was called: # once (16µs+17µs) by Foswiki::Query::OP_empty::BEGIN@14 at line 17
use warnings;
# spent 33µs making 1 call to Foswiki::Query::OP::BEGIN@17 # spent 17µs making 1 call to warnings::import
18
19# Does not need to subclass, but is a subclass of...
20#use Foswiki::Infix::OP ();
21#our @ISA = ( 'Foswiki::Infix::OP' );
22
23
# spent 1.35ms within Foswiki::Query::OP::new which was called 91 times, avg 15µs/call: # 30 times (458µs+0s) by Foswiki::Query::UnaryOP::new at line 11 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/UnaryOP.pm, avg 15µs/call # 27 times (435µs+0s) by Foswiki::Query::ConditionalOP::new at line 18 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/ConditionalOP.pm, avg 16µs/call # 4 times (54µs+0s) by Foswiki::Query::OP_comma::new at line 22 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_comma.pm, avg 14µs/call # 3 times (45µs+0s) by Foswiki::Query::OP_and::new at line 23 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_and.pm, avg 15µs/call # 3 times (44µs+0s) by Foswiki::Query::OP_or::new at line 23 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_or.pm, avg 15µs/call # 3 times (43µs+0s) by Foswiki::Query::OP_div::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_div.pm, avg 14µs/call # 3 times (42µs+0s) by Foswiki::Query::OP_where::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_where.pm, avg 14µs/call # 3 times (39µs+0s) by Foswiki::Query::OP_plus::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_plus.pm, avg 13µs/call # 3 times (37µs+0s) by Foswiki::Query::OP_dot::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_dot.pm, avg 12µs/call # 3 times (36µs+0s) by Foswiki::Query::OP_minus::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_minus.pm, avg 12µs/call # 3 times (36µs+0s) by Foswiki::Query::OP_ref::new at line 21 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_ref.pm, avg 12µs/call # 3 times (36µs+0s) by Foswiki::Query::OP_times::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_times.pm, avg 12µs/call # once (18µs+0s) by Foswiki::Query::OP_empty::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_empty.pm # once (14µs+0s) by Foswiki::If::OP_ingroup::new at line 20 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/OP_ingroup.pm # once (14µs+0s) by Foswiki::If::OP_allows::new at line 23 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/OP_allows.pm
sub new {
241821.55ms my ( $class, %opts ) = @_;
25 return bless( \%opts, $class );
26}
27
28=begin TML
29
30---++ ObjectMethod evaluate($node, %domain) -> $value
31
32Pure virtual method that evaluates the operator in the give domain.
33The domain is a reference to a hash that contains the
34data being operated on, and a reference to the meta-data of the topic being worked on
35(the "topic object"). The data being operated on can be a
36Meta object, a reference to an array (such as attachments), a reference
37to a hash or a scalar. Arrays can contain other arrays
38and hashes.
39
40See Foswiki::Query::Node::evaluate for more information.
41
42=cut
43
44sub evaluate {
45 my $this = shift;
46 die "Operator '$this->{name}' does not define evaluate()";
47}
48
49=begin TML
50
51---++ ObjectMethod evaluatesToConstant() -> $boolean
52Does this operator always evaluate to a constant?
53See Foswiki::Query::Node::evaluatesToConstant
54
55Used in hoisting/optimisation.
56
57Default behaviour is to call evaluatesAsConstant on all
58parameters and return true if they all return true.
59
60=cut
61
62sub evaluatesToConstant {
63 my $this = shift;
64 my $node = shift;
65 foreach my $i ( @{ $node->{params} } ) {
66 return 0 unless $i->evaluatesToConstant(@_);
67 }
68 return 1;
69}
70
71=begin TML
72
73---++ StaticMethod isNumber($string) -> $boolean
74
75Determine if a string represents a valid number (signed decimal)
76
77Used in hoisting/optimisation.
78
79=cut
80
81
# spent 395µs (268+127) within Foswiki::Query::OP::isNumber which was called 24 times, avg 16µs/call: # 22 times (246µs+104µs) by Foswiki::Query::ConditionalOP::compare at line 41 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/ConditionalOP.pm, avg 16µs/call # 2 times (22µs+23µs) by Foswiki::Query::Node::_freeze at line 364 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Node.pm, avg 23µs/call
sub isNumber {
8224388µs24127µs return shift =~ m/^[+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?$/;
# spent 127µs making 24 calls to Foswiki::Query::OP::CORE:match, avg 5µs/call
83}
84
85=begin TML
86
87---++ StaticMethod collect($a, $fn) -> []
88
89Invokes $fn once for each element of $a and return an array built from the results.
90
91=cut
92
93sub collect {
94 my ( $this, $a, $fn ) = @_;
95 if ( ref($a) eq 'ARRAY' ) {
96 my @b = map { $this->collect( $_, $fn ) } @$a;
97 return \@b;
98 }
99 elsif ( ref($a) eq 'HASH' ) {
100 die "Can't collect on a hash";
101 }
102 else {
103 return &$fn($a);
104 }
105}
106
10714µs1;
108__END__
 
# spent 127µs within Foswiki::Query::OP::CORE:match which was called 24 times, avg 5µs/call: # 24 times (127µs+0s) by Foswiki::Query::OP::isNumber at line 82, avg 5µs/call
sub Foswiki::Query::OP::CORE:match; # opcode