← 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/Parser.pm
StatementsExecuted 249 statements in 3.32ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.69ms5.81msFoswiki::Query::Parser::::BEGIN@28Foswiki::Query::Parser::BEGIN@28
333676µs2.71msFoswiki::Query::Parser::::newFoswiki::Query::Parser::new
111648µs694µsFoswiki::Query::Parser::::BEGIN@61Foswiki::Query::Parser::BEGIN@61
111510µs698µsFoswiki::Query::Parser::::BEGIN@58Foswiki::Query::Parser::BEGIN@58
111303µs349µsFoswiki::Query::Parser::::BEGIN@46Foswiki::Query::Parser::BEGIN@46
111292µs339µsFoswiki::Query::Parser::::BEGIN@34Foswiki::Query::Parser::BEGIN@34
111279µs325µsFoswiki::Query::Parser::::BEGIN@36Foswiki::Query::Parser::BEGIN@36
111272µs318µsFoswiki::Query::Parser::::BEGIN@68Foswiki::Query::Parser::BEGIN@68
111264µs313µsFoswiki::Query::Parser::::BEGIN@56Foswiki::Query::Parser::BEGIN@56
111261µs306µsFoswiki::Query::Parser::::BEGIN@48Foswiki::Query::Parser::BEGIN@48
111260µs303µsFoswiki::Query::Parser::::BEGIN@59Foswiki::Query::Parser::BEGIN@59
111259µs305µsFoswiki::Query::Parser::::BEGIN@63Foswiki::Query::Parser::BEGIN@63
111259µs300µsFoswiki::Query::Parser::::BEGIN@52Foswiki::Query::Parser::BEGIN@52
111259µs302µsFoswiki::Query::Parser::::BEGIN@50Foswiki::Query::Parser::BEGIN@50
111254µs300µsFoswiki::Query::Parser::::BEGIN@64Foswiki::Query::Parser::BEGIN@64
111244µs284µsFoswiki::Query::Parser::::BEGIN@67Foswiki::Query::Parser::BEGIN@67
111239µs279µsFoswiki::Query::Parser::::BEGIN@66Foswiki::Query::Parser::BEGIN@66
111234µs281µsFoswiki::Query::Parser::::BEGIN@65Foswiki::Query::Parser::BEGIN@65
111222µs267µsFoswiki::Query::Parser::::BEGIN@44Foswiki::Query::Parser::BEGIN@44
111222µs708µsFoswiki::Query::Parser::::BEGIN@42Foswiki::Query::Parser::BEGIN@42
111218µs259µsFoswiki::Query::Parser::::BEGIN@45Foswiki::Query::Parser::BEGIN@45
111217µs265µsFoswiki::Query::Parser::::BEGIN@47Foswiki::Query::Parser::BEGIN@47
111216µs258µsFoswiki::Query::Parser::::BEGIN@49Foswiki::Query::Parser::BEGIN@49
111216µs256µsFoswiki::Query::Parser::::BEGIN@53Foswiki::Query::Parser::BEGIN@53
111214µs256µsFoswiki::Query::Parser::::BEGIN@43Foswiki::Query::Parser::BEGIN@43
111213µs260µsFoswiki::Query::Parser::::BEGIN@55Foswiki::Query::Parser::BEGIN@55
111207µs530µsFoswiki::Query::Parser::::BEGIN@38Foswiki::Query::Parser::BEGIN@38
111198µs239µsFoswiki::Query::Parser::::BEGIN@70Foswiki::Query::Parser::BEGIN@70
11115µs27µsFoswiki::Query::Parser::::BEGIN@17Foswiki::Query::Parser::BEGIN@17
11111µs43µsFoswiki::Query::Parser::::BEGIN@100Foswiki::Query::Parser::BEGIN@100
11110µs34µsFoswiki::Query::Parser::::BEGIN@19Foswiki::Query::Parser::BEGIN@19
1119µs13µsFoswiki::Query::Parser::::BEGIN@18Foswiki::Query::Parser::BEGIN@18
1116µs6µsFoswiki::Query::Parser::::BEGIN@31Foswiki::Query::Parser::BEGIN@31
1114µs4µsFoswiki::Query::Parser::::BEGIN@40Foswiki::Query::Parser::BEGIN@40
1114µs4µsFoswiki::Query::Parser::::BEGIN@21Foswiki::Query::Parser::BEGIN@21
0000s0sFoswiki::Query::Parser::::onCloseExprFoswiki::Query::Parser::onCloseExpr
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::Query::Parser
6
7Parser for queries, using the Foswiki::Infix::Parser.
8
9The default node type in the generated parse tree is Foswiki::Query::Node,
10though you can pass your own alternative class as an option (it must implement
11Foswiki::Infix::Node)
12
13=cut
14
15package Foswiki::Query::Parser;
16
17226µs238µs
# spent 27µs (15+12) within Foswiki::Query::Parser::BEGIN@17 which was called: # once (15µs+12µs) by Foswiki::If::Parser::BEGIN@16 at line 17
use strict;
# spent 27µs making 1 call to Foswiki::Query::Parser::BEGIN@17 # spent 12µs making 1 call to strict::import
18223µs217µs
# spent 13µs (9+4) within Foswiki::Query::Parser::BEGIN@18 which was called: # once (9µs+4µs) by Foswiki::If::Parser::BEGIN@16 at line 18
use warnings;
# spent 13µs making 1 call to Foswiki::Query::Parser::BEGIN@18 # spent 4µs making 1 call to warnings::import
19245µs258µs
# spent 34µs (10+24) within Foswiki::Query::Parser::BEGIN@19 which was called: # once (10µs+24µs) by Foswiki::If::Parser::BEGIN@16 at line 19
use Assert;
# spent 34µs making 1 call to Foswiki::Query::Parser::BEGIN@19 # spent 24µs making 1 call to Exporter::import
20
21
# spent 4µs within Foswiki::Query::Parser::BEGIN@21 which was called: # once (4µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 26
BEGIN {
2214µs if ( $Foswiki::cfg{UseLocale} ) {
23 require locale;
24 import locale();
25 }
26119µs14µs}
# spent 4µs making 1 call to Foswiki::Query::Parser::BEGIN@21
27
282115µs15.81ms
# spent 5.81ms (1.69+4.11) within Foswiki::Query::Parser::BEGIN@28 which was called: # once (1.69ms+4.11ms) by Foswiki::If::Parser::BEGIN@16 at line 28
use Foswiki::Infix::Parser ();
# spent 5.81ms making 1 call to Foswiki::Query::Parser::BEGIN@28
2917µsour @ISA = ('Foswiki::Infix::Parser');
30
31223µs16µs
# spent 6µs within Foswiki::Query::Parser::BEGIN@31 which was called: # once (6µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 31
use Foswiki::Query::Node ();
# spent 6µs making 1 call to Foswiki::Query::Parser::BEGIN@31
32
33# operator name precedence
34298µs1339µs
# spent 339µs (292+47) within Foswiki::Query::Parser::BEGIN@34 which was called: # once (292µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 34
use Foswiki::Query::OP_or (); # 100
# spent 339µs making 1 call to Foswiki::Query::Parser::BEGIN@34
35
36296µs1325µs
# spent 325µs (279+46) within Foswiki::Query::Parser::BEGIN@36 which was called: # once (279µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 36
use Foswiki::Query::OP_and (); # 200
# spent 325µs making 1 call to Foswiki::Query::Parser::BEGIN@36
37
38287µs1530µs
# spent 530µs (207+323) within Foswiki::Query::Parser::BEGIN@38 which was called: # once (207µs+323µs) by Foswiki::If::Parser::BEGIN@16 at line 38
use Foswiki::Query::OP_not (); # 300
# spent 530µs making 1 call to Foswiki::Query::Parser::BEGIN@38
39
40220µs14µs
# spent 4µs within Foswiki::Query::Parser::BEGIN@40 which was called: # once (4µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 40
use Foswiki::Query::OP_comma (); # 400
# spent 4µs making 1 call to Foswiki::Query::Parser::BEGIN@40
41
42286µs1708µs
# spent 708µs (222+487) within Foswiki::Query::Parser::BEGIN@42 which was called: # once (222µs+487µs) by Foswiki::If::Parser::BEGIN@16 at line 42
use Foswiki::Query::OP_lte (); # 500
# spent 708µs making 1 call to Foswiki::Query::Parser::BEGIN@42
43288µs1256µs
# spent 256µs (214+42) within Foswiki::Query::Parser::BEGIN@43 which was called: # once (214µs+42µs) by Foswiki::If::Parser::BEGIN@16 at line 43
use Foswiki::Query::OP_gt (); # 500
# spent 256µs making 1 call to Foswiki::Query::Parser::BEGIN@43
44293µs1267µs
# spent 267µs (222+45) within Foswiki::Query::Parser::BEGIN@44 which was called: # once (222µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 44
use Foswiki::Query::OP_gte (); # 500
# spent 267µs making 1 call to Foswiki::Query::Parser::BEGIN@44
45286µs1259µs
# spent 259µs (218+41) within Foswiki::Query::Parser::BEGIN@45 which was called: # once (218µs+41µs) by Foswiki::If::Parser::BEGIN@16 at line 45
use Foswiki::Query::OP_lt (); # 500
# spent 259µs making 1 call to Foswiki::Query::Parser::BEGIN@45
46285µs1349µs
# spent 349µs (303+46) within Foswiki::Query::Parser::BEGIN@46 which was called: # once (303µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 46
use Foswiki::Query::OP_match (); # 500
# spent 349µs making 1 call to Foswiki::Query::Parser::BEGIN@46
47285µs1265µs
# spent 265µs (217+47) within Foswiki::Query::Parser::BEGIN@47 which was called: # once (217µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 47
use Foswiki::Query::OP_eq (); # 500
# spent 265µs making 1 call to Foswiki::Query::Parser::BEGIN@47
48286µs1306µs
# spent 306µs (261+45) within Foswiki::Query::Parser::BEGIN@48 which was called: # once (261µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 48
use Foswiki::Query::OP_like (); # 500
# spent 306µs making 1 call to Foswiki::Query::Parser::BEGIN@48
49285µs1258µs
# spent 258µs (216+43) within Foswiki::Query::Parser::BEGIN@49 which was called: # once (216µs+43µs) by Foswiki::If::Parser::BEGIN@16 at line 49
use Foswiki::Query::OP_ne (); # 500
# spent 258µs making 1 call to Foswiki::Query::Parser::BEGIN@49
50284µs1302µs
# spent 302µs (259+43) within Foswiki::Query::Parser::BEGIN@50 which was called: # once (259µs+43µs) by Foswiki::If::Parser::BEGIN@16 at line 50
use Foswiki::Query::OP_in (); # 500
# spent 302µs making 1 call to Foswiki::Query::Parser::BEGIN@50
51
52280µs1300µs
# spent 300µs (259+40) within Foswiki::Query::Parser::BEGIN@52 which was called: # once (259µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 52
use Foswiki::Query::OP_plus (); # 600
# spent 300µs making 1 call to Foswiki::Query::Parser::BEGIN@52
53292µs1256µs
# spent 256µs (216+40) within Foswiki::Query::Parser::BEGIN@53 which was called: # once (216µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 53
use Foswiki::Query::OP_minus (); # 600
# spent 256µs making 1 call to Foswiki::Query::Parser::BEGIN@53
54
55283µs1260µs
# spent 260µs (213+47) within Foswiki::Query::Parser::BEGIN@55 which was called: # once (213µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 55
use Foswiki::Query::OP_times (); # 700
# spent 260µs making 1 call to Foswiki::Query::Parser::BEGIN@55
562101µs1313µs
# spent 313µs (264+49) within Foswiki::Query::Parser::BEGIN@56 which was called: # once (264µs+49µs) by Foswiki::If::Parser::BEGIN@16 at line 56
use Foswiki::Query::OP_div (); # 700
# spent 313µs making 1 call to Foswiki::Query::Parser::BEGIN@56
57
58287µs1698µs
# spent 698µs (510+188) within Foswiki::Query::Parser::BEGIN@58 which was called: # once (510µs+188µs) by Foswiki::If::Parser::BEGIN@16 at line 58
use Foswiki::Query::OP_ref (); # 800
# spent 698µs making 1 call to Foswiki::Query::Parser::BEGIN@58
59291µs1303µs
# spent 303µs (260+43) within Foswiki::Query::Parser::BEGIN@59 which was called: # once (260µs+43µs) by Foswiki::If::Parser::BEGIN@16 at line 59
use Foswiki::Query::OP_dot (); # 800
# spent 303µs making 1 call to Foswiki::Query::Parser::BEGIN@59
60
61294µs1694µs
# spent 694µs (648+45) within Foswiki::Query::Parser::BEGIN@61 which was called: # once (648µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 61
use Foswiki::Query::OP_where (); # 900
# spent 694µs making 1 call to Foswiki::Query::Parser::BEGIN@61
62
63285µs1305µs
# spent 305µs (259+46) within Foswiki::Query::Parser::BEGIN@63 which was called: # once (259µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 63
use Foswiki::Query::OP_lc (); # 1000
# spent 305µs making 1 call to Foswiki::Query::Parser::BEGIN@63
64284µs1300µs
# spent 300µs (254+45) within Foswiki::Query::Parser::BEGIN@64 which was called: # once (254µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 64
use Foswiki::Query::OP_uc (); # 1000
# spent 300µs making 1 call to Foswiki::Query::Parser::BEGIN@64
65286µs1281µs
# spent 281µs (234+47) within Foswiki::Query::Parser::BEGIN@65 which was called: # once (234µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 65
use Foswiki::Query::OP_d2n (); # 1000
# spent 281µs making 1 call to Foswiki::Query::Parser::BEGIN@65
66283µs1279µs
# spent 279µs (239+40) within Foswiki::Query::Parser::BEGIN@66 which was called: # once (239µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 66
use Foswiki::Query::OP_length (); # 1000
# spent 279µs making 1 call to Foswiki::Query::Parser::BEGIN@66
67285µs1284µs
# spent 284µs (244+40) within Foswiki::Query::Parser::BEGIN@67 which was called: # once (244µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 67
use Foswiki::Query::OP_neg (); # 1000
# spent 284µs making 1 call to Foswiki::Query::Parser::BEGIN@67
68286µs1318µs
# spent 318µs (272+46) within Foswiki::Query::Parser::BEGIN@68 which was called: # once (272µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 68
use Foswiki::Query::OP_int (); # 1000
# spent 318µs making 1 call to Foswiki::Query::Parser::BEGIN@68
69
702114µs1239µs
# spent 239µs (198+41) within Foswiki::Query::Parser::BEGIN@70 which was called: # once (198µs+41µs) by Foswiki::If::Parser::BEGIN@16 at line 70
use Foswiki::Query::OP_ob (); # 1100
# spent 239µs making 1 call to Foswiki::Query::Parser::BEGIN@70
71
72=begin TML
73Query Language BNF
74<verbatim>
75expr ::= and_expr 'or' expr | and_expr;
76and_expr ::= not_expr 'and' and_expr | not_expr;
77not_expr ::= 'not' comma_expr | comma_expr;
78comma_expr ::= cmp_expr ',' comma_expr | cmp_expr;
79cmp_expr ::= add_expr cmp_op cm_expr | add_expr;
80cmp_op ::= '<=' | '>=' | '<' | '>' | '=' | '=~' | '~' | '!=' | 'in';
81add_expr ::= mul_expr add_op add_expr | mul_expr;
82mul_expr ::= ref_expr mul_op mul_expr | ref_expr;
83mul_op ::= '*' | 'div';
84ref_expr ::= u_expr ref_op ref_expr | u_expr;
85ref_op ::= '/' | '.';
86u_expr ::= value uop u_expr | value;
87uop ::= 'lc' | 'uc' | 'd2n' | 'length' | '-' | 'int' | '@';
88value ::= <name> | <string> | <number>;
89</verbatim>
90String and Numbers are as defined in Foswiki::Infix::Parser. Names default
91to =/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i=.
92
93See %SYSTEMWEB%.QuerySearch for details of the query language.
94
95=cut
96
97# Each operator is implemented by a class in Foswiki::Query. Note that
98# OP_empty is *not* included here; it is a pseudo-operator and does
99# not participate in parsing.
10017µs132µs
# spent 43µs (11+32) within Foswiki::Query::Parser::BEGIN@100 which was called: # once (11µs+32µs) by Foswiki::If::Parser::BEGIN@16 at line 102
use constant OPS => qw (match and eq lc lte not ref d2n gte length lt ob
# spent 32µs making 1 call to constant::import
101 uc dot gt like ne or where comma plus minus
1021157µs143µs neg times div in int );
# spent 43µs making 1 call to Foswiki::Query::Parser::BEGIN@100
103
104
# spent 2.71ms (676µs+2.04) within Foswiki::Query::Parser::new which was called 3 times, avg 904µs/call: # once (216µs+856µs) by Foswiki::If::Parser::new at line 46 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm # once (221µs+612µs) by Foswiki::Search::parseSearch at line 120 of /var/www/foswikidev/core/lib/Foswiki/Search.pm # once (238µs+569µs) by Foswiki::QUERY at line 60 of /var/www/foswikidev/core/lib/Foswiki/Macros/QUERY.pm
sub new {
10533µs my ( $class, $options ) = @_;
106
107311µs $options->{words} ||= qr/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i;
10833µs $options->{nodeClass} ||= 'Foswiki::Query::Node';
109330µs350µs my $this = $class->SUPER::new($options);
# spent 50µs making 3 calls to Foswiki::Infix::Parser::new, avg 17µs/call
110314µs316µs foreach my $op ( OPS() ) {
# spent 16µs making 3 calls to constant::__ANON__[constant.pm:144], avg 5µs/call
1118133µs my $on = 'Foswiki::Query::OP_' . $op;
11281459µs1621.97ms $this->addOperator( $on->new() );
# spent 165µs making 81 calls to Foswiki::Infix::Parser::addOperator, avg 2µs/call # spent 112µs making 3 calls to Foswiki::Query::OP_match::new, avg 37µs/call # spent 96µs making 3 calls to Foswiki::Query::OP_lc::new, avg 32µs/call # spent 85µs making 3 calls to Foswiki::Query::OP_gt::new, avg 28µs/call # spent 81µs making 3 calls to Foswiki::Query::OP_int::new, avg 27µs/call # spent 79µs making 3 calls to Foswiki::Query::OP_ne::new, avg 26µs/call # spent 76µs making 3 calls to Foswiki::Query::OP_like::new, avg 25µs/call # spent 75µs making 3 calls to Foswiki::Query::OP_neg::new, avg 25µs/call # spent 73µs making 3 calls to Foswiki::Query::OP_lt::new, avg 24µs/call # spent 72µs making 3 calls to Foswiki::Query::OP_eq::new, avg 24µs/call # spent 72µs making 3 calls to Foswiki::Query::OP_ob::new, avg 24µs/call # spent 72µs making 3 calls to Foswiki::Query::OP_uc::new, avg 24µs/call # spent 72µs making 3 calls to Foswiki::Query::OP_not::new, avg 24µs/call # spent 71µs making 3 calls to Foswiki::Query::OP_d2n::new, avg 24µs/call # spent 70µs making 3 calls to Foswiki::Query::OP_lte::new, avg 23µs/call # spent 70µs making 3 calls to Foswiki::Query::OP_in::new, avg 23µs/call # spent 69µs making 3 calls to Foswiki::Query::OP_length::new, avg 23µs/call # spent 68µs making 3 calls to Foswiki::Query::OP_gte::new, avg 23µs/call # spent 54µs making 3 calls to Foswiki::Query::OP_minus::new, avg 18µs/call # spent 52µs making 3 calls to Foswiki::Query::OP_dot::new, avg 17µs/call # spent 52µs making 3 calls to Foswiki::Query::OP_plus::new, avg 17µs/call # spent 51µs making 3 calls to Foswiki::Query::OP_div::new, avg 17µs/call # spent 50µs making 3 calls to Foswiki::Query::OP_and::new, avg 17µs/call # spent 49µs making 3 calls to Foswiki::Query::OP_times::new, avg 16µs/call # spent 49µs making 3 calls to Foswiki::Query::OP_ref::new, avg 16µs/call # spent 48µs making 3 calls to Foswiki::Query::OP_or::new, avg 16µs/call # spent 48µs making 3 calls to Foswiki::Query::OP_where::new, avg 16µs/call # spent 42µs making 3 calls to Foswiki::Query::OP_comma::new, avg 14µs/call
113 }
114314µs return $this;
115}
116
117# Ensure there is at least one operand on the opstack when closing
118# a subexpression.
119sub onCloseExpr {
120 my ( $this, $opands ) = @_;
121 if ( !scalar(@$opands) ) {
122 require Foswiki::Query::OP_empty;
123 push( @$opands, $this->{node_factory}->emptyExpression() );
124 }
125}
126
12713µs1;
128__END__