← 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/Parser.pm
StatementsExecuted 248 statements in 11.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1115.63ms5.76msFoswiki::Query::Parser::::BEGIN@58Foswiki::Query::Parser::BEGIN@58
1112.84ms10.8msFoswiki::Query::Parser::::BEGIN@21Foswiki::Query::Parser::BEGIN@21
3331.85ms6.84msFoswiki::Query::Parser::::newFoswiki::Query::Parser::new
111870µs1.41msFoswiki::Query::Parser::::BEGIN@51Foswiki::Query::Parser::BEGIN@51
111745µs819µsFoswiki::Query::Parser::::BEGIN@54Foswiki::Query::Parser::BEGIN@54
111550µs628µsFoswiki::Query::Parser::::BEGIN@38Foswiki::Query::Parser::BEGIN@38
111479µs558µsFoswiki::Query::Parser::::BEGIN@27Foswiki::Query::Parser::BEGIN@27
111470µs547µsFoswiki::Query::Parser::::BEGIN@52Foswiki::Query::Parser::BEGIN@52
111460µs575µsFoswiki::Query::Parser::::BEGIN@45Foswiki::Query::Parser::BEGIN@45
111454µs527µsFoswiki::Query::Parser::::BEGIN@39Foswiki::Query::Parser::BEGIN@39
111447µs522µsFoswiki::Query::Parser::::BEGIN@29Foswiki::Query::Parser::BEGIN@29
111443µs519µsFoswiki::Query::Parser::::BEGIN@41Foswiki::Query::Parser::BEGIN@41
111442µs523µsFoswiki::Query::Parser::::BEGIN@61Foswiki::Query::Parser::BEGIN@61
111437µs512µsFoswiki::Query::Parser::::BEGIN@60Foswiki::Query::Parser::BEGIN@60
111424µs509µsFoswiki::Query::Parser::::BEGIN@43Foswiki::Query::Parser::BEGIN@43
111397µs471µsFoswiki::Query::Parser::::BEGIN@59Foswiki::Query::Parser::BEGIN@59
111392µs469µsFoswiki::Query::Parser::::BEGIN@37Foswiki::Query::Parser::BEGIN@37
111378µs452µsFoswiki::Query::Parser::::BEGIN@49Foswiki::Query::Parser::BEGIN@49
111373µs448µsFoswiki::Query::Parser::::BEGIN@56Foswiki::Query::Parser::BEGIN@56
111364µs439µsFoswiki::Query::Parser::::BEGIN@36Foswiki::Query::Parser::BEGIN@36
111362µs439µsFoswiki::Query::Parser::::BEGIN@48Foswiki::Query::Parser::BEGIN@48
111362µs435µsFoswiki::Query::Parser::::BEGIN@46Foswiki::Query::Parser::BEGIN@46
111360µs437µsFoswiki::Query::Parser::::BEGIN@40Foswiki::Query::Parser::BEGIN@40
111356µs432µsFoswiki::Query::Parser::::BEGIN@42Foswiki::Query::Parser::BEGIN@42
111355µs435µsFoswiki::Query::Parser::::BEGIN@57Foswiki::Query::Parser::BEGIN@57
111352µs1.19msFoswiki::Query::Parser::::BEGIN@35Foswiki::Query::Parser::BEGIN@35
111348µs825µsFoswiki::Query::Parser::::BEGIN@31Foswiki::Query::Parser::BEGIN@31
111313µs387µsFoswiki::Query::Parser::::BEGIN@63Foswiki::Query::Parser::BEGIN@63
11127µs34µsFoswiki::Query::Parser::::BEGIN@17Foswiki::Query::Parser::BEGIN@17
11120µs37µsFoswiki::Query::Parser::::BEGIN@18Foswiki::Query::Parser::BEGIN@18
11119µs131µsFoswiki::Query::Parser::::BEGIN@93Foswiki::Query::Parser::BEGIN@93
11116µs56µsFoswiki::Query::Parser::::BEGIN@19Foswiki::Query::Parser::BEGIN@19
31115µs15µsFoswiki::Query::Parser::::CORE:qrFoswiki::Query::Parser::CORE:qr (opcode)
11111µs11µsFoswiki::Query::Parser::::BEGIN@33Foswiki::Query::Parser::BEGIN@33
11110µs10µsFoswiki::Query::Parser::::BEGIN@24Foswiki::Query::Parser::BEGIN@24
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
17245µs241µs
# spent 34µs (27+7) within Foswiki::Query::Parser::BEGIN@17 which was called: # once (27µs+7µs) by Foswiki::If::Parser::BEGIN@16 at line 17
use strict;
# spent 34µs making 1 call to Foswiki::Query::Parser::BEGIN@17 # spent 7µs making 1 call to strict::import
18244µs254µs
# spent 37µs (20+17) within Foswiki::Query::Parser::BEGIN@18 which was called: # once (20µs+17µs) by Foswiki::If::Parser::BEGIN@16 at line 18
use warnings;
# spent 37µs making 1 call to Foswiki::Query::Parser::BEGIN@18 # spent 17µs making 1 call to warnings::import
19244µs296µs
# spent 56µs (16+40) within Foswiki::Query::Parser::BEGIN@19 which was called: # once (16µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 19
use Assert;
# spent 56µs making 1 call to Foswiki::Query::Parser::BEGIN@19 # spent 40µs making 1 call to Assert::import
20
212182µs110.8ms
# spent 10.8ms (2.84+7.98) within Foswiki::Query::Parser::BEGIN@21 which was called: # once (2.84ms+7.98ms) by Foswiki::If::Parser::BEGIN@16 at line 21
use Foswiki::Infix::Parser ();
# spent 10.8ms making 1 call to Foswiki::Query::Parser::BEGIN@21
22112µsour @ISA = ('Foswiki::Infix::Parser');
23
24243µs110µs
# spent 10µs within Foswiki::Query::Parser::BEGIN@24 which was called: # once (10µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 24
use Foswiki::Query::Node ();
# spent 10µs making 1 call to Foswiki::Query::Parser::BEGIN@24
25
26# operator name precedence
272148µs1558µs
# spent 558µs (479+79) within Foswiki::Query::Parser::BEGIN@27 which was called: # once (479µs+79µs) by Foswiki::If::Parser::BEGIN@16 at line 27
use Foswiki::Query::OP_or (); # 100
# spent 558µs making 1 call to Foswiki::Query::Parser::BEGIN@27
28
292141µs1522µs
# spent 522µs (447+75) within Foswiki::Query::Parser::BEGIN@29 which was called: # once (447µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 29
use Foswiki::Query::OP_and (); # 200
# spent 522µs making 1 call to Foswiki::Query::Parser::BEGIN@29
30
312142µs1825µs
# spent 825µs (348+477) within Foswiki::Query::Parser::BEGIN@31 which was called: # once (348µs+477µs) by Foswiki::If::Parser::BEGIN@16 at line 31
use Foswiki::Query::OP_not (); # 300
# spent 825µs making 1 call to Foswiki::Query::Parser::BEGIN@31
32
33239µs111µs
# spent 11µs within Foswiki::Query::Parser::BEGIN@33 which was called: # once (11µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 33
use Foswiki::Query::OP_comma (); # 400
# spent 11µs making 1 call to Foswiki::Query::Parser::BEGIN@33
34
352137µs11.19ms
# spent 1.19ms (352µs+837µs) within Foswiki::Query::Parser::BEGIN@35 which was called: # once (352µs+837µs) by Foswiki::If::Parser::BEGIN@16 at line 35
use Foswiki::Query::OP_lte (); # 500
# spent 1.19ms making 1 call to Foswiki::Query::Parser::BEGIN@35
362131µs1439µs
# spent 439µs (364+75) within Foswiki::Query::Parser::BEGIN@36 which was called: # once (364µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 36
use Foswiki::Query::OP_gt (); # 500
# spent 439µs making 1 call to Foswiki::Query::Parser::BEGIN@36
372172µs1469µs
# spent 469µs (392+77) within Foswiki::Query::Parser::BEGIN@37 which was called: # once (392µs+77µs) by Foswiki::If::Parser::BEGIN@16 at line 37
use Foswiki::Query::OP_gte (); # 500
# spent 469µs making 1 call to Foswiki::Query::Parser::BEGIN@37
382330µs1628µs
# spent 628µs (550+78) within Foswiki::Query::Parser::BEGIN@38 which was called: # once (550µs+78µs) by Foswiki::If::Parser::BEGIN@16 at line 38
use Foswiki::Query::OP_lt (); # 500
# spent 628µs making 1 call to Foswiki::Query::Parser::BEGIN@38
392142µs1527µs
# spent 527µs (454+74) within Foswiki::Query::Parser::BEGIN@39 which was called: # once (454µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 39
use Foswiki::Query::OP_match (); # 500
# spent 527µs making 1 call to Foswiki::Query::Parser::BEGIN@39
402141µs1437µs
# spent 437µs (360+78) within Foswiki::Query::Parser::BEGIN@40 which was called: # once (360µs+78µs) by Foswiki::If::Parser::BEGIN@16 at line 40
use Foswiki::Query::OP_eq (); # 500
# spent 437µs making 1 call to Foswiki::Query::Parser::BEGIN@40
412142µs1519µs
# spent 519µs (443+76) within Foswiki::Query::Parser::BEGIN@41 which was called: # once (443µs+76µs) by Foswiki::If::Parser::BEGIN@16 at line 41
use Foswiki::Query::OP_like (); # 500
# spent 519µs making 1 call to Foswiki::Query::Parser::BEGIN@41
422141µs1432µs
# spent 432µs (356+75) within Foswiki::Query::Parser::BEGIN@42 which was called: # once (356µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 42
use Foswiki::Query::OP_ne (); # 500
# spent 432µs making 1 call to Foswiki::Query::Parser::BEGIN@42
432155µs1509µs
# spent 509µs (424+85) within Foswiki::Query::Parser::BEGIN@43 which was called: # once (424µs+85µs) by Foswiki::If::Parser::BEGIN@16 at line 43
use Foswiki::Query::OP_in (); # 500
# spent 509µs making 1 call to Foswiki::Query::Parser::BEGIN@43
44
452150µs1575µs
# spent 575µs (460+115) within Foswiki::Query::Parser::BEGIN@45 which was called: # once (460µs+115µs) by Foswiki::If::Parser::BEGIN@16 at line 45
use Foswiki::Query::OP_plus (); # 600
# spent 575µs making 1 call to Foswiki::Query::Parser::BEGIN@45
462142µs1435µs
# spent 435µs (362+73) within Foswiki::Query::Parser::BEGIN@46 which was called: # once (362µs+73µs) by Foswiki::If::Parser::BEGIN@16 at line 46
use Foswiki::Query::OP_minus (); # 600
# spent 435µs making 1 call to Foswiki::Query::Parser::BEGIN@46
47
482144µs1439µs
# spent 439µs (362+77) within Foswiki::Query::Parser::BEGIN@48 which was called: # once (362µs+77µs) by Foswiki::If::Parser::BEGIN@16 at line 48
use Foswiki::Query::OP_times (); # 700
# spent 439µs making 1 call to Foswiki::Query::Parser::BEGIN@48
492142µs1452µs
# spent 452µs (378+75) within Foswiki::Query::Parser::BEGIN@49 which was called: # once (378µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 49
use Foswiki::Query::OP_div (); # 700
# spent 452µs making 1 call to Foswiki::Query::Parser::BEGIN@49
50
512150µs11.41ms
# spent 1.41ms (870µs+538µs) within Foswiki::Query::Parser::BEGIN@51 which was called: # once (870µs+538µs) by Foswiki::If::Parser::BEGIN@16 at line 51
use Foswiki::Query::OP_ref (); # 800
# spent 1.41ms making 1 call to Foswiki::Query::Parser::BEGIN@51
522163µs1547µs
# spent 547µs (470+77) within Foswiki::Query::Parser::BEGIN@52 which was called: # once (470µs+77µs) by Foswiki::If::Parser::BEGIN@16 at line 52
use Foswiki::Query::OP_dot (); # 800
# spent 547µs making 1 call to Foswiki::Query::Parser::BEGIN@52
53
542144µs1819µs
# spent 819µs (745+74) within Foswiki::Query::Parser::BEGIN@54 which was called: # once (745µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 54
use Foswiki::Query::OP_where (); # 900
# spent 819µs making 1 call to Foswiki::Query::Parser::BEGIN@54
55
562137µs1448µs
# spent 448µs (373+75) within Foswiki::Query::Parser::BEGIN@56 which was called: # once (373µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 56
use Foswiki::Query::OP_lc (); # 1000
# spent 448µs making 1 call to Foswiki::Query::Parser::BEGIN@56
572142µs1435µs
# spent 435µs (355+80) within Foswiki::Query::Parser::BEGIN@57 which was called: # once (355µs+80µs) by Foswiki::If::Parser::BEGIN@16 at line 57
use Foswiki::Query::OP_uc (); # 1000
# spent 435µs making 1 call to Foswiki::Query::Parser::BEGIN@57
5825.33ms15.76ms
# spent 5.76ms (5.63+126µs) within Foswiki::Query::Parser::BEGIN@58 which was called: # once (5.63ms+126µs) by Foswiki::If::Parser::BEGIN@16 at line 58
use Foswiki::Query::OP_d2n (); # 1000
# spent 5.76ms making 1 call to Foswiki::Query::Parser::BEGIN@58
592145µs1471µs
# spent 471µs (397+74) within Foswiki::Query::Parser::BEGIN@59 which was called: # once (397µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 59
use Foswiki::Query::OP_length (); # 1000
# spent 471µs making 1 call to Foswiki::Query::Parser::BEGIN@59
602138µs1512µs
# spent 512µs (437+75) within Foswiki::Query::Parser::BEGIN@60 which was called: # once (437µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 60
use Foswiki::Query::OP_neg (); # 1000
# spent 512µs making 1 call to Foswiki::Query::Parser::BEGIN@60
612158µs1523µs
# spent 523µs (442+81) within Foswiki::Query::Parser::BEGIN@61 which was called: # once (442µs+81µs) by Foswiki::If::Parser::BEGIN@16 at line 61
use Foswiki::Query::OP_int (); # 1000
# spent 523µs making 1 call to Foswiki::Query::Parser::BEGIN@61
62
632180µs1387µs
# spent 387µs (313+74) within Foswiki::Query::Parser::BEGIN@63 which was called: # once (313µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 63
use Foswiki::Query::OP_ob (); # 1100
# spent 387µs making 1 call to Foswiki::Query::Parser::BEGIN@63
64
65=begin TML
66Query Language BNF
67<verbatim>
68expr ::= and_expr 'or' expr | and_expr;
69and_expr ::= not_expr 'and' and_expr | not_expr;
70not_expr ::= 'not' comma_expr | comma_expr;
71comma_expr ::= cmp_expr ',' comma_expr | cmp_expr;
72cmp_expr ::= add_expr cmp_op cm_expr | add_expr;
73cmp_op ::= '<=' | '>=' | '<' | '>' | '=' | '=~' | '~' | '!=' | 'in';
74add_expr ::= mul_expr add_op add_expr | mul_expr;
75mul_expr ::= ref_expr mul_op mul_expr | ref_expr;
76mul_op ::= '*' | 'div';
77ref_expr ::= u_expr ref_op ref_expr | u_expr;
78ref_op ::= '/' | '.';
79u_expr ::= value uop u_expr | value;
80uop ::= 'lc' | 'uc' | 'd2n' | 'length' | '-' | 'int' | '@';
81value ::= <name> | <string> | <number>;
82</verbatim>
83String and Numbers are as defined in Foswiki::Infix::Parser. Names default
84to =/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i=.
85
86See %SYSTEMWEB%.QuerySearch for details of the query language.
87
88=cut
89
90# Each operator is implemented by a class in Foswiki::Query. Note that
91# OP_empty is *not* included here; it is a pseudo-operator and does
92# not participate in parsing.
931112µs
# spent 131µs (19+112) within Foswiki::Query::Parser::BEGIN@93 which was called: # once (19µs+112µs) by Foswiki::If::Parser::BEGIN@16 at line 95
use constant OPS => qw (match and eq lc lte not ref d2n gte length lt ob
# spent 112µs making 1 call to constant::import
94 uc dot gt like ne or where comma plus minus
952286µs1131µs neg times div in int );
# spent 131µs making 1 call to Foswiki::Query::Parser::BEGIN@93
96
97
# spent 6.84ms (1.85+4.99) within Foswiki::Query::Parser::new which was called 3 times, avg 2.28ms/call: # once (662µs+2.12ms) by Foswiki::If::Parser::new at line 39 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/Parser.pm # once (611µs+1.49ms) by Foswiki::Search::parseSearch at line 123 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Search.pm # once (581µs+1.37ms) by Foswiki::QUERY at line 48 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/QUERY.pm
sub new {
981801.83ms my ( $class, $options ) = @_;
99
100315µs $options->{words} ||= qr/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i;
# spent 15µs making 3 calls to Foswiki::Query::Parser::CORE:qr, avg 5µs/call
101 $options->{nodeClass} ||= 'Foswiki::Query::Node';
1023165µs my $this = $class->SUPER::new($options);
# spent 165µs making 3 calls to Foswiki::Infix::Parser::new, avg 55µs/call
103342µs foreach my $op ( OPS() ) {
# spent 42µs making 3 calls to constant::__ANON__[constant.pm:140], avg 14µs/call
104 my $on = 'Foswiki::Query::OP_' . $op;
1051624.77ms $this->addOperator( $on->new() );
# spent 909µs making 81 calls to Foswiki::Infix::Parser::addOperator, avg 11µs/call # spent 253µs making 3 calls to Foswiki::Query::OP_match::new, avg 84µs/call # spent 222µs making 3 calls to Foswiki::Query::OP_lc::new, avg 74µs/call # spent 161µs making 3 calls to Foswiki::Query::OP_not::new, avg 54µs/call # spent 159µs making 3 calls to Foswiki::Query::OP_d2n::new, avg 53µs/call # spent 159µs making 3 calls to Foswiki::Query::OP_lte::new, avg 53µs/call # spent 156µs making 3 calls to Foswiki::Query::OP_ne::new, avg 52µs/call # spent 156µs making 3 calls to Foswiki::Query::OP_eq::new, avg 52µs/call # spent 156µs making 3 calls to Foswiki::Query::OP_lt::new, avg 52µs/call # spent 155µs making 3 calls to Foswiki::Query::OP_gte::new, avg 52µs/call # spent 154µs making 3 calls to Foswiki::Query::OP_in::new, avg 51µs/call # spent 152µs making 3 calls to Foswiki::Query::OP_uc::new, avg 51µs/call # spent 148µs making 3 calls to Foswiki::Query::OP_gt::new, avg 49µs/call # spent 148µs making 3 calls to Foswiki::Query::OP_neg::new, avg 49µs/call # spent 147µs making 3 calls to Foswiki::Query::OP_or::new, avg 49µs/call # spent 147µs making 3 calls to Foswiki::Query::OP_length::new, avg 49µs/call # spent 147µs making 3 calls to Foswiki::Query::OP_ob::new, avg 49µs/call # spent 146µs making 3 calls to Foswiki::Query::OP_like::new, avg 49µs/call # spent 141µs making 3 calls to Foswiki::Query::OP_int::new, avg 47µs/call # spent 128µs making 3 calls to Foswiki::Query::OP_and::new, avg 43µs/call # spent 111µs making 3 calls to Foswiki::Query::OP_div::new, avg 37µs/call # spent 108µs making 3 calls to Foswiki::Query::OP_plus::new, avg 36µs/call # spent 108µs making 3 calls to Foswiki::Query::OP_ref::new, avg 36µs/call # spent 105µs making 3 calls to Foswiki::Query::OP_dot::new, avg 35µs/call # spent 103µs making 3 calls to Foswiki::Query::OP_where::new, avg 34µs/call # spent 100µs making 3 calls to Foswiki::Query::OP_comma::new, avg 33µs/call # spent 98µs making 3 calls to Foswiki::Query::OP_minus::new, avg 33µs/call # spent 94µs making 3 calls to Foswiki::Query::OP_times::new, avg 31µs/call
106 }
107 return $this;
108}
109
110# Ensure there is at least one operand on the opstack when closing
111# a subexpression.
112sub onCloseExpr {
113 my ( $this, $opands ) = @_;
114 if ( !scalar(@$opands) ) {
115 require Foswiki::Query::OP_empty;
116 push( @$opands, $this->{node_factory}->emptyExpression() );
117 }
118}
119
12016µs1;
121__END__
 
# spent 15µs within Foswiki::Query::Parser::CORE:qr which was called 3 times, avg 5µs/call: # 3 times (15µs+0s) by Foswiki::Query::Parser::new at line 100, avg 5µs/call
sub Foswiki::Query::Parser::CORE:qr; # opcode