← 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/ConditionalOP.pm
StatementsExecuted 458 statements in 2.52ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
22221.10ms10.3msFoswiki::Query::ConditionalOP::::evalTestFoswiki::Query::ConditionalOP::evalTest
2211524µs987µsFoswiki::Query::ConditionalOP::::compareFoswiki::Query::ConditionalOP::compare
2799420µs855µsFoswiki::Query::ConditionalOP::::newFoswiki::Query::ConditionalOP::new
11126µs33µsFoswiki::Query::ConditionalOP::::BEGIN@11Foswiki::Query::ConditionalOP::BEGIN@11
11116µs33µsFoswiki::Query::ConditionalOP::::BEGIN@12Foswiki::Query::ConditionalOP::BEGIN@12
11110µs10µsFoswiki::Query::ConditionalOP::::BEGIN@13Foswiki::Query::ConditionalOP::BEGIN@13
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::ConditionalOP;
3
4=begin TML
5
6---+ package Foswiki::Query::ConditionalOP
7Base class for binary conditional operators.
8
9=cut
10
11245µs240µs
# spent 33µs (26+7) within Foswiki::Query::ConditionalOP::BEGIN@11 which was called: # once (26µs+7µs) by Foswiki::Query::OP_lte::BEGIN@14 at line 11
use strict;
# spent 33µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@11 # spent 7µs making 1 call to strict::import
12244µs250µs
# spent 33µs (16+17) within Foswiki::Query::ConditionalOP::BEGIN@12 which was called: # once (16µs+17µs) by Foswiki::Query::OP_lte::BEGIN@14 at line 12
use warnings;
# spent 33µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@12 # spent 17µs making 1 call to warnings::import
132515µs110µs
# spent 10µs within Foswiki::Query::ConditionalOP::BEGIN@13 which was called: # once (10µs+0s) by Foswiki::Query::OP_lte::BEGIN@14 at line 13
use Foswiki::Query::OP;
# spent 10µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@13
1419µsour @ISA = ('Foswiki::Query::OP');
15
16
# spent 855µs (420+435) within Foswiki::Query::ConditionalOP::new which was called 27 times, avg 32µs/call: # 3 times (89µs+78µs) by Foswiki::Query::OP_match::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_match.pm, avg 56µs/call # 3 times (40µs+49µs) by Foswiki::Query::OP_gte::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_gte.pm, avg 30µs/call # 3 times (41µs+47µs) by Foswiki::Query::OP_lte::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_lte.pm, avg 29µs/call # 3 times (40µs+48µs) by Foswiki::Query::OP_ne::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_ne.pm, avg 29µs/call # 3 times (41µs+46µs) by Foswiki::Query::OP_eq::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_eq.pm, avg 29µs/call # 3 times (45µs+40µs) by Foswiki::Query::OP_gt::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_gt.pm, avg 28µs/call # 3 times (40µs+44µs) by Foswiki::Query::OP_like::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_like.pm, avg 28µs/call # 3 times (41µs+43µs) by Foswiki::Query::OP_lt::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_lt.pm, avg 28µs/call # 3 times (43µs+40µs) by Foswiki::Query::OP_in::new at line 19 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_in.pm, avg 28µs/call
sub new {
1754401µs my $class = shift;
1827435µs return $class->SUPER::new( arity => 2, @_ );
# spent 435µs making 27 calls to Foswiki::Query::OP::new, avg 16µs/call
19}
20
21=begin TML
22
23---++ StaticMethod compare($a, $b, \&fn) -> $boolean
24
25Apply a binary comparison function to two data, tolerant
26of whether they are numeric or not. =\&fn= takes a single parameter,
27which is the result of a =<=>= comparison on =$a= and =$b=. The result
28of applying =\&fn= is returned.
29
30=cut
31
32
# spent 987µs (524+464) within Foswiki::Query::ConditionalOP::compare which was called 22 times, avg 45µs/call: # 22 times (524µs+464µs) by Foswiki::Query::ConditionalOP::evalTest at line 88, avg 45µs/call
sub compare {
3388508µs my ( $a, $b, $sub ) = @_;
34 if ( !defined($a) ) {
35 return &$sub(0) unless defined($b);
36 return -&$sub(1);
37 }
38 elsif ( !defined($b) ) {
39 return &$sub(1);
40 }
4122350µs if ( Foswiki::Query::OP::isNumber($a)
# spent 350µs making 22 calls to Foswiki::Query::OP::isNumber, avg 16µs/call
42 && Foswiki::Query::OP::isNumber($b) )
43 {
44 return &$sub( $a <=> $b );
45 }
46 else {
4722114µs return &$sub( $a cmp $b );
48 }
49}
50
51=begin TML
52
53---++ ObjectMethod evalTest($node, $clientData, \&fn) -> $result
54Evaluate a node using the comparison function passed in. Extra parameters
55are passed on to the comparison function. If the LHS of the node
56evaluates to an array, the result will be an array made by
57applying =\&fn= to each member of the LHS array. The RHS is passed on
58untouched to \&fn. Thus =(1,-1) > 1= will yield (1,0)
59
60=cut
61
62
# spent 10.3ms (1.10+9.19) within Foswiki::Query::ConditionalOP::evalTest which was called 22 times, avg 468µs/call: # 12 times (624µs+5.34ms) by Foswiki::Query::OP_ne::evaluate at line 29 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_ne.pm, avg 497µs/call # 10 times (475µs+3.86ms) by Foswiki::Query::OP_eq::evaluate at line 29 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_eq.pm, avg 433µs/call
sub evalTest {
63308989µs my $this = shift;
64 my $node = shift;
65 my $clientData = shift;
66 my $sub = shift;
67 my $a = $node->{params}[0];
68 my $b = $node->{params}[1];
69220s my $ea = $a->evaluate( @{$clientData} );
# spent 7.52ms making 22 calls to Foswiki::Query::Node::evaluate, avg 342µs/call, recursion: max depth 2, sum of overlapping time 7.52ms
70220s my $eb = $b->evaluate( @{$clientData} );
# spent 684µs making 22 calls to Foswiki::Query::Node::evaluate, avg 31µs/call, recursion: max depth 2, sum of overlapping time 684µs
71 $ea = '' unless defined $ea;
72 $eb = '' unless defined $eb;
73
74 if ( ref($ea) eq 'ARRAY' ) {
75 my @res;
76 foreach my $lhs (@$ea) {
77 push( @res, $lhs ) if &$sub( $lhs, $eb, @_ );
78 }
79 if ( scalar(@res) == 0 ) {
80 return;
81 }
82 elsif ( scalar(@res) == 1 ) {
83 return $res[0];
84 }
85 return \@res;
86 }
87 else {
8822987µs return &$sub( $ea, $eb, @_ );
# spent 987µs making 22 calls to Foswiki::Query::ConditionalOP::compare, avg 45µs/call
89 }
90}
91
9216µs1;
93__END__