← 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/Query/OP_where.pm
StatementsExecuted 14 statements in 469µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
31149µs97µsFoswiki::Query::OP_where::::newFoswiki::Query::OP_where::new
11119µs37µsFoswiki::Query::OP_where::::BEGIN@11Foswiki::Query::OP_where::BEGIN@11
11112µs18µsFoswiki::Query::OP_where::::BEGIN@12Foswiki::Query::OP_where::BEGIN@12
1115µs5µsFoswiki::Query::OP_where::::BEGIN@14Foswiki::Query::OP_where::BEGIN@14
0000s0sFoswiki::Query::OP_where::::evaluateFoswiki::Query::OP_where::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
2
3=begin TML
4
5---+ package Foswiki::Query::OP_where
6
7=cut
8
9package Foswiki::Query::OP_where;
10
11236µs254µs
# spent 37µs (19+18) within Foswiki::Query::OP_where::BEGIN@11 which was called: # once (19µs+18µs) by Foswiki::Query::Parser::new at line 11
use strict;
# spent 37µs making 1 call to Foswiki::Query::OP_where::BEGIN@11 # spent 18µs making 1 call to strict::import
12238µs225µs
# spent 18µs (12+7) within Foswiki::Query::OP_where::BEGIN@12 which was called: # once (12µs+7µs) by Foswiki::Query::Parser::new at line 12
use warnings;
# spent 18µs making 1 call to Foswiki::Query::OP_where::BEGIN@12 # spent 7µs making 1 call to warnings::import
13
142332µs15µs
# spent 5µs within Foswiki::Query::OP_where::BEGIN@14 which was called: # once (5µs+0s) by Foswiki::Query::Parser::new at line 14
use Foswiki::Query::BinaryOP ();
# spent 5µs making 1 call to Foswiki::Query::OP_where::BEGIN@14
15110µsour @ISA = ('Foswiki::Query::BinaryOP');
16
17
# spent 97µs (49+48) within Foswiki::Query::OP_where::new which was called 3 times, avg 32µs/call: # 3 times (49µs+48µs) by Foswiki::Query::Parser::new at line 47 of /var/www/foswiki11/lib/Foswiki/Query/Parser.pm, avg 32µs/call
sub new {
1832µs my $class = shift;
19346µs348µs return $class->SUPER::new( name => '[', close => ']', prec => 800 );
# spent 48µs making 3 calls to Foswiki::Query::BinaryOP::new, avg 16µs/call
20}
21
22sub evaluate {
23 my $this = shift;
24 my $node = shift;
25 my %domain = @_;
26 my $a = $node->{params}[0];
27 my $lval = $a->evaluate(@_);
28 my $b = $node->{params}[1];
29
30 # Special case; integer index responds with array el at that
31 # index.
32 if ( $b->{op} == $Foswiki::Infix::Node::NUMBER ) {
33 if ( ref($lval) eq 'ARRAY' ) {
34 return $lval->[ int( $b->{params}[0] ) ];
35 }
36 if ( defined($lval) && 0 == int( $b->{params}[0] ) ) {
37 return $lval;
38 }
39 return [];
40 }
41
42 # Otherwise evaluate the inner query
43 if ( ref($lval) eq 'ARRAY' ) {
44 my @res;
45 foreach my $el (@$lval) {
46 if ( $b->evaluate( data => $el, tom => $domain{tom} ) ) {
47 push( @res, $el );
48 }
49 }
50 return unless scalar(@res);
51 return \@res;
52 }
53 else {
54 return $b->evaluate( data => $lval, tom => $domain{tom} ) ? $lval : [];
55 }
56}
57
5814µs1;
59__END__