Filename | /usr/share/perl5/DBIx/Class/Carp.pm |
Statements | Executed 147 statements in 2.19ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
17 | 17 | 17 | 833µs | 1.08ms | import | DBIx::Class::Carp::
17 | 1 | 1 | 218µs | 218µs | CORE:regcomp (opcode) | DBIx::Class::Carp::
17 | 1 | 1 | 30µs | 30µs | CORE:qr (opcode) | DBIx::Class::Carp::
1 | 1 | 1 | 25µs | 42µs | BEGIN@4 | DBIx::Class::Carp::
1 | 1 | 1 | 14µs | 26µs | BEGIN@5 | DBIx::Class::Carp::
1 | 1 | 1 | 12µs | 21µs | BEGIN@86 | DBIx::Class::Carp::
1 | 1 | 1 | 7µs | 7µs | BEGIN@9 | DBIx::Class::Carp::
0 | 0 | 0 | 0s | 0s | __ANON__[:104] | DBIx::Class::Carp::
0 | 0 | 0 | 0s | 0s | __ANON__[:121] | DBIx::Class::Carp::
0 | 0 | 0 | 0s | 0s | __ANON__[:75] | DBIx::Class::Carp::
0 | 0 | 0 | 0s | 0s | __ANON__[:93] | DBIx::Class::Carp::
0 | 0 | 0 | 0s | 0s | __find_caller | DBIx::Class::Carp::
0 | 0 | 0 | 0s | 0s | unimport | DBIx::Class::Carp::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package # hide from pause | ||||
2 | DBIx::Class::Carp; | ||||
3 | |||||
4 | 2 | 71µs | 2 | 60µs | # spent 42µs (25+18) within DBIx::Class::Carp::BEGIN@4 which was called:
# once (25µs+18µs) by DBIx::Class::_Util::BEGIN@56 at line 4 # spent 42µs making 1 call to DBIx::Class::Carp::BEGIN@4
# spent 18µs making 1 call to strict::import |
5 | 2 | 58µs | 2 | 39µs | # spent 26µs (14+12) within DBIx::Class::Carp::BEGIN@5 which was called:
# once (14µs+12µs) by DBIx::Class::_Util::BEGIN@56 at line 5 # spent 26µs making 1 call to DBIx::Class::Carp::BEGIN@5
# spent 12µs making 1 call to warnings::import |
6 | |||||
7 | # load Carp early to prevent tickling of the ::Internal stash being | ||||
8 | # interpreted as "Carp is already loaded" by some braindead loader | ||||
9 | 2 | 643µs | 1 | 7µs | # spent 7µs within DBIx::Class::Carp::BEGIN@9 which was called:
# once (7µs+0s) by DBIx::Class::_Util::BEGIN@56 at line 9 # spent 7µs making 1 call to DBIx::Class::Carp::BEGIN@9 |
10 | 1 | 2µs | $Carp::Internal{ (__PACKAGE__) }++; | ||
11 | |||||
12 | sub __find_caller { | ||||
13 | my ($skip_pattern, $class) = @_; | ||||
14 | |||||
15 | my $skip_class_data = $class->_skip_namespace_frames | ||||
16 | if ($class and $class->can('_skip_namespace_frames')); | ||||
17 | |||||
18 | $skip_pattern = qr/$skip_pattern|$skip_class_data/ | ||||
19 | if $skip_class_data; | ||||
20 | |||||
21 | my $fr_num = 1; # skip us and the calling carp* | ||||
22 | |||||
23 | my (@f, $origin); | ||||
24 | while (@f = caller($fr_num++)) { | ||||
25 | |||||
26 | next if | ||||
27 | ( $f[3] eq '(eval)' or $f[3] =~ /::__ANON__$/ ); | ||||
28 | |||||
29 | $origin ||= ( | ||||
30 | $f[3] =~ /^ (.+) :: ([^\:]+) $/x | ||||
31 | and | ||||
32 | ! $Carp::Internal{$1} | ||||
33 | and | ||||
34 | $1 !~ /^(?: DBIx::Class::Storage::BlockRunner | Context::Preserve | Try::Tiny | Class::Accessor::Grouped | Class::C3::Componentised | Module::Runtime )$/x | ||||
35 | |||||
36 | |||||
37 | and | ||||
38 | $2 !~ /^(?: throw_exception | carp | carp_unique | carp_once | dbh_do | txn_do | with_deferred_fk_checks)$/x | ||||
39 | ############################# | ||||
40 | ) ? $f[3] : undef; | ||||
41 | |||||
42 | if ( | ||||
43 | $f[0]->can('_skip_namespace_frames') | ||||
44 | and | ||||
45 | my $extra_skip = $f[0]->_skip_namespace_frames | ||||
46 | ) { | ||||
47 | $skip_pattern = qr/$skip_pattern|$extra_skip/; | ||||
48 | } | ||||
49 | |||||
50 | last if $f[0] !~ $skip_pattern; | ||||
51 | } | ||||
52 | |||||
53 | my $site = @f # if empty - nothing matched - full stack | ||||
54 | ? "at $f[1] line $f[2]" | ||||
55 | : Carp::longmess() | ||||
56 | ; | ||||
57 | $origin ||= '{UNKNOWN}'; | ||||
58 | |||||
59 | return ( | ||||
60 | $site, | ||||
61 | $origin =~ /::/ ? "$origin(): " : "$origin: ", # cargo-cult from Carp::Clan | ||||
62 | ); | ||||
63 | }; | ||||
64 | |||||
65 | my $warn = sub { | ||||
66 | my ($ln, @warn) = @_; | ||||
67 | @warn = "Warning: something's wrong" unless @warn; | ||||
68 | |||||
69 | # back-compat with Carp::Clan - a warning ending with \n does | ||||
70 | # not include caller info | ||||
71 | warn ( | ||||
72 | @warn, | ||||
73 | $warn[-1] =~ /\n$/ ? '' : " $ln\n" | ||||
74 | ); | ||||
75 | 1 | 4µs | }; | ||
76 | |||||
77 | # spent 1.08ms (833µs+249µs) within DBIx::Class::Carp::import which was called 17 times, avg 64µs/call:
# once (411µs+21µs) by DBIx::Class::Storage::TxnScopeGuard::BEGIN@9 at line 9 of DBIx/Class/Storage/TxnScopeGuard.pm
# once (35µs+21µs) by DBIx::Class::Relationship::Accessor::BEGIN@6 at line 6 of DBIx/Class/Relationship/Accessor.pm
# once (31µs+20µs) by DBIx::Class::ResultSource::BEGIN@11 at line 11 of DBIx/Class/ResultSource.pm
# once (30µs+17µs) by DBIx::Class::Storage::DBIHacks::BEGIN@20 at line 20 of DBIx/Class/Storage/DBIHacks.pm
# once (31µs+15µs) by DBIx::Class::Row::BEGIN@11 at line 11 of DBIx/Class/Row.pm
# once (28µs+18µs) by DBIx::Class::Storage::BEGIN@15 at line 15 of DBIx/Class/Storage.pm
# once (29µs+14µs) by DBIx::Class::ResultSet::BEGIN@6 at line 6 of DBIx/Class/ResultSet.pm
# once (27µs+14µs) by DBIx::Class::Storage::DBI::BEGIN@10 at line 10 of DBIx/Class/Storage/DBI.pm
# once (26µs+15µs) by DBIx::Class::Relationship::HasOne::BEGIN@6 at line 6 of DBIx/Class/Relationship/HasOne.pm
# once (27µs+14µs) by DBIx::Class::Componentised::BEGIN@10 at line 10 of DBIx/Class/Componentised.pm
# once (29µs+12µs) by DBIx::Class::SQLMaker::BEGIN@42 at line 42 of DBIx/Class/SQLMaker.pm
# once (26µs+14µs) by DBIx::Class::_Util::BEGIN@56 at line 56 of DBIx/Class/_Util.pm
# once (27µs+12µs) by DBIx::Class::Schema::BEGIN@8 at line 8 of DBIx/Class/Schema.pm
# once (20µs+11µs) by DBIx::Class::Relationship::ManyToMany::BEGIN@7 at line 7 of DBIx/Class/Relationship/ManyToMany.pm
# once (19µs+12µs) by DBIx::Class::Relationship::CascadeActions::BEGIN@6 at line 6 of DBIx/Class/Relationship/CascadeActions.pm
# once (20µs+10µs) by DBIx::Class::Storage::BlockRunner::BEGIN@8 at line 8 of DBIx/Class/Storage/BlockRunner.pm
# once (16µs+10µs) by DBIx::Class::ResultSetColumn::BEGIN@7 at line 7 of DBIx/Class/ResultSetColumn.pm | ||||
78 | 17 | 16µs | my (undef, $skip_pattern) = @_; | ||
79 | 17 | 16µs | my $into = caller; | ||
80 | |||||
81 | 17 | 357µs | 34 | 249µs | $skip_pattern = $skip_pattern # spent 218µs making 17 calls to DBIx::Class::Carp::CORE:regcomp, avg 13µs/call
# spent 30µs making 17 calls to DBIx::Class::Carp::CORE:qr, avg 2µs/call |
82 | ? qr/ ^ $into $ | $skip_pattern /x | ||||
83 | : qr/ ^ $into $ /x | ||||
84 | ; | ||||
85 | |||||
86 | 2 | 283µs | 2 | 29µs | # spent 21µs (12+9) within DBIx::Class::Carp::BEGIN@86 which was called:
# once (12µs+9µs) by DBIx::Class::_Util::BEGIN@56 at line 86 # spent 21µs making 1 call to DBIx::Class::Carp::BEGIN@86
# spent 9µs making 1 call to strict::unimport |
87 | |||||
88 | *{"${into}::carp"} = sub { | ||||
89 | $warn->( | ||||
90 | __find_caller($skip_pattern, $into), | ||||
91 | @_ | ||||
92 | ); | ||||
93 | 17 | 109µs | }; | ||
94 | |||||
95 | 17 | 14µs | my $fired = {}; | ||
96 | *{"${into}::carp_once"} = sub { | ||||
97 | return if $fired->{$_[0]}; | ||||
98 | $fired->{$_[0]} = 1; | ||||
99 | |||||
100 | $warn->( | ||||
101 | __find_caller($skip_pattern, $into), | ||||
102 | @_, | ||||
103 | ); | ||||
104 | 17 | 453µs | }; | ||
105 | |||||
106 | 17 | 7µs | my $seen; | ||
107 | *{"${into}::carp_unique"} = sub { | ||||
108 | my ($ln, $calling) = __find_caller($skip_pattern, $into); | ||||
109 | my $msg = join ('', $calling, @_); | ||||
110 | |||||
111 | # unique carping with a hidden caller makes no sense | ||||
112 | $msg =~ s/\n+$//; | ||||
113 | |||||
114 | return if $seen->{$ln}{$msg}; | ||||
115 | $seen->{$ln}{$msg} = 1; | ||||
116 | |||||
117 | $warn->( | ||||
118 | $ln, | ||||
119 | $msg, | ||||
120 | ); | ||||
121 | 17 | 151µs | }; | ||
122 | } | ||||
123 | |||||
124 | sub unimport { | ||||
125 | die (__PACKAGE__ . " does not implement unimport yet\n"); | ||||
126 | } | ||||
127 | |||||
128 | 1 | 3µs | 1; | ||
129 | |||||
130 | __END__ | ||||
# spent 30µs within DBIx::Class::Carp::CORE:qr which was called 17 times, avg 2µs/call:
# 17 times (30µs+0s) by DBIx::Class::Carp::import at line 81, avg 2µs/call | |||||
# spent 218µs within DBIx::Class::Carp::CORE:regcomp which was called 17 times, avg 13µs/call:
# 17 times (218µs+0s) by DBIx::Class::Carp::import at line 81, avg 13µs/call |