← 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/XPathContext.pm
StatementsExecuted 17 statements in 879µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs22µsXML::LibXML::XPathContext::::BEGIN@12XML::LibXML::XPathContext::BEGIN@12
1118µs18µsXML::LibXML::XPathContext::::BEGIN@142XML::LibXML::XPathContext::BEGIN@142
1117µs7µsXML::LibXML::XPathContext::::BEGIN@17XML::LibXML::XPathContext::BEGIN@17
1117µs34µsXML::LibXML::XPathContext::::BEGIN@16XML::LibXML::XPathContext::BEGIN@16
1117µs10µsXML::LibXML::XPathContext::::BEGIN@13XML::LibXML::XPathContext::BEGIN@13
1116µs38µsXML::LibXML::XPathContext::::BEGIN@14XML::LibXML::XPathContext::BEGIN@14
1114µs4µsXML::LibXML::XPathContext::::BEGIN@18XML::LibXML::XPathContext::BEGIN@18
0000s0sXML::LibXML::XPathContext::::CLONE_SKIPXML::LibXML::XPathContext::CLONE_SKIP
0000s0sXML::LibXML::XPathContext::::_guarded_find_callXML::LibXML::XPathContext::_guarded_find_call
0000s0sXML::LibXML::XPathContext::::_perl_dispatcherXML::LibXML::XPathContext::_perl_dispatcher
0000s0sXML::LibXML::XPathContext::::existsXML::LibXML::XPathContext::exists
0000s0sXML::LibXML::XPathContext::::findXML::LibXML::XPathContext::find
0000s0sXML::LibXML::XPathContext::::findnodesXML::LibXML::XPathContext::findnodes
0000s0sXML::LibXML::XPathContext::::findvalueXML::LibXML::XPathContext::findvalue
0000s0sXML::LibXML::XPathContext::::registerFunctionXML::LibXML::XPathContext::registerFunction
0000s0sXML::LibXML::XPathContext::::unregisterFunctionXML::LibXML::XPathContext::unregisterFunction
0000s0sXML::LibXML::XPathContext::::unregisterFunctionNSXML::LibXML::XPathContext::unregisterFunctionNS
0000s0sXML::LibXML::XPathContext::::unregisterNsXML::LibXML::XPathContext::unregisterNs
0000s0sXML::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
10package XML::LibXML::XPathContext;
11
12222µs233µs
# spent 22µs (12+11) within XML::LibXML::XPathContext::BEGIN@12 which was called: # once (12µs+11µs) by XML::LibXML::BEGIN@28 at line 12
use strict;
# spent 22µs making 1 call to XML::LibXML::XPathContext::BEGIN@12 # spent 11µs making 1 call to strict::import
13222µs214µs
# spent 10µs (7+4) within XML::LibXML::XPathContext::BEGIN@13 which was called: # once (7µs+4µs) by XML::LibXML::BEGIN@28 at line 13
use warnings;
# spent 10µs making 1 call to XML::LibXML::XPathContext::BEGIN@13 # spent 4µs making 1 call to warnings::import
14221µs270µs
# spent 38µs (6+32) within XML::LibXML::XPathContext::BEGIN@14 which was called: # once (6µs+32µs) by XML::LibXML::BEGIN@28 at line 14
use vars qw($VERSION @ISA $USE_LIBXML_DATA_TYPES);
# spent 38µs making 1 call to XML::LibXML::XPathContext::BEGIN@14 # spent 32µs making 1 call to vars::import
15
16221µs261µs
# spent 34µs (7+27) within XML::LibXML::XPathContext::BEGIN@16 which was called: # once (7µs+27µs) by XML::LibXML::BEGIN@28 at line 16
use Carp;
# spent 34µs making 1 call to XML::LibXML::XPathContext::BEGIN@16 # spent 27µs making 1 call to Exporter::import
17228µs17µs
# spent 7µs within XML::LibXML::XPathContext::BEGIN@17 which was called: # once (7µs+0s) by XML::LibXML::BEGIN@28 at line 17
use XML::LibXML;
# spent 7µs making 1 call to XML::LibXML::XPathContext::BEGIN@17
182715µs14µs
# spent 4µs within XML::LibXML::XPathContext::BEGIN@18 which was called: # once (4µs+0s) by XML::LibXML::BEGIN@28 at line 18
use XML::LibXML::NodeList;
# spent 4µs making 1 call to XML::LibXML::XPathContext::BEGIN@18
19
201400ns$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
21
22# should LibXML XPath data types be used for simple objects
23# when passing parameters to extension functions (default: no)
241100ns$USE_LIBXML_DATA_TYPES = 0;
25
26sub CLONE_SKIP { 1 }
27
28sub findnodes {
29 my ($self, $xpath, $node) = @_;
30
31 my @nodes = $self->_guarded_find_call('_findnodes', $node, $xpath);
32
33 if (wantarray) {
34 return @nodes;
35 }
36 else {
37 return XML::LibXML::NodeList->new(@nodes);
38 }
39}
40
41sub find {
42 my ($self, $xpath, $node) = @_;
43
44 my ($type, @params) = $self->_guarded_find_call('_find', $node, $xpath,0);
45
46 if ($type) {
47 return $type->new(@params);
48 }
49 return undef;
50}
51
52sub exists {
53 my ($self, $xpath, $node) = @_;
54 my (undef, $value) = $self->_guarded_find_call('_find', $node, $xpath,1);
55 return $value;
56}
57
58sub findvalue {
59 my $self = shift;
60 return $self->find(@_)->to_literal->value;
61}
62
63sub _guarded_find_call {
64 my ($self, $method, $node)=(shift,shift,shift);
65
66 my $prev_node;
67 if (ref($node)) {
68 $prev_node = $self->getContextNode();
69 $self->setContextNode($node);
70 }
71 my @ret;
72 eval {
73 @ret = $self->$method(@_);
74 };
75 $self->_free_node_pool;
76 $self->setContextNode($prev_node) if ref($node);
77
78 if ($@) {
79 my $err = $@;
80 chomp $err;
81 croak $err;
82 }
83
84 return @ret;
85}
86
87sub registerFunction {
88 my ($self, $name, $sub) = @_;
89 $self->registerFunctionNS($name, undef, $sub);
90 return;
91}
92
93sub unregisterNs {
94 my ($self, $prefix) = @_;
95 $self->registerNs($prefix, undef);
96 return;
97}
98
99sub unregisterFunction {
100 my ($self, $name) = @_;
101 $self->registerFunctionNS($name, undef, undef);
102 return;
103}
104
105sub unregisterFunctionNS {
106 my ($self, $name, $ns) = @_;
107 $self->registerFunctionNS($name, $ns, undef);
108 return;
109}
110
111sub unregisterVarLookupFunc {
112 my ($self) = @_;
113 $self->registerVarLookupFunc(undef, undef);
114 return;
115}
116
117# extension function perl dispatcher
118# borrowed from XML::LibXSLT
119
120sub _perl_dispatcher {
121 my $func = shift;
122 my @params = @_;
123 my @perlParams;
124
125 my $i = 0;
126 while (@params) {
127 my $type = shift(@params);
128 if ($type eq 'XML::LibXML::Literal' or
129 $type eq 'XML::LibXML::Number' or
130 $type eq 'XML::LibXML::Boolean')
131 {
132 my $val = shift(@params);
133 unshift(@perlParams, $USE_LIBXML_DATA_TYPES ? $type->new($val) : $val);
134 }
135 elsif ($type eq 'XML::LibXML::NodeList') {
136 my $node_count = shift(@params);
137 unshift(@perlParams, $type->new(splice(@params, 0, $node_count)));
138 }
139 }
140
141 $func = "main::$func" unless ref($func) || $func =~ /(.+)::/;
142248µs228µs
# spent 18µs (8+10) within XML::LibXML::XPathContext::BEGIN@142 which was called: # once (8µs+10µs) by XML::LibXML::BEGIN@28 at line 142
no strict 'refs';
# spent 18µs making 1 call to XML::LibXML::XPathContext::BEGIN@142 # spent 10µs making 1 call to strict::unimport
143 my $res = $func->(@perlParams);
144 return $res;
145}
146
14712µs1;