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

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 16:57:28 2010
Reported on Tue May 4 16:59:00 2010

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

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 23µs | 34µs | XML::LibXML::XPathContext::::BEGIN@12XML::LibXML::XPathContext::BEGIN@12
1 | 1 | 1 | 12µs | 91µs | XML::LibXML::XPathContext::::BEGIN@15XML::LibXML::XPathContext::BEGIN@15
1 | 1 | 1 | 12µs | 36µs | XML::LibXML::XPathContext::::BEGIN@141XML::LibXML::XPathContext::BEGIN@141
1 | 1 | 1 | 10µs | 10µs | XML::LibXML::XPathContext::::BEGIN@16XML::LibXML::XPathContext::BEGIN@16
1 | 1 | 1 | 10µs | 94µs | XML::LibXML::XPathContext::::BEGIN@13XML::LibXML::XPathContext::BEGIN@13
1 | 1 | 1 | 5µs | 5µs | XML::LibXML::XPathContext::::BEGIN@17XML::LibXML::XPathContext::BEGIN@17
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::CLONE_SKIPXML::LibXML::XPathContext::CLONE_SKIP
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::_guarded_find_callXML::LibXML::XPathContext::_guarded_find_call
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::_perl_dispatcherXML::LibXML::XPathContext::_perl_dispatcher
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::existsXML::LibXML::XPathContext::exists
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::findXML::LibXML::XPathContext::find
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::findnodesXML::LibXML::XPathContext::findnodes
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::findvalueXML::LibXML::XPathContext::findvalue
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::registerFunctionXML::LibXML::XPathContext::registerFunction
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::unregisterFunctionXML::LibXML::XPathContext::unregisterFunction
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::unregisterFunctionNSXML::LibXML::XPathContext::unregisterFunctionNS
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::unregisterNsXML::LibXML::XPathContext::unregisterNs
0 | 0 | 0 | 0s | 0s | XML::LibXML::XPathContext::::unregisterVarLookupFuncXML::LibXML::XPathContext::unregisterVarLookupFunc

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | # $Id: XPathContext.pm 422 2002-11-08 17:10:30Z phish $
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::XPathContext;
11 |  |  |  |  |
12 | 3 | 41µs | 2 | 45µs | # spent 34µs (23+11) within XML::LibXML::XPathContext::BEGIN@12 which was called # once (23µs+11µs) by XML::LibXML::BEGIN@25 at line 12 use strict; # spent 34µs making 1 call to XML::LibXML::XPathContext::BEGIN@12 # spent 11µs making 1 call to strict::import
13 | 3 | 33µs | 2 | 178µs | # spent 94µs (10+84) within XML::LibXML::XPathContext::BEGIN@13 which was called # once (10µs+84µs) by XML::LibXML::BEGIN@25 at line 13 use vars qw($VERSION @ISA $USE_LIBXML_DATA_TYPES); # spent 94µs making 1 call to XML::LibXML::XPathContext::BEGIN@13 # spent 84µs making 1 call to vars::import
14 |  |  |  |  |
15 | 3 | 35µs | 2 | 169µs | # spent 91µs (12+78) within XML::LibXML::XPathContext::BEGIN@15 which was called # once (12µs+78µs) by XML::LibXML::BEGIN@25 at line 15 use Carp; # spent 91µs making 1 call to XML::LibXML::XPathContext::BEGIN@15 # spent 78µs making 1 call to Exporter::import
16 | 3 | 31µs | 1 | 10µs | # spent 10µs within XML::LibXML::XPathContext::BEGIN@16 which was called # once (10µs+0s) by XML::LibXML::BEGIN@25 at line 16 use XML::LibXML; # spent 10µs making 1 call to XML::LibXML::XPathContext::BEGIN@16
17 | 3 | 690µs | 1 | 5µs | # spent 5µs within XML::LibXML::XPathContext::BEGIN@17 which was called # once (5µs+0s) by XML::LibXML::BEGIN@25 at line 17 use XML::LibXML::NodeList; # spent 5µs making 1 call to XML::LibXML::XPathContext::BEGIN@17
18 |  |  |  |  |
19 | 1 | 800ns |  |  | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE
20 |  |  |  |  |
21 |  |  |  |  | # should LibXML XPath data types be used for simple objects
22 |  |  |  |  | # when passing parameters to extension functions (default: no)
23 | 1 | 200ns |  |  | $USE_LIBXML_DATA_TYPES = 0;
24 |  |  |  |  |
25 |  |  |  |  | sub CLONE_SKIP { 1 }
26 |  |  |  |  |
27 |  |  |  |  | sub findnodes {
28 |  |  |  |  | my ($self, $xpath, $node) = @_;
29 |  |  |  |  |
30 |  |  |  |  | my @nodes = $self->_guarded_find_call('_findnodes', $node, $xpath);
31 |  |  |  |  |
32 |  |  |  |  | if (wantarray) {
33 |  |  |  |  | return @nodes;
34 |  |  |  |  | }
35 |  |  |  |  | else {
36 |  |  |  |  | return XML::LibXML::NodeList->new(@nodes);
37 |  |  |  |  | }
38 |  |  |  |  | }
39 |  |  |  |  |
40 |  |  |  |  | sub find {
41 |  |  |  |  | my ($self, $xpath, $node) = @_;
42 |  |  |  |  |
43 |  |  |  |  | my ($type, @params) = $self->_guarded_find_call('_find', $node, $xpath,0);
44 |  |  |  |  |
45 |  |  |  |  | if ($type) {
46 |  |  |  |  | return $type->new(@params);
47 |  |  |  |  | }
48 |  |  |  |  | return undef;
49 |  |  |  |  | }
50 |  |  |  |  |
51 |  |  |  |  | sub exists {
52 |  |  |  |  | my ($self, $xpath, $node) = @_;
53 |  |  |  |  | my (undef, $value) = $self->_guarded_find_call('_find', $node, $xpath,1);
54 |  |  |  |  | return $value;
55 |  |  |  |  | }
56 |  |  |  |  |
57 |  |  |  |  | sub findvalue {
58 |  |  |  |  | my $self = shift;
59 |  |  |  |  | return $self->find(@_)->to_literal->value;
60 |  |  |  |  | }
61 |  |  |  |  |
62 |  |  |  |  | sub _guarded_find_call {
63 |  |  |  |  | my ($self, $method, $node)=(shift,shift,shift);
64 |  |  |  |  |
65 |  |  |  |  | my $prev_node;
66 |  |  |  |  | if (ref($node)) {
67 |  |  |  |  | $prev_node = $self->getContextNode();
68 |  |  |  |  | $self->setContextNode($node);
69 |  |  |  |  | }
70 |  |  |  |  | my @ret;
71 |  |  |  |  | eval {
72 |  |  |  |  | @ret = $self->$method(@_);
73 |  |  |  |  | };
74 |  |  |  |  | $self->_free_node_pool;
75 |  |  |  |  | $self->setContextNode($prev_node) if ref($node);
76 |  |  |  |  |
77 |  |  |  |  | if ($@) {
78 |  |  |  |  | my $err = $@;
79 |  |  |  |  | chomp $err;
80 |  |  |  |  | croak $err;
81 |  |  |  |  | }
82 |  |  |  |  |
83 |  |  |  |  | return @ret;
84 |  |  |  |  | }
85 |  |  |  |  |
86 |  |  |  |  | sub registerFunction {
87 |  |  |  |  | my ($self, $name, $sub) = @_;
88 |  |  |  |  | $self->registerFunctionNS($name, undef, $sub);
89 |  |  |  |  | return;
90 |  |  |  |  | }
91 |  |  |  |  |
92 |  |  |  |  | sub unregisterNs {
93 |  |  |  |  | my ($self, $prefix) = @_;
94 |  |  |  |  | $self->registerNs($prefix, undef);
95 |  |  |  |  | return;
96 |  |  |  |  | }
97 |  |  |  |  |
98 |  |  |  |  | sub unregisterFunction {
99 |  |  |  |  | my ($self, $name) = @_;
100 |  |  |  |  | $self->registerFunctionNS($name, undef, undef);
101 |  |  |  |  | return;
102 |  |  |  |  | }
103 |  |  |  |  |
104 |  |  |  |  | sub unregisterFunctionNS {
105 |  |  |  |  | my ($self, $name, $ns) = @_;
106 |  |  |  |  | $self->registerFunctionNS($name, $ns, undef);
107 |  |  |  |  | return;
108 |  |  |  |  | }
109 |  |  |  |  |
110 |  |  |  |  | sub unregisterVarLookupFunc {
111 |  |  |  |  | my ($self) = @_;
112 |  |  |  |  | $self->registerVarLookupFunc(undef, undef);
113 |  |  |  |  | return;
114 |  |  |  |  | }
115 |  |  |  |  |
116 |  |  |  |  | # extension function perl dispatcher
117 |  |  |  |  | # borrowed from XML::LibXSLT
118 |  |  |  |  |
119 |  |  |  |  | sub _perl_dispatcher {
120 |  |  |  |  | my $func = shift;
121 |  |  |  |  | my @params = @_;
122 |  |  |  |  | my @perlParams;
123 |  |  |  |  |
124 |  |  |  |  | my $i = 0;
125 |  |  |  |  | while (@params) {
126 |  |  |  |  | my $type = shift(@params);
127 |  |  |  |  | if ($type eq 'XML::LibXML::Literal' or
128 |  |  |  |  | $type eq 'XML::LibXML::Number' or
129 |  |  |  |  | $type eq 'XML::LibXML::Boolean')
130 |  |  |  |  | {
131 |  |  |  |  | my $val = shift(@params);
132 |  |  |  |  | unshift(@perlParams, $USE_LIBXML_DATA_TYPES ? $type->new($val) : $val);
133 |  |  |  |  | }
134 |  |  |  |  | elsif ($type eq 'XML::LibXML::NodeList') {
135 |  |  |  |  | my $node_count = shift(@params);
136 |  |  |  |  | unshift(@perlParams, $type->new(splice(@params, 0, $node_count)));
137 |  |  |  |  | }
138 |  |  |  |  | }
139 |  |  |  |  |
140 |  |  |  |  | $func = "main::$func" unless ref($func) || $func =~ /(.+)::/;
141 | 3 | 72µs | 2 | 60µs | # spent 36µs (12+24) within XML::LibXML::XPathContext::BEGIN@141 which was called # once (12µs+24µs) by XML::LibXML::BEGIN@25 at line 141 no strict 'refs'; # spent 36µs making 1 call to XML::LibXML::XPathContext::BEGIN@141 # spent 24µs making 1 call to strict::unimport
142 |  |  |  |  | my $res = $func->(@perlParams);
143 |  |  |  |  | return $res;
144 |  |  |  |  | }
145 |  |  |  |  |
146 | 1 | 5µs |  |  | 1;