Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/ConditionalOP.pm |
Statements | Executed 458 statements in 2.52ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
22 | 2 | 2 | 1.10ms | 10.3ms | evalTest | Foswiki::Query::ConditionalOP::
22 | 1 | 1 | 524µs | 987µs | compare | Foswiki::Query::ConditionalOP::
27 | 9 | 9 | 420µs | 855µs | new | Foswiki::Query::ConditionalOP::
1 | 1 | 1 | 26µs | 33µs | BEGIN@11 | Foswiki::Query::ConditionalOP::
1 | 1 | 1 | 16µs | 33µs | BEGIN@12 | Foswiki::Query::ConditionalOP::
1 | 1 | 1 | 10µs | 10µ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 | 45µs | 2 | 40µ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 # spent 33µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@11
# spent 7µs making 1 call to strict::import |
12 | 2 | 44µs | 2 | 50µ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 # spent 33µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@12
# spent 17µs making 1 call to warnings::import |
13 | 2 | 515µs | 1 | 10µ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 # spent 10µs making 1 call to Foswiki::Query::ConditionalOP::BEGIN@13 |
14 | 1 | 9µs | our @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 | ||||
17 | 54 | 401µs | my $class = shift; | ||
18 | 27 | 435µ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 | |||||
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 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 | ||||
33 | 66 | 264µ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 | } | ||||
41 | 22 | 244µs | 22 | 350µ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 { | ||||
47 | 22 | 114µs | return &$sub( $a cmp $b ); # spent 59µs making 12 calls to Foswiki::Query::OP_ne::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_ne.pm:28], avg 5µs/call
# spent 56µs making 10 calls to Foswiki::Query::OP_eq::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/OP_eq.pm:28], avg 6µ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 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 | ||||
63 | 242 | 672µ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]; | ||||
69 | 22 | 36µs | 22 | 0s | 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 |
70 | 22 | 32µs | 22 | 0s | 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 | 22 | 249µs | 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 | 22 | 987µs | return &$sub( $ea, $eb, @_ ); # spent 987µs making 22 calls to Foswiki::Query::ConditionalOP::compare, avg 45µs/call | ||
89 | } | ||||
90 | } | ||||
91 | |||||
92 | 1 | 6µs | 1; | ||
93 | __END__ |