← Index
NYTProf Performance Profile   « line view »
For t/optimization.t
  Run on Thu Jan 8 22:47:42 2015
Reported on Thu Jan 8 22:48:06 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Devel/StackTrace/Frame.pm
StatementsExecuted 33 statements in 765µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11140µs40µsDevel::StackTrace::Frame::::BEGIN@10Devel::StackTrace::Frame::BEGIN@10
11114µs28µsDevel::StackTrace::Frame::::BEGIN@6Devel::StackTrace::Frame::BEGIN@6
1119µs14µsDevel::StackTrace::Frame::::BEGIN@7Devel::StackTrace::Frame::BEGIN@7
1118µs19µsDevel::StackTrace::Frame::::BEGIN@11Devel::StackTrace::Frame::BEGIN@11
0000s0sDevel::StackTrace::Frame::::__ANON__[:17]Devel::StackTrace::Frame::__ANON__[:17]
0000s0sDevel::StackTrace::Frame::::argsDevel::StackTrace::Frame::args
0000s0sDevel::StackTrace::Frame::::as_stringDevel::StackTrace::Frame::as_string
0000s0sDevel::StackTrace::Frame::::newDevel::StackTrace::Frame::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Devel::StackTrace::Frame;
2{
321µs $Devel::StackTrace::Frame::VERSION = '1.30';
4}
5
6224µs242µs
# spent 28µs (14+14) within Devel::StackTrace::Frame::BEGIN@6 which was called: # once (14µs+14µs) by Devel::StackTrace::BEGIN@11 at line 6
use strict;
# spent 28µs making 1 call to Devel::StackTrace::Frame::BEGIN@6 # spent 14µs making 1 call to strict::import
7235µs218µs
# spent 14µs (9+5) within Devel::StackTrace::Frame::BEGIN@7 which was called: # once (9µs+5µs) by Devel::StackTrace::BEGIN@11 at line 7
use warnings;
# spent 14µs making 1 call to Devel::StackTrace::Frame::BEGIN@7 # spent 5µs making 1 call to warnings::import
8
9# Create accessor routines
10
# spent 40µs within Devel::StackTrace::Frame::BEGIN@10 which was called: # once (40µs+0s) by Devel::StackTrace::BEGIN@11 at line 19
BEGIN {
11276µs231µs
# spent 19µs (8+11) within Devel::StackTrace::Frame::BEGIN@11 which was called: # once (8µs+11µs) by Devel::StackTrace::BEGIN@11 at line 11
no strict 'refs';
# spent 19µs making 1 call to Devel::StackTrace::Frame::BEGIN@11 # spent 11µs making 1 call to strict::unimport
1217µs foreach my $f (
13 qw( package filename line subroutine hasargs
14 wantarray evaltext is_require hints bitmask args )
15 ) {
16112µs next if $f eq 'args';
171032µs *{$f} = sub { my $s = shift; return $s->{$f} };
18 }
191579µs140µs}
# spent 40µs making 1 call to Devel::StackTrace::Frame::BEGIN@10
20
21{
2223µs my @fields = (
23 qw( package filename line subroutine hasargs wantarray
24 evaltext is_require hints bitmask )
25 );
26
27 sub new {
28 my $proto = shift;
29 my $class = ref $proto || $proto;
30
31 my $self = bless {}, $class;
32
33 @{$self}{@fields} = @{ shift() };
34
35 # fixup unix-style paths on win32
36 $self->{filename} = File::Spec->canonpath( $self->{filename} );
37
38 $self->{args} = shift;
39
40 $self->{respect_overload} = shift;
41
42 $self->{max_arg_length} = shift;
43
44 $self->{message} = shift;
45
46 $self->{indent} = shift;
47
48 return $self;
49 }
50}
51
52sub args {
53 my $self = shift;
54
55 return @{ $self->{args} };
56}
57
58sub as_string {
59 my $self = shift;
60 my $first = shift;
61 my $p = shift;
62
63 my $sub = $self->subroutine;
64
65 # This code stolen straight from Carp.pm and then tweaked. All
66 # errors are probably my fault -dave
67 if ($first) {
68 $sub
69 = defined $self->{message}
70 ? $self->{message}
71 : 'Trace begun';
72 }
73 else {
74
75 # Build a string, $sub, which names the sub-routine called.
76 # This may also be "require ...", "eval '...' or "eval {...}"
77 if ( my $eval = $self->evaltext ) {
78 if ( $self->is_require ) {
79 $sub = "require $eval";
80 }
81 else {
82 $eval =~ s/([\\\'])/\\$1/g;
83 $sub = "eval '$eval'";
84 }
85 }
86 elsif ( $sub eq '(eval)' ) {
87 $sub = 'eval {...}';
88 }
89
90 # if there are any arguments in the sub-routine call, format
91 # them according to the format variables defined earlier in
92 # this file and join them onto the $sub sub-routine string
93 #
94 # We copy them because they're going to be modified.
95 #
96 if ( my @a = $self->args ) {
97 for (@a) {
98
99 # set args to the string "undef" if undefined
100 $_ = "undef", next unless defined $_;
101
102 # hack!
103 $_ = $self->Devel::StackTrace::_ref_to_string($_)
104 if ref $_;
105
106 local $SIG{__DIE__};
107 local $@;
108
109 eval {
110 my $max_arg_length
111 = exists $p->{max_arg_length}
112 ? $p->{max_arg_length}
113 : $self->{max_arg_length};
114
115 if ( $max_arg_length
116 && length $_ > $max_arg_length ) {
117 substr( $_, $max_arg_length ) = '...';
118 }
119
120 s/'/\\'/g;
121
122 # 'quote' arg unless it looks like a number
123 $_ = "'$_'" unless /^-?[\d.]+$/;
124
125 # print control/high ASCII chars as 'M-<char>' or '^<char>'
126 s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
127 s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
128 };
129
130 if ( my $e = $@ ) {
131 $_ = $e =~ /malformed utf-8/i ? '(bad utf-8)' : '?';
132 }
133 }
134
135 # append ('all', 'the', 'arguments') to the $sub string
136 $sub .= '(' . join( ', ', @a ) . ')';
137 $sub .= ' called';
138 }
139 }
140
141 # If the user opted into indentation (a la Carp::confess), pre-add a tab
142 my $tab = $self->{indent} && !$first ? "\t" : q{};
143
144 return "${tab}$sub at " . $self->filename . ' line ' . $self->line;
145}
146
14715µs1;
148
149# ABSTRACT: A single frame in a stack trace
150
151__END__