← Index
NYTProf Performance Profile   « line view »
For bin/benchmark-perlformance
  Run on Fri Apr 17 15:31:48 2015
Reported on Fri Apr 17 15:32:02 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/DPath/Filters.pm
StatementsExecuted 24 statements in 446µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1119µs16µsData::DPath::Filters::::BEGIN@57Data::DPath::Filters::BEGIN@57
1119µs15µsData::DPath::Filters::::BEGIN@64Data::DPath::Filters::BEGIN@64
1118µs70µsData::DPath::Filters::::BEGIN@15Data::DPath::Filters::BEGIN@15
1118µs16µsData::DPath::Filters::::BEGIN@32Data::DPath::Filters::BEGIN@32
1118µs14µsData::DPath::Filters::::BEGIN@50Data::DPath::Filters::BEGIN@50
1117µs10µsData::DPath::Filters::::BEGIN@11Data::DPath::Filters::BEGIN@11
1117µs16µsData::DPath::Filters::::BEGIN@14Data::DPath::Filters::BEGIN@14
1117µs7µsData::DPath::Filters::::BEGIN@2Data::DPath::Filters::BEGIN@2
1116µs25µsData::DPath::Filters::::BEGIN@13Data::DPath::Filters::BEGIN@13
1116µs16µsData::DPath::Filters::::BEGIN@10Data::DPath::Filters::BEGIN@10
0000s0sData::DPath::Filters::::affeData::DPath::Filters::affe
0000s0sData::DPath::Filters::::idxData::DPath::Filters::idx
0000s0sData::DPath::Filters::::is_reftypeData::DPath::Filters::is_reftype
0000s0sData::DPath::Filters::::isaData::DPath::Filters::isa
0000s0sData::DPath::Filters::::keyData::DPath::Filters::key
0000s0sData::DPath::Filters::::reftypeData::DPath::Filters::reftype
0000s0sData::DPath::Filters::::sizeData::DPath::Filters::size
0000s0sData::DPath::Filters::::valueData::DPath::Filters::value
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Data::DPath::Filters;
2
# spent 7µs within Data::DPath::Filters::BEGIN@2 which was called: # once (7µs+0s) by Data::DPath::Context::BEGIN@18 at line 4
BEGIN {
314µs $Data::DPath::Filters::AUTHORITY = 'cpan:SCHWIGON';
4120µs17µs}
# spent 7µs making 1 call to Data::DPath::Filters::BEGIN@2
5{
62900ns $Data::DPath::Filters::VERSION = '0.49';
7}
8# ABSTRACT: Magic functions available inside filter conditions
9
10217µs225µs
# spent 16µs (6+10) within Data::DPath::Filters::BEGIN@10 which was called: # once (6µs+10µs) by Data::DPath::Context::BEGIN@18 at line 10
use strict;
# spent 16µs making 1 call to Data::DPath::Filters::BEGIN@10 # spent 10µs making 1 call to strict::import
11216µs213µs
# spent 10µs (7+3) within Data::DPath::Filters::BEGIN@11 which was called: # once (7µs+3µs) by Data::DPath::Context::BEGIN@18 at line 11
use warnings;
# spent 10µs making 1 call to Data::DPath::Filters::BEGIN@11 # spent 3µs making 1 call to warnings::import
12
13218µs243µs
# spent 25µs (6+18) within Data::DPath::Filters::BEGIN@13 which was called: # once (6µs+18µs) by Data::DPath::Context::BEGIN@18 at line 13
use Data::Dumper;
# spent 25µs making 1 call to Data::DPath::Filters::BEGIN@13 # spent 18µs making 1 call to Exporter::import
14227µs226µs
# spent 16µs (7+10) within Data::DPath::Filters::BEGIN@14 which was called: # once (7µs+10µs) by Data::DPath::Context::BEGIN@18 at line 14
use Scalar::Util;
# spent 16µs making 1 call to Data::DPath::Filters::BEGIN@14 # spent 10µs making 1 call to Exporter::import
15
# spent 70µs (8+62) within Data::DPath::Filters::BEGIN@15 which was called: # once (8µs+62µs) by Data::DPath::Context::BEGIN@18 at line 19
use constant {
16112µs162µs HASH => 'HASH',
# spent 62µs making 1 call to constant::import
17 ARRAY => 'ARRAY',
18 SCALAR => 'SCALAR',
19157µs170µs };
# spent 70µs making 1 call to Data::DPath::Filters::BEGIN@15
20
2110sour $idx;
2210sour $p; # current point
23
24sub affe {
25 return $_ eq 'affe' ? 1 : 0;
26}
27
28sub idx { $idx }
29
30sub size()
31{
322105µs224µs
# spent 16µs (8+8) within Data::DPath::Filters::BEGIN@32 which was called: # once (8µs+8µs) by Data::DPath::Context::BEGIN@18 at line 32
no warnings 'uninitialized';
# spent 16µs making 1 call to Data::DPath::Filters::BEGIN@32 # spent 8µs making 1 call to warnings::unimport
33
34 return -1 unless defined $_;
35 # speed optimization: first try faster ref, then reftype
36 # ref
37 return scalar @$_ if ref $_ eq ARRAY;
38 return scalar keys %$_ if ref $_ eq HASH;
39 return 1 if ref \$_ eq SCALAR;
40 # reftype
41 return scalar @$_ if Scalar::Util::reftype $_ eq ARRAY;
42 return scalar keys %$_ if Scalar::Util::reftype $_ eq HASH;
43 return 1 if Scalar::Util::reftype \$_ eq SCALAR;
44 # else
45 return -1;
46}
47
48sub key()
49{
50246µs221µs
# spent 14µs (8+7) within Data::DPath::Filters::BEGIN@50 which was called: # once (8µs+7µs) by Data::DPath::Context::BEGIN@18 at line 50
no warnings 'uninitialized';
# spent 14µs making 1 call to Data::DPath::Filters::BEGIN@50 # spent 7µs making 1 call to warnings::unimport
51 my $attrs = defined $p->attrs ? $p->attrs : {};
52 return $attrs->{key};
53}
54
55sub value()
56{
57238µs222µs
# spent 16µs (9+7) within Data::DPath::Filters::BEGIN@57 which was called: # once (9µs+7µs) by Data::DPath::Context::BEGIN@18 at line 57
no warnings 'uninitialized';
# spent 16µs making 1 call to Data::DPath::Filters::BEGIN@57 # spent 7µs making 1 call to warnings::unimport
58 return $_;
59}
60
61sub isa($) {
62 my ($classname) = @_;
63
64283µs221µs
# spent 15µs (9+6) within Data::DPath::Filters::BEGIN@64 which was called: # once (9µs+6µs) by Data::DPath::Context::BEGIN@18 at line 64
no warnings 'uninitialized';
# spent 15µs making 1 call to Data::DPath::Filters::BEGIN@64 # spent 6µs making 1 call to warnings::unimport
65 #print STDERR "*** value ", Dumper($_ ? $_ : "UNDEF");
66 return $_->isa($classname) if Scalar::Util::blessed $_;
67 return undef;
68}
69
70sub reftype() {
71 return Scalar::Util::reftype($_);
72}
73
74sub is_reftype($) {
75 return (Scalar::Util::reftype($_) eq shift);
76}
77
7812µs1;
79
80=pod
81
82=encoding utf-8
83
84=head1 NAME
85
86Data::DPath::Filters - Magic functions available inside filter conditions
87
88=head1 API METHODS
89
90=head2 affe
91
92Mysterious test function. Will vanish. Soon. Or will it really? No,
93probably not. I like it. :-)
94
95Returns true if the value eq "affe".
96
97=head2 idx
98
99Returns the current index inside array elements.
100
101Please note that the current matching elements might not be in a
102defined order if resulting from anything else than arrays.
103
104=head2 size
105
106Returns the size of the current element. If it is a hash ref it
107returns number of elements, if hashref it returns number of keys, if
108scalar it returns 1, everything else returns -1.
109
110=head2 key
111
112If it is a hashref returns the key under which the current element is
113associated as value. Else it returns undef.
114
115This gives the key() function kind of a "look back" behaviour because
116the associated point is already after that key.
117
118=head2 value
119
120Returns the value of the current element.
121
122=head2 isa
123
124Frontend to UNIVERSAL::isa. True if the current element is_a given
125class.
126
127=head2 reftype
128
129Frontend to Scalar::Util::reftype.
130
131Returns Scalar::Util::reftype of current element $_. With this you can
132do comparison by yourself with C<eq>, C<=~>, C<~~> or whatever in
133filter expressions.
134
135=head2 is_reftype($EXPECTED_TYPE)
136
137Frontend to Scalar::Util::reftype.
138
139Checks whether Scalar::Util::reftype of current element $_ equals the
140provided argument $EXPECTED_TYPE and returns true/false.
141
142=head1 AUTHOR
143
144Steffen Schwigon <ss5@renormalist.net>
145
146=head1 COPYRIGHT AND LICENSE
147
148This software is copyright (c) 2012 by Steffen Schwigon.
149
150This is free software; you can redistribute it and/or modify it under
151the same terms as the Perl 5 programming language system itself.
152
153=cut
154
155__END__