← Index
NYTProf Performance Profile   « block view • line view • sub view »
For conv.pl
  Run on Sun Nov 14 22:50:31 2010
Reported on Sun Nov 14 22:51:23 2010

Filename/usr/share/perl5/XML/SAX/Exception.pm
StatementsExecuted 18 statements in 753µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11124µs30µsXML::SAX::Exception::::BEGIN@3XML::SAX::Exception::BEGIN@3
11117µs99µsXML::SAX::Exception::::BEGIN@10XML::SAX::Exception::BEGIN@10
11115µs77µsXML::SAX::Exception::::BEGIN@8XML::SAX::Exception::BEGIN@8
11113µs87µsXML::SAX::Exception::::BEGIN@5XML::SAX::Exception::BEGIN@5
0000s0sXML::SAX::Exception::::newXML::SAX::Exception::new
0000s0sXML::SAX::Exception::::stackstringXML::SAX::Exception::stackstring
0000s0sXML::SAX::Exception::::stacktraceXML::SAX::Exception::stacktrace
0000s0sXML::SAX::Exception::::stringifyXML::SAX::Exception::stringify
0000s0sXML::SAX::Exception::::throwXML::SAX::Exception::throw
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package XML::SAX::Exception;
2
3350µs236µs
# spent 30µs (24+6) within XML::SAX::Exception::BEGIN@3 which was called: # once (24µs+6µs) by XML::LibXML::_SAXParser::BEGIN@1933 at line 3
use strict;
# spent 30µs making 1 call to XML::SAX::Exception::BEGIN@3 # spent 6µs making 1 call to strict::import
4
5110µs174µs
# spent 87µs (13+74) within XML::SAX::Exception::BEGIN@5 which was called: # once (13µs+74µs) by XML::LibXML::_SAXParser::BEGIN@1933 at line 6
use overload '""' => "stringify",
# spent 74µs making 1 call to overload::import
6236µs187µs 'fallback' => 1;
# spent 87µs making 1 call to XML::SAX::Exception::BEGIN@5
7
8398µs2139µs
# spent 77µs (15+62) within XML::SAX::Exception::BEGIN@8 which was called: # once (15µs+62µs) by XML::LibXML::_SAXParser::BEGIN@1933 at line 8
use vars qw/$StackTrace $VERSION/;
# spent 77µs making 1 call to XML::SAX::Exception::BEGIN@8 # spent 62µs making 1 call to vars::import
912µs$VERSION = '1.01';
103519µs2181µs
# spent 99µs (17+82) within XML::SAX::Exception::BEGIN@10 which was called: # once (17µs+82µs) by XML::LibXML::_SAXParser::BEGIN@1933 at line 10
use Carp;
# spent 99µs making 1 call to XML::SAX::Exception::BEGIN@10 # spent 82µs making 1 call to Exporter::import
11
1212µs$StackTrace = $ENV{XML_DEBUG} || 0;
13
14# Other exception classes:
15
16112µs@XML::SAX::Exception::NotRecognized::ISA = ('XML::SAX::Exception');
1718µs@XML::SAX::Exception::NotSupported::ISA = ('XML::SAX::Exception');
1817µs@XML::SAX::Exception::Parse::ISA = ('XML::SAX::Exception');
19
20
21sub throw {
22 my $class = shift;
23 if (ref($class)) {
24 die $class;
25 }
26 die $class->new(@_);
27}
28
29sub new {
30 my $class = shift;
31 my %opts = @_;
32 confess "Invalid options: " . join(', ', keys %opts) unless exists $opts{Message};
33
34 bless { ($StackTrace ? (StackTrace => stacktrace()) : ()), %opts },
35 $class;
36}
37
38sub stringify {
39 my $self = shift;
40 local $^W;
41 my $error;
42 if (exists $self->{LineNumber}) {
43 $error = $self->{Message} . " [Ln: " . $self->{LineNumber} .
44 ", Col: " . $self->{ColumnNumber} . "]";
45 }
46 else {
47 $error = $self->{Message};
48 }
49 if ($StackTrace) {
50 $error .= stackstring($self->{StackTrace});
51 }
52 $error .= "\n";
53 return $error;
54}
55
56sub stacktrace {
57 my $i = 2;
58 my @fulltrace;
59 while (my @trace = caller($i++)) {
60 my %hash;
61 @hash{qw(Package Filename Line)} = @trace[0..2];
62 push @fulltrace, \%hash;
63 }
64 return \@fulltrace;
65}
66
67sub stackstring {
68 my $stacktrace = shift;
69 my $string = "\nFrom:\n";
70 foreach my $current (@$stacktrace) {
71 $string .= $current->{Filename} . " Line: " . $current->{Line} . "\n";
72 }
73 return $string;
74}
75
7619µs1;
77
78__END__