← 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:47 2015

Filename/usr/share/perl5/XML/SAX/Exception.pm
StatementsExecuted 14 statements in 423µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1119µs24µsXML::SAX::Exception::::BEGIN@11XML::SAX::Exception::BEGIN@11
1117µs35µsXML::SAX::Exception::::BEGIN@13XML::SAX::Exception::BEGIN@13
1117µs7µsXML::SAX::Exception::::BEGIN@2XML::SAX::Exception::BEGIN@2
1117µs36µsXML::SAX::Exception::::BEGIN@8XML::SAX::Exception::BEGIN@8
1116µs16µsXML::SAX::Exception::::BEGIN@6XML::SAX::Exception::BEGIN@6
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
# spent 7µs within XML::SAX::Exception::BEGIN@2 which was called: # once (7µs+0s) by XML::SAX::ParserFactory::BEGIN@12 at line 4
BEGIN {
317µs $XML::SAX::Exception::VERSION = '1.07';
4118µs17µs}
# spent 7µs making 1 call to XML::SAX::Exception::BEGIN@2
5
6225µs225µs
# spent 16µs (6+10) within XML::SAX::Exception::BEGIN@6 which was called: # once (6µs+10µs) by XML::SAX::ParserFactory::BEGIN@12 at line 6
use strict;
# spent 16µs making 1 call to XML::SAX::Exception::BEGIN@6 # spent 10µs making 1 call to strict::import
7
815µs129µs
# spent 36µs (7+29) within XML::SAX::Exception::BEGIN@8 which was called: # once (7µs+29µs) by XML::SAX::ParserFactory::BEGIN@12 at line 9
use overload '""' => "stringify",
# spent 29µs making 1 call to overload::import
9120µs136µs 'fallback' => 1;
# spent 36µs making 1 call to XML::SAX::Exception::BEGIN@8
10
11221µs238µs
# spent 24µs (9+15) within XML::SAX::Exception::BEGIN@11 which was called: # once (9µs+15µs) by XML::SAX::ParserFactory::BEGIN@12 at line 11
use vars qw($StackTrace);
# spent 24µs making 1 call to XML::SAX::Exception::BEGIN@11 # spent 15µs making 1 call to vars::import
12
132314µs262µs
# spent 35µs (7+27) within XML::SAX::Exception::BEGIN@13 which was called: # once (7µs+27µs) by XML::SAX::ParserFactory::BEGIN@12 at line 13
use Carp;
# spent 35µs making 1 call to XML::SAX::Exception::BEGIN@13 # spent 27µs making 1 call to Exporter::import
14
151900ns$StackTrace = $ENV{XML_DEBUG} || 0;
16
17# Other exception classes:
18
1916µs@XML::SAX::Exception::NotRecognized::ISA = ('XML::SAX::Exception');
2012µs@XML::SAX::Exception::NotSupported::ISA = ('XML::SAX::Exception');
2112µs@XML::SAX::Exception::Parse::ISA = ('XML::SAX::Exception');
22
23
24sub throw {
25 my $class = shift;
26 if (ref($class)) {
27 die $class;
28 }
29 die $class->new(@_);
30}
31
32sub new {
33 my $class = shift;
34 my %opts = @_;
35 confess "Invalid options: " . join(', ', keys %opts) unless exists $opts{Message};
36
37 bless { ($StackTrace ? (StackTrace => stacktrace()) : ()), %opts },
38 $class;
39}
40
41sub stringify {
42 my $self = shift;
43 local $^W;
44 my $error;
45 if (exists $self->{LineNumber}) {
46 $error = $self->{Message} . " [Ln: " . $self->{LineNumber} .
47 ", Col: " . $self->{ColumnNumber} . "]";
48 }
49 else {
50 $error = $self->{Message};
51 }
52 if ($StackTrace) {
53 $error .= stackstring($self->{StackTrace});
54 }
55 $error .= "\n";
56 return $error;
57}
58
59sub stacktrace {
60 my $i = 2;
61 my @fulltrace;
62 while (my @trace = caller($i++)) {
63 my %hash;
64 @hash{qw(Package Filename Line)} = @trace[0..2];
65 push @fulltrace, \%hash;
66 }
67 return \@fulltrace;
68}
69
70sub stackstring {
71 my $stacktrace = shift;
72 my $string = "\nFrom:\n";
73 foreach my $current (@$stacktrace) {
74 $string .= $current->{Filename} . " Line: " . $current->{Line} . "\n";
75 }
76 return $string;
77}
78
7913µs1;
80
81__END__