← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:49 2015

Filename/usr/lib/x86_64-linux-gnu/perl5/5.20/XML/LibXML/AttributeHash.pm
StatementsExecuted 14 statements in 934µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11111µs23µsXML::LibXML::AttributeHash::::BEGIN@3XML::LibXML::AttributeHash::BEGIN@3
1118µs8µsXML::LibXML::AttributeHash::::BEGIN@6XML::LibXML::AttributeHash::BEGIN@6
1117µs12µsXML::LibXML::AttributeHash::::BEGIN@4XML::LibXML::AttributeHash::BEGIN@4
1116µs21µsXML::LibXML::AttributeHash::::BEGIN@9XML::LibXML::AttributeHash::BEGIN@9
1114µs4µsXML::LibXML::AttributeHash::::BEGIN@13XML::LibXML::AttributeHash::BEGIN@13
1114µs4µsXML::LibXML::AttributeHash::::BEGIN@5XML::LibXML::AttributeHash::BEGIN@5
0000s0sXML::LibXML::AttributeHash::::CLEARXML::LibXML::AttributeHash::CLEAR
0000s0sXML::LibXML::AttributeHash::::DELETEXML::LibXML::AttributeHash::DELETE
0000s0sXML::LibXML::AttributeHash::::EXISTSXML::LibXML::AttributeHash::EXISTS
0000s0sXML::LibXML::AttributeHash::::FETCHXML::LibXML::AttributeHash::FETCH
0000s0sXML::LibXML::AttributeHash::::FIRSTKEYXML::LibXML::AttributeHash::FIRSTKEY
0000s0sXML::LibXML::AttributeHash::::NEXTKEYXML::LibXML::AttributeHash::NEXTKEY
0000s0sXML::LibXML::AttributeHash::::SCALARXML::LibXML::AttributeHash::SCALAR
0000s0sXML::LibXML::AttributeHash::::STOREXML::LibXML::AttributeHash::STORE
0000s0sXML::LibXML::AttributeHash::::TIEHASHXML::LibXML::AttributeHash::TIEHASH
0000s0sXML::LibXML::AttributeHash::::all_keysXML::LibXML::AttributeHash::all_keys
0000s0sXML::LibXML::AttributeHash::::elementXML::LibXML::AttributeHash::element
0000s0sXML::LibXML::AttributeHash::::from_clarkXML::LibXML::AttributeHash::from_clark
0000s0sXML::LibXML::AttributeHash::::to_clarkXML::LibXML::AttributeHash::to_clark
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package XML::LibXML::AttributeHash;
2
3222µs234µs
# spent 23µs (11+11) within XML::LibXML::AttributeHash::BEGIN@3 which was called: # once (11µs+11µs) by XML::LibXML::Element::BEGIN@1536 at line 3
use strict;
# spent 23µs making 1 call to XML::LibXML::AttributeHash::BEGIN@3 # spent 11µs making 1 call to strict::import
4220µs217µs
# spent 12µs (7+5) within XML::LibXML::AttributeHash::BEGIN@4 which was called: # once (7µs+5µs) by XML::LibXML::Element::BEGIN@1536 at line 4
use warnings;
# spent 12µs making 1 call to XML::LibXML::AttributeHash::BEGIN@4 # spent 5µs making 1 call to warnings::import
5217µs14µs
# spent 4µs within XML::LibXML::AttributeHash::BEGIN@5 which was called: # once (4µs+0s) by XML::LibXML::Element::BEGIN@1536 at line 5
use Scalar::Util qw//;
# spent 4µs making 1 call to XML::LibXML::AttributeHash::BEGIN@5
6238µs18µs
# spent 8µs within XML::LibXML::AttributeHash::BEGIN@6 which was called: # once (8µs+0s) by XML::LibXML::Element::BEGIN@1536 at line 6
use Tie::Hash;
# spent 8µs making 1 call to XML::LibXML::AttributeHash::BEGIN@6
715µsour @ISA = qw/Tie::Hash/;
8
9262µs237µs
# spent 21µs (6+16) within XML::LibXML::AttributeHash::BEGIN@9 which was called: # once (6µs+16µs) by XML::LibXML::Element::BEGIN@1536 at line 9
use vars qw($VERSION);
# spent 21µs making 1 call to XML::LibXML::AttributeHash::BEGIN@9 # spent 16µs making 1 call to vars::import
101300ns$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
11
12BEGIN
13
# spent 4µs within XML::LibXML::AttributeHash::BEGIN@13 which was called: # once (4µs+0s) by XML::LibXML::Element::BEGIN@1536 at line 17
{
14 *__HAS_WEAKEN = defined(&Scalar::Util::weaken)
15 ? sub () { 1 }
1614µs : sub () { 0 };
171762µs14µs};
# spent 4µs making 1 call to XML::LibXML::AttributeHash::BEGIN@13
18
19sub element
20{
21 return $_[0][0];
22}
23
24sub from_clark
25{
26 my ($self, $str) = @_;
27 if ($str =~ m! \{ (.+) \} (.+) !x)
28 {
29 return ($1, $2);
30 }
31 return (undef, $str);
32}
33
34sub to_clark
35{
36 my ($self, $ns, $local) = @_;
37 defined $ns ? "{$ns}$local" : $local;
38}
39
40sub all_keys
41{
42 my ($self, @keys) = @_;
43
44 my $elem = $self->element;
45
46 foreach my $attr (defined($elem) ? $elem->attributes : ())
47 {
48 if (! $attr->isa('XML::LibXML::Namespace'))
49 {
50 push @keys, $self->to_clark($attr->namespaceURI, $attr->localname);
51 }
52 }
53
54 return sort @keys;
55}
56
57sub TIEHASH
58{
59 my ($class, $element, %args) = @_;
60 my $self = bless [$element, undef, \%args], $class;
61 if (__HAS_WEAKEN and $args{weaken})
62 {
63 Scalar::Util::weaken( $self->[0] );
64 }
65 return $self;
66}
67
68sub STORE
69{
70 my ($self, $key, $value) = @_;
71 my ($key_ns, $key_local) = $self->from_clark($key);
72 if (defined $key_ns)
73 {
74 return $self->element->setAttributeNS($key_ns, "xxx:$key_local", "$value");
75 }
76 else
77 {
78 return $self->element->setAttribute($key_local, "$value");
79 }
80}
81
82sub FETCH
83{
84 my ($self, $key) = @_;
85 my ($key_ns, $key_local) = $self->from_clark($key);
86 if (defined $key_ns)
87 {
88 return $self->element->getAttributeNS($key_ns, "$key_local");
89 }
90 else
91 {
92 return $self->element->getAttribute($key_local);
93 }
94}
95
96sub EXISTS
97{
98 my ($self, $key) = @_;
99 my ($key_ns, $key_local) = $self->from_clark($key);
100 if (defined $key_ns)
101 {
102 return $self->element->hasAttributeNS($key_ns, "$key_local");
103 }
104 else
105 {
106 return $self->element->hasAttribute($key_local);
107 }
108}
109
110sub DELETE
111{
112 my ($self, $key) = @_;
113 my ($key_ns, $key_local) = $self->from_clark($key);
114 if (defined $key_ns)
115 {
116 return $self->element->removeAttributeNS($key_ns, "$key_local");
117 }
118 else
119 {
120 return $self->element->removeAttribute($key_local);
121 }
122}
123
124sub FIRSTKEY
125{
126 my ($self) = @_;
127 my @keys = $self->all_keys;
128 $self->[1] = \@keys;
129 if (wantarray)
130 {
131 return ($keys[0], $self->FETCH($keys[0]));
132 }
133 $keys[0];
134}
135
136sub NEXTKEY
137{
138 my ($self, $lastkey) = @_;
139 my @keys = defined $self->[1] ? @{ $self->[1] } : $self->all_keys;
140 my $found;
141 foreach my $k (@keys)
142 {
143 if ($k gt $lastkey)
144 {
145 $found = $k and last;
146 }
147 }
148 if (!defined $found)
149 {
150 $self->[1] = undef;
151 return;
152 }
153 if (wantarray)
154 {
155 return ($found, $self->FETCH($found));
156 }
157 return $found;
158}
159
160sub SCALAR
161{
162 my ($self) = @_;
163 return $self->element;
164}
165
166sub CLEAR
167{
168 my ($self) = @_;
169 foreach my $k ($self->all_keys)
170 {
171 $self->DELETE($k);
172 }
173 return $self;
174}
175
17613µs__PACKAGE__
177__END__