← 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:05 2010

File /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/Error.pm
Statements Executed 104
Statement Execution Time 1.74ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.35ms3.74msXML::LibXML::Error::::BEGIN@225XML::LibXML::Error::BEGIN@225
11117µs20µsXML::LibXML::Error::::BEGIN@11XML::LibXML::Error::BEGIN@11
11115µs58µsXML::LibXML::Error::::BEGIN@15XML::LibXML::Error::BEGIN@15
11111µs62µsXML::LibXML::Error::::BEGIN@39XML::LibXML::Error::BEGIN@39
1119µs51µsXML::LibXML::Error::::BEGIN@40XML::LibXML::Error::BEGIN@40
1119µs57µsXML::LibXML::Error::::BEGIN@13XML::LibXML::Error::BEGIN@13
1119µs44µsXML::LibXML::Error::::BEGIN@27XML::LibXML::Error::BEGIN@27
1119µs57µsXML::LibXML::Error::::BEGIN@38XML::LibXML::Error::BEGIN@38
1118µs43µsXML::LibXML::Error::::BEGIN@41XML::LibXML::Error::BEGIN@41
1118µs37µsXML::LibXML::Error::::BEGIN@28XML::LibXML::Error::BEGIN@28
1118µs37µsXML::LibXML::Error::::BEGIN@34XML::LibXML::Error::BEGIN@34
1118µs36µsXML::LibXML::Error::::BEGIN@32XML::LibXML::Error::BEGIN@32
1118µs33µsXML::LibXML::Error::::BEGIN@52XML::LibXML::Error::BEGIN@52
1118µs36µsXML::LibXML::Error::::BEGIN@29XML::LibXML::Error::BEGIN@29
1117µs36µsXML::LibXML::Error::::BEGIN@37XML::LibXML::Error::BEGIN@37
1117µs35µsXML::LibXML::Error::::BEGIN@36XML::LibXML::Error::BEGIN@36
1117µs37µsXML::LibXML::Error::::BEGIN@35XML::LibXML::Error::BEGIN@35
1117µs34µsXML::LibXML::Error::::BEGIN@42XML::LibXML::Error::BEGIN@42
1117µs35µsXML::LibXML::Error::::BEGIN@30XML::LibXML::Error::BEGIN@30
1117µs70µsXML::LibXML::Error::::BEGIN@12XML::LibXML::Error::BEGIN@12
1117µs37µsXML::LibXML::Error::::BEGIN@33XML::LibXML::Error::BEGIN@33
1117µs35µsXML::LibXML::Error::::BEGIN@45XML::LibXML::Error::BEGIN@45
1116µs30µsXML::LibXML::Error::::BEGIN@44XML::LibXML::Error::BEGIN@44
1116µs39µsXML::LibXML::Error::::BEGIN@43XML::LibXML::Error::BEGIN@43
1116µs29µsXML::LibXML::Error::::BEGIN@50XML::LibXML::Error::BEGIN@50
1116µs29µsXML::LibXML::Error::::BEGIN@53XML::LibXML::Error::BEGIN@53
1116µs29µsXML::LibXML::Error::::BEGIN@49XML::LibXML::Error::BEGIN@49
1116µs30µsXML::LibXML::Error::::BEGIN@46XML::LibXML::Error::BEGIN@46
1116µs29µsXML::LibXML::Error::::BEGIN@47XML::LibXML::Error::BEGIN@47
1116µs29µsXML::LibXML::Error::::BEGIN@55XML::LibXML::Error::BEGIN@55
1116µs28µsXML::LibXML::Error::::BEGIN@48XML::LibXML::Error::BEGIN@48
1116µs29µsXML::LibXML::Error::::BEGIN@54XML::LibXML::Error::BEGIN@54
1115µs29µsXML::LibXML::Error::::BEGIN@51XML::LibXML::Error::BEGIN@51
0000s0sXML::LibXML::Error::::AUTOLOADXML::LibXML::Error::AUTOLOAD
0000s0sXML::LibXML::Error::::DESTROYXML::LibXML::Error::DESTROY
0000s0sXML::LibXML::Error::::__ANON__[:18]XML::LibXML::Error::__ANON__[:18]
0000s0sXML::LibXML::Error::::__ANON__[:21]XML::LibXML::Error::__ANON__[:21]
0000s0sXML::LibXML::Error::::_callback_errorXML::LibXML::Error::_callback_error
0000s0sXML::LibXML::Error::::_instant_error_callbackXML::LibXML::Error::_instant_error_callback
0000s0sXML::LibXML::Error::::_report_errorXML::LibXML::Error::_report_error
0000s0sXML::LibXML::Error::::_report_warningXML::LibXML::Error::_report_warning
0000s0sXML::LibXML::Error::::as_stringXML::LibXML::Error::as_string
0000s0sXML::LibXML::Error::::domainXML::LibXML::Error::domain
0000s0sXML::LibXML::Error::::dumpXML::LibXML::Error::dump
0000s0sXML::LibXML::Error::::int1XML::LibXML::Error::int1
0000s0sXML::LibXML::Error::::int2XML::LibXML::Error::int2
0000s0sXML::LibXML::Error::::newXML::LibXML::Error::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Id: Error.pm,v 1.1.2.1 2004/04/20 20:09:48 pajas Exp $
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#
9package XML::LibXML::Error;
10
11328µs223µs
# spent 20µs (17+3) within XML::LibXML::Error::BEGIN@11 which was called # once (17µs+3µs) by XML::LibXML::BEGIN@23 at line 11
use strict;
# spent 20µs making 1 call to XML::LibXML::Error::BEGIN@11 # spent 3µs making 1 call to strict::import
12327µs2132µs
# spent 70µs (7+63) within XML::LibXML::Error::BEGIN@12 which was called # once (7µs+63µs) by XML::LibXML::BEGIN@23 at line 12
use vars qw($AUTOLOAD @error_domains $VERSION $WARNINGS);
# spent 70µs making 1 call to XML::LibXML::Error::BEGIN@12 # spent 62µs making 1 call to vars::import
13396µs2105µs
# spent 57µs (9+48) within XML::LibXML::Error::BEGIN@13 which was called # once (9µs+48µs) by XML::LibXML::BEGIN@23 at line 13
use Carp;
# spent 57µs making 1 call to XML::LibXML::Error::BEGIN@13 # spent 48µs making 1 call to Exporter::import
14use overload
15
# spent 58µs (15+43) within XML::LibXML::Error::BEGIN@15 which was called # once (15µs+43µs) by XML::LibXML::BEGIN@23 at line 22
'""' => \&as_string,
16 'eq' => sub {
17 ("$_[0]" eq "$_[1]")
18 },
19 'cmp' => sub {
20 ("$_[0]" cmp "$_[1]")
21 },
22347µs2101µs fallback => 1;
# spent 58µs making 1 call to XML::LibXML::Error::BEGIN@15 # spent 43µs making 1 call to overload::import
23
241400ns$WARNINGS = 0; # 0: supress, 1: report via warn, 2: report via die
251400ns$VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE
26
27328µs278µs
# spent 44µs (9+35) within XML::LibXML::Error::BEGIN@27 which was called # once (9µs+35µs) by XML::LibXML::BEGIN@23 at line 27
use constant XML_ERR_NONE => 0;
# spent 44µs making 1 call to XML::LibXML::Error::BEGIN@27 # spent 35µs making 1 call to constant::import
28326µs266µs
# spent 37µs (8+29) within XML::LibXML::Error::BEGIN@28 which was called # once (8µs+29µs) by XML::LibXML::BEGIN@23 at line 28
use constant XML_ERR_WARNING => 1; # A simple warning
# spent 37µs making 1 call to XML::LibXML::Error::BEGIN@28 # spent 29µs making 1 call to constant::import
29326µs264µs
# spent 36µs (8+28) within XML::LibXML::Error::BEGIN@29 which was called # once (8µs+28µs) by XML::LibXML::BEGIN@23 at line 29
use constant XML_ERR_ERROR => 2; # A recoverable error
# spent 36µs making 1 call to XML::LibXML::Error::BEGIN@29 # spent 28µs making 1 call to constant::import
30326µs262µs
# spent 35µs (7+28) within XML::LibXML::Error::BEGIN@30 which was called # once (7µs+28µs) by XML::LibXML::BEGIN@23 at line 30
use constant XML_ERR_FATAL => 3; # A fatal error
# spent 35µs making 1 call to XML::LibXML::Error::BEGIN@30 # spent 28µs making 1 call to constant::import
31
32333µs265µs
# spent 36µs (8+29) within XML::LibXML::Error::BEGIN@32 which was called # once (8µs+29µs) by XML::LibXML::BEGIN@23 at line 32
use constant XML_ERR_FROM_NONE => 0;
# spent 36µs making 1 call to XML::LibXML::Error::BEGIN@32 # spent 29µs making 1 call to constant::import
33327µs267µs
# spent 37µs (7+30) within XML::LibXML::Error::BEGIN@33 which was called # once (7µs+30µs) by XML::LibXML::BEGIN@23 at line 33
use constant XML_ERR_FROM_PARSER => 1; # The XML parser
# spent 37µs making 1 call to XML::LibXML::Error::BEGIN@33 # spent 30µs making 1 call to constant::import
34335µs266µs
# spent 37µs (8+29) within XML::LibXML::Error::BEGIN@34 which was called # once (8µs+29µs) by XML::LibXML::BEGIN@23 at line 34
use constant XML_ERR_FROM_TREE => 2; # The tree module
# spent 37µs making 1 call to XML::LibXML::Error::BEGIN@34 # spent 29µs making 1 call to constant::import
35326µs267µs
# spent 37µs (7+30) within XML::LibXML::Error::BEGIN@35 which was called # once (7µs+30µs) by XML::LibXML::BEGIN@23 at line 35
use constant XML_ERR_FROM_NAMESPACE => 3; # The XML Namespace module
# spent 37µs making 1 call to XML::LibXML::Error::BEGIN@35 # spent 30µs making 1 call to constant::import
36327µs264µs
# spent 35µs (7+28) within XML::LibXML::Error::BEGIN@36 which was called # once (7µs+28µs) by XML::LibXML::BEGIN@23 at line 36
use constant XML_ERR_FROM_DTD => 4; # The XML DTD validation
# spent 35µs making 1 call to XML::LibXML::Error::BEGIN@36 # spent 28µs making 1 call to constant::import
37326µs265µs
# spent 36µs (7+29) within XML::LibXML::Error::BEGIN@37 which was called # once (7µs+29µs) by XML::LibXML::BEGIN@23 at line 37
use constant XML_ERR_FROM_HTML => 5; # The HTML parser
# spent 36µs making 1 call to XML::LibXML::Error::BEGIN@37 # spent 29µs making 1 call to constant::import
38340µs2105µs
# spent 57µs (9+48) within XML::LibXML::Error::BEGIN@38 which was called # once (9µs+48µs) by XML::LibXML::BEGIN@23 at line 38
use constant XML_ERR_FROM_MEMORY => 6; # The memory allocator
# spent 57µs making 1 call to XML::LibXML::Error::BEGIN@38 # spent 48µs making 1 call to constant::import
39341µs2113µs
# spent 62µs (11+51) within XML::LibXML::Error::BEGIN@39 which was called # once (11µs+51µs) by XML::LibXML::BEGIN@23 at line 39
use constant XML_ERR_FROM_OUTPUT => 7; # The serialization code
# spent 62µs making 1 call to XML::LibXML::Error::BEGIN@39 # spent 51µs making 1 call to constant::import
40331µs292µs
# spent 51µs (9+42) within XML::LibXML::Error::BEGIN@40 which was called # once (9µs+42µs) by XML::LibXML::BEGIN@23 at line 40
use constant XML_ERR_FROM_IO => 8; # The Input/Output stack
# spent 51µs making 1 call to XML::LibXML::Error::BEGIN@40 # spent 42µs making 1 call to constant::import
41328µs278µs
# spent 43µs (8+35) within XML::LibXML::Error::BEGIN@41 which was called # once (8µs+35µs) by XML::LibXML::BEGIN@23 at line 41
use constant XML_ERR_FROM_FTP => 9; # The FTP module
# spent 43µs making 1 call to XML::LibXML::Error::BEGIN@41 # spent 35µs making 1 call to constant::import
42322µs262µs
# spent 34µs (7+27) within XML::LibXML::Error::BEGIN@42 which was called # once (7µs+27µs) by XML::LibXML::BEGIN@23 at line 42
use constant XML_ERR_FROM_HTTP => 10; # The FTP module
# spent 34µs making 1 call to XML::LibXML::Error::BEGIN@42 # spent 27µs making 1 call to constant::import
43324µs271µs
# spent 39µs (6+32) within XML::LibXML::Error::BEGIN@43 which was called # once (6µs+32µs) by XML::LibXML::BEGIN@23 at line 43
use constant XML_ERR_FROM_XINCLUDE => 11; # The XInclude processing
# spent 39µs making 1 call to XML::LibXML::Error::BEGIN@43 # spent 33µs making 1 call to constant::import
44322µs254µs
# spent 30µs (6+24) within XML::LibXML::Error::BEGIN@44 which was called # once (6µs+24µs) by XML::LibXML::BEGIN@23 at line 44
use constant XML_ERR_FROM_XPATH => 12; # The XPath module
# spent 30µs making 1 call to XML::LibXML::Error::BEGIN@44 # spent 24µs making 1 call to constant::import
45322µs264µs
# spent 35µs (7+29) within XML::LibXML::Error::BEGIN@45 which was called # once (7µs+29µs) by XML::LibXML::BEGIN@23 at line 45
use constant XML_ERR_FROM_XPOINTER => 13; # The XPointer module
# spent 35µs making 1 call to XML::LibXML::Error::BEGIN@45 # spent 29µs making 1 call to constant::import
46321µs253µs
# spent 30µs (6+24) within XML::LibXML::Error::BEGIN@46 which was called # once (6µs+24µs) by XML::LibXML::BEGIN@23 at line 46
use constant XML_ERR_FROM_REGEXP => 14; # The regular expressions module
# spent 30µs making 1 call to XML::LibXML::Error::BEGIN@46 # spent 24µs making 1 call to constant::import
47321µs252µs
# spent 29µs (6+23) within XML::LibXML::Error::BEGIN@47 which was called # once (6µs+23µs) by XML::LibXML::BEGIN@23 at line 47
use constant XML_ERR_FROM_DATATYPE => 15; # The W3C XML Schemas Datatype module
# spent 29µs making 1 call to XML::LibXML::Error::BEGIN@47 # spent 23µs making 1 call to constant::import
48321µs251µs
# spent 28µs (6+23) within XML::LibXML::Error::BEGIN@48 which was called # once (6µs+23µs) by XML::LibXML::BEGIN@23 at line 48
use constant XML_ERR_FROM_SCHEMASP => 16; # The W3C XML Schemas parser module
# spent 28µs making 1 call to XML::LibXML::Error::BEGIN@48 # spent 23µs making 1 call to constant::import
49321µs252µs
# spent 29µs (6+23) within XML::LibXML::Error::BEGIN@49 which was called # once (6µs+23µs) by XML::LibXML::BEGIN@23 at line 49
use constant XML_ERR_FROM_SCHEMASV => 17; # The W3C XML Schemas validation module
# spent 29µs making 1 call to XML::LibXML::Error::BEGIN@49 # spent 23µs making 1 call to constant::import
50321µs251µs
# spent 29µs (6+23) within XML::LibXML::Error::BEGIN@50 which was called # once (6µs+23µs) by XML::LibXML::BEGIN@23 at line 50
use constant XML_ERR_FROM_RELAXNGP => 18; # The Relax-NG parser module
# spent 29µs making 1 call to XML::LibXML::Error::BEGIN@50 # spent 23µs making 1 call to constant::import
51335µs252µs
# spent 29µs (5+23) within XML::LibXML::Error::BEGIN@51 which was called # once (5µs+23µs) by XML::LibXML::BEGIN@23 at line 51
use constant XML_ERR_FROM_RELAXNGV => 19; # The Relax-NG validator module
# spent 29µs making 1 call to XML::LibXML::Error::BEGIN@51 # spent 23µs making 1 call to constant::import
52323µs258µs
# spent 33µs (8+25) within XML::LibXML::Error::BEGIN@52 which was called # once (8µs+25µs) by XML::LibXML::BEGIN@23 at line 52
use constant XML_ERR_FROM_CATALOG => 20; # The Catalog module
# spent 33µs making 1 call to XML::LibXML::Error::BEGIN@52 # spent 25µs making 1 call to constant::import
53321µs252µs
# spent 29µs (6+23) within XML::LibXML::Error::BEGIN@53 which was called # once (6µs+23µs) by XML::LibXML::BEGIN@23 at line 53
use constant XML_ERR_FROM_C14N => 21; # The Canonicalization module
# spent 29µs making 1 call to XML::LibXML::Error::BEGIN@53 # spent 23µs making 1 call to constant::import
54321µs252µs
# spent 29µs (6+23) within XML::LibXML::Error::BEGIN@54 which was called # once (6µs+23µs) by XML::LibXML::BEGIN@23 at line 54
use constant XML_ERR_FROM_XSLT => 22; # The XSLT engine from libxslt
# spent 29µs making 1 call to XML::LibXML::Error::BEGIN@54 # spent 23µs making 1 call to constant::import
553673µs252µs
# spent 29µs (6+23) within XML::LibXML::Error::BEGIN@55 which was called # once (6µs+23µs) by XML::LibXML::BEGIN@23 at line 55
use constant XML_ERR_FROM_VALID => 23; # The validaton module
# spent 29µs making 1 call to XML::LibXML::Error::BEGIN@55 # spent 23µs making 1 call to constant::import
56
5714µs@error_domains = ("", "parser", "tree", "namespace", "validity",
58 "HTML parser", "memory", "output", "I/O", "ftp",
59 "http", "XInclude", "XPath", "xpointer", "regexp",
60 "Schemas datatype", "Schemas parser", "Schemas validity",
61 "Relax-NG parser", "Relax-NG validity",
62 "Catalog", "C14N", "XSLT", "validity");
63
64{
65
661400ns sub new {
67 my ($class,$xE) = @_;
68 my $terr;
69 if (ref($xE)) {
70 my ($context,$column) = $xE->context_and_column();
71 $terr =bless {
72 domain => $xE->domain(),
73 level => $xE->level(),
74 code => $xE->code(),
75 message => $xE->message(),
76 file => $xE->file(),
77 line => $xE->line(),
78 str1 => $xE->str1(),
79 str2 => $xE->str2(),
80 str3 => $xE->str3(),
81 num1 => $xE->num1(),
82 num2 => $xE->num2(),
83 (defined($context) ?
84 (
85 context => $context,
86 column => $column,
87 ) : ()),
88 }, $class;
89 } else {
90 # !!!! problem : got a flat error
91 # warn("PROBLEM: GOT A FLAT ERROR $xE\n");
92 $terr =bless {
93 domain => 0,
94 level => 2,
95 code => -1,
96 message => $xE,
97 file => undef,
98 line => undef,
99 str1 => undef,
100 str2 => undef,
101 str3 => undef,
102 num1 => undef,
103 num2 => undef,
104 }, $class;
105 }
106 return $terr;
107 }
108
109 sub _callback_error {
110 #print "CALLBACK\n";
111 my ($xE,$prev) = @_;
112 my $terr;
113 $terr=XML::LibXML::Error->new($xE);
114 if ($terr->{level} == XML_ERR_WARNING and $WARNINGS!=2) {
115 warn $terr if $WARNINGS;
116 return $prev;
117 }
118 #unless ( defined $terr->{file} and length $terr->{file} ) {
119 # this would make it easier to recognize parsed strings
120 # but it breaks old implementations
121 # [CG] $terr->{file} = 'string()';
122 #}
123 #warn "Saving the error ",$terr->dump;
124 $terr->{_prev} = ref($prev) ? $prev :
125 defined($prev) && length($prev) ? XML::LibXML::Error->new($prev) : undef;
126 return $terr;
127 }
128 sub _instant_error_callback {
129 my $xE = shift;
130 my $terr= XML::LibXML::Error->new($xE);
131 print "Reporting an instanteous error ",$terr->dump;
132 die $terr;
133 }
134 sub _report_warning {
135 my ($saved_error) = @_;
136 #print "CALLBACK WARN\n";
137 if ( defined $saved_error ) {
138 #print "reporting a warning ",$saved_error->dump;
139 warn $saved_error;
140 }
141 }
142 sub _report_error {
143 my ($saved_error) = @_;
144 #print "CALLBACK ERROR: $saved_error\n";
145 if ( defined $saved_error ) {
146 die $saved_error;
147 }
148 }
149}
150
151
152sub AUTOLOAD {
153 my $self=shift;
154 return undef unless ref($self);
155 my $sub = $AUTOLOAD;
156 $sub =~ s/.*:://;
157 if ($sub=~/^(?:code|_prev|level|file|line|domain|nodename|message|column|context|str[123]|num[12])$/) {
158 return $self->{$sub};
159 } else {
160 croak("Unknown error field $sub");
161 }
162}
163
164# backward compatibility
165sub int1 { $_[0]->num1 }
166sub int2 { $_[0]->num2 }
167
168sub DESTROY {}
169
170sub domain {
171 my ($self)=@_;
172 return undef unless ref($self);
173 return $error_domains[$self->{domain}];
174}
175
176sub as_string {
177 my ($self)=@_;
178 my $msg = "";
179 my $level;
180
181 if (defined($self->{_prev})) {
182 $msg = $self->{_prev}->as_string;
183 }
184
185 if ($self->{level} == XML_ERR_NONE) {
186 $level = "";
187 } elsif ($self->{level} == XML_ERR_WARNING) {
188 $level = "warning";
189 } elsif ($self->{level} == XML_ERR_ERROR ||
190 $self->{level} == XML_ERR_FATAL) {
191 $level = "error";
192 }
193 my $where="";
194 if (defined($self->{file})) {
195 $where="$self->{file}:$self->{line}";
196 } elsif (($self->{domain} == XML_ERR_FROM_PARSER)
197 and
198 $self->{line}) {
199 $where="Entity: line $self->{line}";
200 }
201 if ($self->{nodename}) {
202 $where.=": element ".$self->{nodename};
203 }
204 $msg.=$where.": " if $where ne "";
205 $msg.=$error_domains[$self->{domain}]." ".$level." :";
206 my $str=$self->{message}||"";
207 chomp($str);
208 $msg.=" ".$str."\n";
209 if (($self->{domain} == XML_ERR_FROM_XPATH) and
210 defined($self->{str1})) {
211 $msg.=$self->{str1}."\n";
212 $msg.=(" " x $self->{num1})."^\n";
213 } elsif (defined $self->{context}) {
214 my $context = $self->{context};
215 $msg.=$context."\n";
216 $context = substr($context,0,$self->{column});
217 $context=~s/[^\t]/ /g;
218 $msg.=$context."^\n";
219 }
220 return $msg;
221}
222
223sub dump {
224 my ($self)=@_;
2253140µs23.76ms
# spent 3.74ms (3.35+391µs) within XML::LibXML::Error::BEGIN@225 which was called # once (3.35ms+391µs) by XML::LibXML::BEGIN@23 at line 225
use Data::Dumper;
# spent 3.74ms making 1 call to XML::LibXML::Error::BEGIN@225 # spent 27µs making 1 call to Exporter::import
226 return Data::Dumper->new([$self],['error'])->Dump;
227}
228
22919µs1;