| Filename | /home/ss5/local/projects/data-dpath/lib/Data/DPath/Filters.pm |
| Statements | Executed 23 statements in 584µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 17µs | 33µs | Data::DPath::Filters::BEGIN@4 |
| 1 | 1 | 1 | 12µs | 22µs | Data::DPath::Filters::BEGIN@44 |
| 1 | 1 | 1 | 11µs | 76µs | Data::DPath::Filters::BEGIN@9 |
| 1 | 1 | 1 | 10µs | 23µs | Data::DPath::Filters::BEGIN@26 |
| 1 | 1 | 1 | 10µs | 20µs | Data::DPath::Filters::BEGIN@51 |
| 1 | 1 | 1 | 10µs | 15µs | Data::DPath::Filters::BEGIN@5 |
| 1 | 1 | 1 | 10µs | 25µs | Data::DPath::Filters::BEGIN@8 |
| 1 | 1 | 1 | 9µs | 18µs | Data::DPath::Filters::BEGIN@58 |
| 1 | 1 | 1 | 9µs | 36µs | Data::DPath::Filters::BEGIN@7 |
| 2 | 2 | 2 | 6µs | 6µs | Data::DPath::Filters::value |
| 0 | 0 | 0 | 0s | 0s | Data::DPath::Filters::affe |
| 0 | 0 | 0 | 0s | 0s | Data::DPath::Filters::idx |
| 0 | 0 | 0 | 0s | 0s | Data::DPath::Filters::is_reftype |
| 0 | 0 | 0 | 0s | 0s | Data::DPath::Filters::isa |
| 0 | 0 | 0 | 0s | 0s | Data::DPath::Filters::key |
| 0 | 0 | 0 | 0s | 0s | Data::DPath::Filters::reftype |
| 0 | 0 | 0 | 0s | 0s | Data::DPath::Filters::size |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Data::DPath::Filters; | ||||
| 2 | # ABSTRACT: Magic functions available inside filter conditions | ||||
| 3 | |||||
| 4 | 2 | 29µs | 2 | 49µs | # spent 33µs (17+16) within Data::DPath::Filters::BEGIN@4 which was called:
# once (17µs+16µs) by Data::DPath::Context::BEGIN@12 at line 4 # spent 33µs making 1 call to Data::DPath::Filters::BEGIN@4
# spent 16µs making 1 call to strict::import |
| 5 | 2 | 24µs | 2 | 20µs | # spent 15µs (10+5) within Data::DPath::Filters::BEGIN@5 which was called:
# once (10µs+5µs) by Data::DPath::Context::BEGIN@12 at line 5 # spent 15µs making 1 call to Data::DPath::Filters::BEGIN@5
# spent 5µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 25µs | 2 | 63µs | # spent 36µs (9+27) within Data::DPath::Filters::BEGIN@7 which was called:
# once (9µs+27µs) by Data::DPath::Context::BEGIN@12 at line 7 # spent 36µs making 1 call to Data::DPath::Filters::BEGIN@7
# spent 27µs making 1 call to Exporter::import |
| 8 | 2 | 35µs | 2 | 40µs | # spent 25µs (10+16) within Data::DPath::Filters::BEGIN@8 which was called:
# once (10µs+16µs) by Data::DPath::Context::BEGIN@12 at line 8 # spent 25µs making 1 call to Data::DPath::Filters::BEGIN@8
# spent 16µs making 1 call to Exporter::import |
| 9 | # spent 76µs (11+65) within Data::DPath::Filters::BEGIN@9 which was called:
# once (11µs+65µs) by Data::DPath::Context::BEGIN@12 at line 13 | ||||
| 10 | 1 | 8µs | 1 | 65µs | HASH => 'HASH', # spent 65µs making 1 call to constant::import |
| 11 | ARRAY => 'ARRAY', | ||||
| 12 | SCALAR => 'SCALAR', | ||||
| 13 | 1 | 78µs | 1 | 76µs | }; # spent 76µs making 1 call to Data::DPath::Filters::BEGIN@9 |
| 14 | |||||
| 15 | 1 | 200ns | our $idx; | ||
| 16 | 1 | 100ns | our $p; # current point | ||
| 17 | |||||
| 18 | sub affe { | ||||
| 19 | return $_ eq 'affe' ? 1 : 0; | ||||
| 20 | } | ||||
| 21 | |||||
| 22 | sub idx { $idx } | ||||
| 23 | |||||
| 24 | sub size() | ||||
| 25 | { | ||||
| 26 | 2 | 153µs | 2 | 35µs | # spent 23µs (10+12) within Data::DPath::Filters::BEGIN@26 which was called:
# once (10µs+12µs) by Data::DPath::Context::BEGIN@12 at line 26 # spent 23µs making 1 call to Data::DPath::Filters::BEGIN@26
# spent 12µs making 1 call to warnings::unimport |
| 27 | |||||
| 28 | return -1 unless defined $_; | ||||
| 29 | # speed optimization: first try faster ref, then reftype | ||||
| 30 | # ref | ||||
| 31 | return scalar @$_ if ref $_ eq ARRAY; | ||||
| 32 | return scalar keys %$_ if ref $_ eq HASH; | ||||
| 33 | return 1 if ref \$_ eq SCALAR; | ||||
| 34 | # reftype | ||||
| 35 | return scalar @$_ if Scalar::Util::reftype $_ eq ARRAY; | ||||
| 36 | return scalar keys %$_ if Scalar::Util::reftype $_ eq HASH; | ||||
| 37 | return 1 if Scalar::Util::reftype \$_ eq SCALAR; | ||||
| 38 | # else | ||||
| 39 | return -1; | ||||
| 40 | } | ||||
| 41 | |||||
| 42 | sub key() | ||||
| 43 | { | ||||
| 44 | 2 | 67µs | 2 | 33µs | # spent 22µs (12+10) within Data::DPath::Filters::BEGIN@44 which was called:
# once (12µs+10µs) by Data::DPath::Context::BEGIN@12 at line 44 # spent 22µs making 1 call to Data::DPath::Filters::BEGIN@44
# spent 10µs making 1 call to warnings::unimport |
| 45 | my $attrs = defined $p->attrs ? $p->attrs : {}; | ||||
| 46 | return $attrs->{key}; | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | sub value() | ||||
| 50 | # spent 6µs within Data::DPath::Filters::value which was called 2 times, avg 3µs/call:
# once (3µs+0s) by main::__ANON__[(eval 67)[/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/5.16.3/Safe.pm:23]:1] at line 1 of (eval 68)[(eval 67)[Safe.pm:23]:1]
# once (2µs+0s) by main::__ANON__[(eval 55)[/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/5.16.3/Safe.pm:23]:1] at line 1 of (eval 56)[(eval 55)[Safe.pm:23]:1] | ||||
| 51 | 2 | 52µs | 2 | 29µs | # spent 20µs (10+10) within Data::DPath::Filters::BEGIN@51 which was called:
# once (10µs+10µs) by Data::DPath::Context::BEGIN@12 at line 51 # spent 20µs making 1 call to Data::DPath::Filters::BEGIN@51
# spent 10µs making 1 call to warnings::unimport |
| 52 | 2 | 14µs | return $_; | ||
| 53 | } | ||||
| 54 | |||||
| 55 | sub isa($) { | ||||
| 56 | my ($classname) = @_; | ||||
| 57 | |||||
| 58 | 2 | 96µs | 2 | 27µs | # spent 18µs (9+9) within Data::DPath::Filters::BEGIN@58 which was called:
# once (9µs+9µs) by Data::DPath::Context::BEGIN@12 at line 58 # spent 18µs making 1 call to Data::DPath::Filters::BEGIN@58
# spent 9µs making 1 call to warnings::unimport |
| 59 | #print STDERR "*** value ", Dumper($_ ? $_ : "UNDEF"); | ||||
| 60 | return $_->isa($classname) if Scalar::Util::blessed $_; | ||||
| 61 | return undef; | ||||
| 62 | } | ||||
| 63 | |||||
| 64 | sub reftype() { | ||||
| 65 | return Scalar::Util::reftype($_); | ||||
| 66 | } | ||||
| 67 | |||||
| 68 | sub is_reftype($) { | ||||
| 69 | return (Scalar::Util::reftype($_) eq shift); | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | 1 | 3µs | 1; | ||
| 73 | |||||
| 74 | __END__ |