Filename | /var/www/foswikidev/core/lib/Foswiki/Query/OP_length.pm |
Statements | Executed 14 statements in 226µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 1 | 1 | 35µs | 69µs | new | Foswiki::Query::OP_length::
1 | 1 | 1 | 12µs | 24µs | BEGIN@11 | Foswiki::Query::OP_length::
1 | 1 | 1 | 9µs | 12µs | BEGIN@12 | Foswiki::Query::OP_length::
1 | 1 | 1 | 3µs | 3µs | BEGIN@14 | Foswiki::Query::OP_length::
0 | 0 | 0 | 0s | 0s | evaluate | Foswiki::Query::OP_length::
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_length | ||||
6 | |||||
7 | =cut | ||||
8 | |||||
9 | package Foswiki::Query::OP_length; | ||||
10 | |||||
11 | 2 | 25µs | 2 | 36µs | # spent 24µs (12+12) within Foswiki::Query::OP_length::BEGIN@11 which was called:
# once (12µs+12µs) by Foswiki::Query::Parser::BEGIN@66 at line 11 # spent 24µs making 1 call to Foswiki::Query::OP_length::BEGIN@11
# spent 12µs making 1 call to strict::import |
12 | 2 | 23µs | 2 | 16µs | # spent 12µs (9+4) within Foswiki::Query::OP_length::BEGIN@12 which was called:
# once (9µs+4µs) by Foswiki::Query::Parser::BEGIN@66 at line 12 # spent 12µs making 1 call to Foswiki::Query::OP_length::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 138µs | 1 | 3µs | # spent 3µs within Foswiki::Query::OP_length::BEGIN@14 which was called:
# once (3µs+0s) by Foswiki::Query::Parser::BEGIN@66 at line 14 # spent 3µs making 1 call to Foswiki::Query::OP_length::BEGIN@14 |
15 | 1 | 6µs | our @ISA = ('Foswiki::Query::UnaryOP'); | ||
16 | |||||
17 | # spent 69µs (35+34) within Foswiki::Query::OP_length::new which was called 3 times, avg 23µs/call:
# 3 times (35µs+34µs) by Foswiki::Query::Parser::new at line 112 of /var/www/foswikidev/core/lib/Foswiki/Query/Parser.pm, avg 23µs/call | ||||
18 | 3 | 2µs | my $class = shift; | ||
19 | 3 | 30µs | 3 | 34µs | return $class->SUPER::new( name => 'length', prec => 1000 ); # spent 34µs making 3 calls to Foswiki::Query::UnaryOP::new, avg 11µs/call |
20 | } | ||||
21 | |||||
22 | sub evaluate { | ||||
23 | my $this = shift; | ||||
24 | my $node = shift; | ||||
25 | my $a = $node->{params}[0]; | ||||
26 | my $val = $a->evaluate(@_) || ''; | ||||
27 | return 0 unless defined $val; | ||||
28 | if ( ref($val) eq 'ARRAY' ) { | ||||
29 | return scalar(@$val); | ||||
30 | } | ||||
31 | elsif ( ref($val) eq 'HASH' ) { | ||||
32 | return scalar( keys %$val ); | ||||
33 | } | ||||
34 | elsif ( !ref($val) ) { | ||||
35 | return length($val); | ||||
36 | } | ||||
37 | return 1; | ||||
38 | } | ||||
39 | |||||
40 | 1 | 3µs | 1; | ||
41 | __END__ |