Filename | /var/www/foswikidev/core/lib/Foswiki/Query/ConditionalOP.pm |
Statements | Executed 140366 statements in 170ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
8769 | 2 | 2 | 116ms | 1.02s | evalTest | Foswiki::Query::ConditionalOP::
8769 | 1 | 1 | 91.1ms | 141ms | compare | Foswiki::Query::ConditionalOP::
27 | 9 | 9 | 211µs | 391µs | new | Foswiki::Query::ConditionalOP::
1 | 1 | 1 | 14µs | 25µs | BEGIN@11 | Foswiki::Query::ConditionalOP::
1 | 1 | 1 | 9µs | 12µs | BEGIN@12 | Foswiki::Query::ConditionalOP::
1 | 1 | 1 | 5µs | 5µs | BEGIN@13 | Foswiki::Query::ConditionalOP::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Query::ConditionalOP; | ||||
3 | |||||
4 | =begin TML | ||||
5 | |||||
6 | ---+ package Foswiki::Query::ConditionalOP | ||||
7 | Base class for binary conditional operators. | ||||
8 | |||||
9 | =cut | ||||
10 | |||||
11 | 2 | 26µs | 2 | 37µs | # spent 25µs (14+12) within Foswiki::Query::ConditionalOP::BEGIN@11 which was called:
# once (14µs+12µs) by Foswiki::Query::OP_lte::BEGIN@14 at line 11 # spent 25µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@11
# spent 12µs making 1 call to strict::import |
12 | 2 | 22µs | 2 | 16µs | # spent 12µs (9+3) within Foswiki::Query::ConditionalOP::BEGIN@12 which was called:
# once (9µs+3µs) by Foswiki::Query::OP_lte::BEGIN@14 at line 12 # spent 12µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 294µs | 1 | 5µs | # spent 5µs within Foswiki::Query::ConditionalOP::BEGIN@13 which was called:
# once (5µs+0s) by Foswiki::Query::OP_lte::BEGIN@14 at line 13 # spent 5µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@13 |
14 | 1 | 6µs | our @ISA = ('Foswiki::Query::OP'); | ||
15 | |||||
16 | # spent 391µs (211+180) within Foswiki::Query::ConditionalOP::new which was called 27 times, avg 14µs/call:
# 3 times (40µs+32µs) by Foswiki::Query::OP_match::new at line 26 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_match.pm, avg 24µs/call
# 3 times (28µs+24µs) by Foswiki::Query::OP_gt::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_gt.pm, avg 17µs/call
# 3 times (21µs+25µs) by Foswiki::Query::OP_ne::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_ne.pm, avg 15µs/call
# 3 times (21µs+19µs) by Foswiki::Query::OP_like::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_like.pm, avg 13µs/call
# 3 times (21µs+18µs) by Foswiki::Query::OP_eq::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_eq.pm, avg 13µs/call
# 3 times (20µs+16µs) by Foswiki::Query::OP_lte::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_lte.pm, avg 12µs/call
# 3 times (21µs+15µs) by Foswiki::Query::OP_in::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_in.pm, avg 12µs/call
# 3 times (20µs+16µs) by Foswiki::Query::OP_gte::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_gte.pm, avg 12µs/call
# 3 times (20µs+15µs) by Foswiki::Query::OP_lt::new at line 19 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_lt.pm, avg 12µs/call | ||||
17 | 27 | 7µs | my $class = shift; | ||
18 | 27 | 209µs | 27 | 180µs | return $class->SUPER::new( arity => 2, @_ ); # spent 180µs making 27 calls to Foswiki::Query::OP::new, avg 7µs/call |
19 | } | ||||
20 | |||||
21 | =begin TML | ||||
22 | |||||
23 | ---++ StaticMethod compare($a, $b, \&fn) -> $boolean | ||||
24 | |||||
25 | Apply a binary comparison function to two data, tolerant | ||||
26 | of whether they are numeric or not. =\&fn= takes a single parameter, | ||||
27 | which is the result of a =<=>= comparison on =$a= and =$b=. The result | ||||
28 | of applying =\&fn= is returned. | ||||
29 | |||||
30 | =cut | ||||
31 | |||||
32 | # spent 141ms (91.1+49.7) within Foswiki::Query::ConditionalOP::compare which was called 8769 times, avg 16µs/call:
# 8769 times (91.1ms+49.7ms) by Foswiki::Query::ConditionalOP::evalTest at line 88, avg 16µs/call | ||||
33 | 8769 | 4.63ms | my ( $a, $b, $sub ) = @_; | ||
34 | 8769 | 2.79ms | if ( !defined($a) ) { | ||
35 | return &$sub(0) unless defined($b); | ||||
36 | return -&$sub(1); | ||||
37 | } | ||||
38 | elsif ( !defined($b) ) { | ||||
39 | return &$sub(1); | ||||
40 | } | ||||
41 | 8769 | 9.43ms | 8769 | 36.4ms | if ( Foswiki::Query::OP::isNumber($a) # spent 36.4ms making 8769 calls to Foswiki::Query::OP::isNumber, avg 4µs/call |
42 | && Foswiki::Query::OP::isNumber($b) ) | ||||
43 | { | ||||
44 | return &$sub( $a <=> $b ); | ||||
45 | } | ||||
46 | else { | ||||
47 | 8769 | 45.8ms | 8769 | 13.3ms | return &$sub( $a cmp $b ); # spent 13.3ms making 8763 calls to Foswiki::Query::OP_eq::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Query/OP_eq.pm:28], avg 2µs/call
# spent 8µs making 6 calls to Foswiki::Query::OP_ne::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Query/OP_ne.pm:28], avg 1µs/call |
48 | } | ||||
49 | } | ||||
50 | |||||
51 | =begin TML | ||||
52 | |||||
53 | ---++ ObjectMethod evalTest($node, $clientData, \&fn) -> $result | ||||
54 | Evaluate a node using the comparison function passed in. Extra parameters | ||||
55 | are passed on to the comparison function. If the LHS of the node | ||||
56 | evaluates to an array, the result will be an array made by | ||||
57 | applying =\&fn= to each member of the LHS array. The RHS is passed on | ||||
58 | untouched to \&fn. Thus =(1,-1) > 1= will yield (1,0) | ||||
59 | |||||
60 | =cut | ||||
61 | |||||
62 | # spent 1.02s (116ms+900ms) within Foswiki::Query::ConditionalOP::evalTest which was called 8769 times, avg 116µs/call:
# 8763 times (116ms+898ms) by Foswiki::Query::OP_eq::evaluate at line 29 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_eq.pm, avg 116µs/call
# 6 times (62µs+1.15ms) by Foswiki::Query::OP_ne::evaluate at line 29 of /var/www/foswikidev/core/lib/Foswiki/Query/OP_ne.pm, avg 202µs/call | ||||
63 | 8769 | 1.64ms | my $this = shift; | ||
64 | 8769 | 1.18ms | my $node = shift; | ||
65 | 8769 | 1.08ms | my $clientData = shift; | ||
66 | 8769 | 880µs | my $sub = shift; | ||
67 | 8769 | 4.10ms | my $a = $node->{params}[0]; | ||
68 | 8769 | 2.29ms | my $b = $node->{params}[1]; | ||
69 | 8769 | 10.7ms | 8769 | 0s | my $ea = $a->evaluate( @{$clientData} ); # spent 722ms making 8769 calls to Foswiki::Query::Node::evaluate, avg 82µs/call, recursion: max depth 2, sum of overlapping time 722ms |
70 | 8769 | 13.5ms | 8769 | 0s | my $eb = $b->evaluate( @{$clientData} ); # spent 36.9ms making 8769 calls to Foswiki::Query::Node::evaluate, avg 4µs/call, recursion: max depth 2, sum of overlapping time 36.9ms |
71 | 8769 | 1.34ms | $ea = '' unless defined $ea; | ||
72 | 8769 | 737µs | $eb = '' unless defined $eb; | ||
73 | |||||
74 | 8769 | 3.03ms | 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 { | ||||
88 | 8769 | 66.2ms | 8769 | 141ms | return &$sub( $ea, $eb, @_ ); # spent 141ms making 8769 calls to Foswiki::Query::ConditionalOP::compare, avg 16µs/call |
89 | } | ||||
90 | } | ||||
91 | |||||
92 | 1 | 3µs | 1; | ||
93 | __END__ |