← 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/Query/OP.pm
StatementsExecuted 9516 statements in 55.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
88492236.7ms36.7msFoswiki::Query::OP::::isNumberFoswiki::Query::OP::isNumber
12011701µs981µsFoswiki::Query::OP::::evaluatesToConstantFoswiki::Query::OP::evaluatesToConstant
911515546µs546µsFoswiki::Query::OP::::newFoswiki::Query::OP::new
11113µs24µsFoswiki::Query::OP::::BEGIN@16Foswiki::Query::OP::BEGIN@16
1119µs13µsFoswiki::Query::OP::::BEGIN@17Foswiki::Query::OP::BEGIN@17
0000s0sFoswiki::Query::OP::::collectFoswiki::Query::OP::collect
0000s0sFoswiki::Query::OP::::evaluateFoswiki::Query::OP::evaluate
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
16224µs236µs
# spent 24µs (13+12) within Foswiki::Query::OP::BEGIN@16 which was called: # once (13µs+12µs) by Foswiki::Query::OP_empty::BEGIN@14 at line 16
use strict;
# spent 24µs making 1 call to Foswiki::Query::OP::BEGIN@16 # spent 12µs making 1 call to strict::import
172267µs216µs
# spent 13µs (9+4) within Foswiki::Query::OP::BEGIN@17 which was called: # once (9µs+4µs) by Foswiki::Query::OP_empty::BEGIN@14 at line 17
use warnings;
# spent 13µs making 1 call to Foswiki::Query::OP::BEGIN@17 # spent 4µ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 546µs within Foswiki::Query::OP::new which was called 91 times, avg 6µs/call: # 30 times (183µs+0s) by Foswiki::Query::UnaryOP::new at line 18 of /var/www/foswikidev/core/lib/Foswiki/Query/UnaryOP.pm, avg 6µs/call # 27 times (180µs+0s) by Foswiki::Query::ConditionalOP::new at line 18 of /var/www/foswikidev/core/lib/Foswiki/Query/ConditionalOP.pm, avg 7µs/call # 4 times (22µs+0s) by Foswiki::Query::OP_comma::new at line 22 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_comma.pm, avg 6µs/call # 3 times (19µs+0s) by Foswiki::Query::OP_plus::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_plus.pm, avg 6µs/call # 3 times (17µs+0s) by Foswiki::Query::OP_minus::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_minus.pm, avg 6µs/call # 3 times (17µs+0s) by Foswiki::Query::OP_dot::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_dot.pm, avg 6µs/call # 3 times (15µs+0s) by Foswiki::Query::OP_and::new at line 23 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_and.pm, avg 5µs/call # 3 times (14µs+0s) by Foswiki::Query::OP_ref::new at line 21 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_ref.pm, avg 5µs/call # 3 times (14µs+0s) by Foswiki::Query::OP_or::new at line 23 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_or.pm, avg 5µs/call # 3 times (14µs+0s) by Foswiki::Query::OP_where::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_where.pm, avg 5µs/call # 3 times (13µs+0s) by Foswiki::Query::OP_times::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_times.pm, avg 4µs/call # 3 times (13µs+0s) by Foswiki::Query::OP_div::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_div.pm, avg 4µs/call # once (10µs+0s) by Foswiki::Query::OP_empty::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_empty.pm # once (6µs+0s) by Foswiki::If::OP_allows::new at line 30 of /var/www/foswikidev/core/lib/Foswiki/If/OP_allows.pm # once (6µs+0s) by Foswiki::If::OP_ingroup::new at line 27 of /var/www/foswikidev/core/lib/Foswiki/If/OP_ingroup.pm
sub new {
2491169µs my ( $class, %opts ) = @_;
2591520µs 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
62
# spent 981µs (701+280) within Foswiki::Query::OP::evaluatesToConstant which was called 120 times, avg 8µs/call: # 120 times (701µs+280µs) by Foswiki::Query::Node::evaluatesToConstant at line 316 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm, avg 8µs/call
sub evaluatesToConstant {
6312030µs my $this = shift;
6412023µs my $node = shift;
65120119µs foreach my $i ( @{ $node->{params} } ) {
66120438µs1200s return 0 unless $i->evaluatesToConstant(@_);
# spent 280µs making 120 calls to Foswiki::Query::Node::evaluatesToConstant, avg 2µs/call, recursion: max depth 1, sum of overlapping time 280µs
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 36.7ms within Foswiki::Query::OP::isNumber which was called 8849 times, avg 4µs/call: # 8769 times (36.4ms+0s) by Foswiki::Query::ConditionalOP::compare at line 41 of /var/www/foswikidev/core/lib/Foswiki/Query/ConditionalOP.pm, avg 4µs/call # 80 times (301µs+0s) by Foswiki::Query::Node::_freeze at line 364 of /var/www/foswikidev/core/lib/Foswiki/Query/Node.pm, avg 4µs/call
sub isNumber {
82884953.5ms return shift =~ m/^[+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?$/;
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
10712µs1;
108__END__