← 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:27:20 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_ref.pm
StatementsExecuted 18 statements in 882µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
31171µs108µsFoswiki::Query::OP_ref::::newFoswiki::Query::OP_ref::new
11124µs31µsFoswiki::Query::OP_ref::::BEGIN@11Foswiki::Query::OP_ref::BEGIN@11
11118µs61µsFoswiki::Query::OP_ref::::BEGIN@17Foswiki::Query::OP_ref::BEGIN@17
11116µs34µsFoswiki::Query::OP_ref::::BEGIN@12Foswiki::Query::OP_ref::BEGIN@12
11116µs404µsFoswiki::Query::OP_ref::::BEGIN@16Foswiki::Query::OP_ref::BEGIN@16
1119µs9µsFoswiki::Query::OP_ref::::BEGIN@13Foswiki::Query::OP_ref::BEGIN@13
0000s0sFoswiki::Query::OP_ref::::__ANON__[:60]Foswiki::Query::OP_ref::__ANON__[:60]
0000s0sFoswiki::Query::OP_ref::::__ANON__[:63]Foswiki::Query::OP_ref::__ANON__[:63]
0000s0sFoswiki::Query::OP_ref::::evaluateFoswiki::Query::OP_ref::evaluate
0000s0sFoswiki::Query::OP_ref::::evaluatesToConstantFoswiki::Query::OP_ref::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
2
3=begin TML
4
5---+ package Foswiki::Query::OP_ref
6
7=cut
8
9package Foswiki::Query::OP_ref;
10
11245µs238µs
# spent 31µs (24+7) within Foswiki::Query::OP_ref::BEGIN@11 which was called: # once (24µs+7µs) by Foswiki::Query::Parser::BEGIN@51 at line 11
use strict;
# spent 31µs making 1 call to Foswiki::Query::OP_ref::BEGIN@11 # spent 7µs making 1 call to strict::import
12241µs251µs
# spent 34µs (16+18) within Foswiki::Query::OP_ref::BEGIN@12 which was called: # once (16µs+18µs) by Foswiki::Query::Parser::BEGIN@51 at line 12
use warnings;
# spent 34µs making 1 call to Foswiki::Query::OP_ref::BEGIN@12 # spent 18µs making 1 call to warnings::import
13261µs19µs
# spent 9µs within Foswiki::Query::OP_ref::BEGIN@13 which was called: # once (9µs+0s) by Foswiki::Query::Parser::BEGIN@51 at line 13
use Foswiki::Query::OP ();
# spent 9µs making 1 call to Foswiki::Query::OP_ref::BEGIN@13
1419µsour @ISA = ('Foswiki::Query::OP');
15
16249µs2791µs
# spent 404µs (16+388) within Foswiki::Query::OP_ref::BEGIN@16 which was called: # once (16µs+388µs) by Foswiki::Query::Parser::BEGIN@51 at line 16
use Error qw( :try );
# spent 404µs making 1 call to Foswiki::Query::OP_ref::BEGIN@16 # spent 388µs making 1 call to Error::import
172612µs2104µs
# spent 61µs (18+43) within Foswiki::Query::OP_ref::BEGIN@17 which was called: # once (18µs+43µs) by Foswiki::Query::Parser::BEGIN@51 at line 17
use Assert;
# spent 61µs making 1 call to Foswiki::Query::OP_ref::BEGIN@17 # spent 43µs making 1 call to Assert::import
18
19
# spent 108µs (71+36) within Foswiki::Query::OP_ref::new which was called 3 times, avg 36µs/call: # 3 times (71µs+36µs) by Foswiki::Query::Parser::new at line 105 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Parser.pm, avg 36µs/call
sub new {
2036µs my $class = shift;
21352µs336µs return $class->SUPER::new( arity => 2, name => '/', prec => 800 );
# spent 36µs making 3 calls to Foswiki::Query::OP::new, avg 12µs/call
22}
23
24sub evaluate {
25 my $this = shift;
26 my $pnode = shift;
27 my %domain = @_;
28
29 eval "require $Foswiki::cfg{Store}{QueryAlgorithm}";
30 die $@ if $@;
31
32 my $a = $pnode->{params}[0];
33 my $node = $a->evaluate(@_);
34 return unless defined $node;
35 if ( ref($node) eq 'HASH' ) {
36 return;
37 }
38 if ( !( ref($node) eq 'ARRAY' ) ) {
39 $node = [$node];
40 }
41 my @result;
42 foreach my $v (@$node) {
43
44 # Has to be relative to the web of the topic we are querying
45 my ( $w, $t ) =
46 $Foswiki::Plugins::SESSION->normalizeWebTopicName(
47 $Foswiki::Plugins::SESSION->{webName}, $v );
48 try {
49 my $submeta =
50 $Foswiki::cfg{Store}{QueryAlgorithm}
51 ->getRefTopic( $domain{tom}, $w, $t );
52 my $b = $pnode->{params}[1];
53 my $res = $b->evaluate( tom => $submeta, data => $submeta );
54 if ( ref($res) eq 'ARRAY' ) {
55 push( @result, @$res );
56 }
57 else {
58 push( @result, $res );
59 }
60 }
61 catch Error::Simple with {
62 print STDERR "ERROR IN OP_ref: $_[0]->{-text}" if DEBUG;
63 };
64 }
65 return unless scalar(@result);
66 return $result[0] if scalar(@result) == 1;
67 return \@result;
68}
69
70sub evaluatesToConstant {
71 my $this = shift;
72 my $node = shift;
73 return 1 if $node->{params}[0]->evaluatesToConstant(@_);
74
75 # param[1] may contain non-constant terms, but that's OK because
76 # they are evaluated relative to the (constant) param[0]
77 return 0;
78}
79
8016µs1;
81__END__