Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/NodeList.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 01.HTTP.t
Run on Tue May 4 14:17:45 2010
Reported on Tue May 4 14:18:12 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/NodeList.pm
Statements Executed | 21
Statement Execution Time | 588µs

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 337µs | 1.41ms | XML::LibXML::NodeList::::BEGIN@12XML::LibXML::NodeList::BEGIN@12
1 | 1 | 1 | 16µs | 19µs | XML::LibXML::NodeList::::BEGIN@11XML::LibXML::NodeList::BEGIN@11
1 | 1 | 1 | 13µs | 43µs | XML::LibXML::NodeList::::BEGIN@20XML::LibXML::NodeList::BEGIN@20
1 | 1 | 1 | 6µs | 24µs | XML::LibXML::NodeList::::BEGIN@16XML::LibXML::NodeList::BEGIN@16
1 | 1 | 1 | 5µs | 5µs | XML::LibXML::NodeList::::BEGIN@13XML::LibXML::NodeList::BEGIN@13
1 | 1 | 1 | 4µs | 4µs | XML::LibXML::NodeList::::BEGIN@14XML::LibXML::NodeList::BEGIN@14
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::appendXML::LibXML::NodeList::append
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::get_nodeXML::LibXML::NodeList::get_node
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::get_nodelistXML::LibXML::NodeList::get_nodelist
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::iteratorXML::LibXML::NodeList::iterator
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::newXML::LibXML::NodeList::new
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::new_from_refXML::LibXML::NodeList::new_from_ref
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::popXML::LibXML::NodeList::pop
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::prependXML::LibXML::NodeList::prepend
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::pushXML::LibXML::NodeList::push
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::shiftXML::LibXML::NodeList::shift
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::sizeXML::LibXML::NodeList::size
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::string_valueXML::LibXML::NodeList::string_value
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::to_booleanXML::LibXML::NodeList::to_boolean
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::to_literalXML::LibXML::NodeList::to_literal
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::to_numberXML::LibXML::NodeList::to_number
0 | 0 | 0 | 0s | 0s | XML::LibXML::NodeList::::unshiftXML::LibXML::NodeList::unshift

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | # $Id: NodeList.pm 785 2009-07-16 14:17:46Z pajas $
2 |  |  |  |  | #
3 |  |  |  |  | # This is free software, you may use it and distribute it under the same terms as
4 |  |  |  |  | # Perl itself.
5 |  |  |  |  | #
6 |  |  |  |  | # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas
7 |  |  |  |  | #
8 |  |  |  |  | #
9 |  |  |  |  |
10 |  |  |  |  | package XML::LibXML::NodeList;
11 | 3 | 22µs | 2 | 22µs | # spent 19µs (16+3) within XML::LibXML::NodeList::BEGIN@11 which was called # once (16µs+3µs) by XML::LibXML::BEGIN@24 at line 11 use strict; # spent 19µs making 1 call to XML::LibXML::NodeList::BEGIN@11 # spent 3µs making 1 call to strict::import
12 | 3 | 91µs | 1 | 1.41ms | # spent 1.41ms (337µs+1.08) within XML::LibXML::NodeList::BEGIN@12 which was called # once (337µs+1.08ms) by XML::LibXML::BEGIN@24 at line 12 use XML::LibXML::Boolean; # spent 1.41ms making 1 call to XML::LibXML::NodeList::BEGIN@12
13 | 3 | 18µs | 1 | 5µs | # spent 5µs within XML::LibXML::NodeList::BEGIN@13 which was called # once (5µs+0s) by XML::LibXML::BEGIN@24 at line 13 use XML::LibXML::Literal; # spent 5µs making 1 call to XML::LibXML::NodeList::BEGIN@13
14 | 3 | 20µs | 1 | 4µs | # spent 4µs within XML::LibXML::NodeList::BEGIN@14 which was called # once (4µs+0s) by XML::LibXML::BEGIN@24 at line 14 use XML::LibXML::Number; # spent 4µs making 1 call to XML::LibXML::NodeList::BEGIN@14
15 |  |  |  |  |
16 | 3 | 36µs | 2 | 42µs | # spent 24µs (6+18) within XML::LibXML::NodeList::BEGIN@16 which was called # once (6µs+18µs) by XML::LibXML::BEGIN@24 at line 16 use vars qw ($VERSION); # spent 24µs making 1 call to XML::LibXML::NodeList::BEGIN@16 # spent 18µs making 1 call to vars::import
17 | 1 | 600ns |  |  | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE
18 |  |  |  |  |
19 |  |  |  |  | use overload
20 | 1 | 10µs | 1 | 30µs | # spent 43µs (13+30) within XML::LibXML::NodeList::BEGIN@20 which was called # once (13µs+30µs) by XML::LibXML::BEGIN@24 at line 22 '""' => \&to_literal, # spent 30µs making 1 call to overload::import
21 |  |  |  |  | 'bool' => \&to_boolean,
22 | 2 | 385µs | 1 | 43µs | ; # spent 43µs making 1 call to XML::LibXML::NodeList::BEGIN@20
23 |  |  |  |  |
24 |  |  |  |  | sub new {
25 |  |  |  |  | my $class = shift;
26 |  |  |  |  | bless [@_], $class;
27 |  |  |  |  | }
28 |  |  |  |  |
29 |  |  |  |  | sub new_from_ref {
30 |  |  |  |  | my ($class,$array_ref,$reuse) = @_;
31 |  |  |  |  | return bless $reuse ? $array_ref : [@$array_ref], $class;
32 |  |  |  |  | }
33 |  |  |  |  |
34 |  |  |  |  | sub pop {
35 |  |  |  |  | my $self = CORE::shift;
36 |  |  |  |  | CORE::pop @$self;
37 |  |  |  |  | }
38 |  |  |  |  |
39 |  |  |  |  | sub push {
40 |  |  |  |  | my $self = CORE::shift;
41 |  |  |  |  | CORE::push @$self, @_;
42 |  |  |  |  | }
43 |  |  |  |  |
44 |  |  |  |  | sub append {
45 |  |  |  |  | my $self = CORE::shift;
46 |  |  |  |  | my ($nodelist) = @_;
47 |  |  |  |  | CORE::push @$self, $nodelist->get_nodelist;
48 |  |  |  |  | }
49 |  |  |  |  |
50 |  |  |  |  | sub shift {
51 |  |  |  |  | my $self = CORE::shift;
52 |  |  |  |  | CORE::shift @$self;
53 |  |  |  |  | }
54 |  |  |  |  |
55 |  |  |  |  | sub unshift {
56 |  |  |  |  | my $self = CORE::shift;
57 |  |  |  |  | CORE::unshift @$self, @_;
58 |  |  |  |  | }
59 |  |  |  |  |
60 |  |  |  |  | sub prepend {
61 |  |  |  |  | my $self = CORE::shift;
62 |  |  |  |  | my ($nodelist) = @_;
63 |  |  |  |  | CORE::unshift @$self, $nodelist->get_nodelist;
64 |  |  |  |  | }
65 |  |  |  |  |
66 |  |  |  |  | sub size {
67 |  |  |  |  | my $self = CORE::shift;
68 |  |  |  |  | scalar @$self;
69 |  |  |  |  | }
70 |  |  |  |  |
71 |  |  |  |  | sub get_node {
72 |  |  |  |  | # uses array index starting at 1, not 0
73 |  |  |  |  | # this is mainly because of XPath.
74 |  |  |  |  | my $self = CORE::shift;
75 |  |  |  |  | my ($pos) = @_;
76 |  |  |  |  | $self->[$pos - 1];
77 |  |  |  |  | }
78 |  |  |  |  |
79 | 1 | 1µs |  |  | *item = \&get_node;
80 |  |  |  |  |
81 |  |  |  |  | sub get_nodelist {
82 |  |  |  |  | my $self = CORE::shift;
83 |  |  |  |  | @$self;
84 |  |  |  |  | }
85 |  |  |  |  |
86 |  |  |  |  | sub to_boolean {
87 |  |  |  |  | my $self = CORE::shift;
88 |  |  |  |  | return (@$self > 0) ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False;
89 |  |  |  |  | }
90 |  |  |  |  |
91 |  |  |  |  | # string-value of a nodelist is the string-value of the first node
92 |  |  |  |  | sub string_value {
93 |  |  |  |  | my $self = CORE::shift;
94 |  |  |  |  | return '' unless @$self;
95 |  |  |  |  | return $self->[0]->string_value;
96 |  |  |  |  | }
97 |  |  |  |  |
98 |  |  |  |  | sub to_literal {
99 |  |  |  |  | my $self = CORE::shift;
100 |  |  |  |  | return XML::LibXML::Literal->new(
101 |  |  |  |  | join('', grep {defined $_} map { $_->string_value } @$self)
102 |  |  |  |  | );
103 |  |  |  |  | }
104 |  |  |  |  |
105 |  |  |  |  | sub to_number {
106 |  |  |  |  | my $self = CORE::shift;
107 |  |  |  |  | return XML::LibXML::Number->new(
108 |  |  |  |  | $self->to_literal
109 |  |  |  |  | );
110 |  |  |  |  | }
111 |  |  |  |  |
112 |  |  |  |  | sub iterator {
113 |  |  |  |  | warn "this function is obsolete!\nIt was disabled in version 1.54\n";
114 |  |  |  |  | return undef;
115 |  |  |  |  | }
116 |  |  |  |  |
117 | 1 | 4µs |  |  | 1;
118 |  |  |  |  | __END__
119 |  |  |  |  |
120 |  |  |  |  | =head1 NAME
121 |  |  |  |  |
122 |  |  |  |  | XML::LibXML::NodeList - a list of XML document nodes
123 |  |  |  |  |
124 |  |  |  |  | =head1 DESCRIPTION
125 |  |  |  |  |
126 |  |  |  |  | An XML::LibXML::NodeList object contains an ordered list of nodes, as
127 |  |  |  |  | detailed by the W3C DOM documentation of Node Lists.
128 |  |  |  |  |
129 |  |  |  |  | =head1 SYNOPSIS
130 |  |  |  |  |
131 |  |  |  |  | my $results = $dom->findnodes('//somepath');
132 |  |  |  |  | foreach my $context ($results->get_nodelist) {
133 |  |  |  |  | my $newresults = $context->findnodes('./other/element');
134 |  |  |  |  | ...
135 |  |  |  |  | }
136 |  |  |  |  |
137 |  |  |  |  | =head1 API
138 |  |  |  |  |
139 |  |  |  |  | =head2 new()
140 |  |  |  |  |
141 |  |  |  |  | You will almost never have to create a new NodeSet object, as it is all
142 |  |  |  |  | done for you by XPath.
143 |  |  |  |  |
144 |  |  |  |  | =head2 get_nodelist()
145 |  |  |  |  |
146 |  |  |  |  | Returns a list of nodes, the contents of the node list, as a perl list.
147 |  |  |  |  |
148 |  |  |  |  | =head2 string_value()
149 |  |  |  |  |
150 |  |  |  |  | Returns the string-value of the first node in the list.
151 |  |  |  |  | See the XPath specification for what "string-value" means.
152 |  |  |  |  |
153 |  |  |  |  | =head2 to_literal()
154 |  |  |  |  |
155 |  |  |  |  | Returns the concatenation of all the string-values of all
156 |  |  |  |  | the nodes in the list.
157 |  |  |  |  |
158 |  |  |  |  | =head2 get_node($pos)
159 |  |  |  |  |
160 |  |  |  |  | Returns the node at $pos. The node position in XPath is based at 1, not 0.
161 |  |  |  |  |
162 |  |  |  |  | =head2 size()
163 |  |  |  |  |
164 |  |  |  |  | Returns the number of nodes in the NodeSet.
165 |  |  |  |  |
166 |  |  |  |  | =head2 pop()
167 |  |  |  |  |
168 |  |  |  |  | Equivalent to perl's pop function.
169 |  |  |  |  |
170 |  |  |  |  | =head2 push(@nodes)
171 |  |  |  |  |
172 |  |  |  |  | Equivalent to perl's push function.
173 |  |  |  |  |
174 |  |  |  |  | =head2 append($nodelist)
175 |  |  |  |  |
176 |  |  |  |  | Given a nodelist, appends the list of nodes in $nodelist to the end of the
177 |  |  |  |  | current list.
178 |  |  |  |  |
179 |  |  |  |  | =head2 shift()
180 |  |  |  |  |
181 |  |  |  |  | Equivalent to perl's shift function.
182 |  |  |  |  |
183 |  |  |  |  | =head2 unshift(@nodes)
184 |  |  |  |  |
185 |  |  |  |  | Equivalent to perl's unshift function.
186 |  |  |  |  |
187 |  |  |  |  | =head2 prepend($nodeset)
188 |  |  |  |  |
189 |  |  |  |  | Given a nodelist, prepends the list of nodes in $nodelist to the front of
190 |  |  |  |  | the current list.
191 |  |  |  |  |
192 |  |  |  |  | =head2 iterator()
193 |  |  |  |  |
194 |  |  |  |  | Will return a new nodelist iterator for the current nodelist. A
195 |  |  |  |  | nodelist iterator is usefull if more complex nodelist processing is
196 |  |  |  |  | needed.
197 |  |  |  |  |
198 |  |  |  |  | =cut