Profile of DBIx/Class/Carp.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:59 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Carp.pm
Statements | Executed 310 statements in 4.33ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
90 | 4 | 1 | 1.92ms | 1.92ms | DBIx::Class::Carp::::CORE:regcompDBIx::Class::Carp::CORE:regcomp (opcode)
2 | 1 | 1 | 914µs | 4.14ms | DBIx::Class::Carp::::__find_callerDBIx::Class::Carp::__find_caller
16 | 16 | 16 | 527µs | 1.32ms | DBIx::Class::Carp::::importDBIx::Class::Carp::import
50 | 2 | 1 | 163µs | 163µs | DBIx::Class::Carp::::CORE:matchDBIx::Class::Carp::CORE:match (opcode)
56 | 3 | 1 | 127µs | 127µs | DBIx::Class::Carp::::CORE:qrDBIx::Class::Carp::CORE:qr (opcode)
1 | 1 | 1 | 12µs | 14µs | DBIx::Class::Carp::::BEGIN@3DBIx::Class::Carp::BEGIN@3
1 | 1 | 1 | 7µs | 18µs | DBIx::Class::Carp::::BEGIN@4DBIx::Class::Carp::BEGIN@4
1 | 1 | 1 | 7µs | 16µs | DBIx::Class::Carp::::BEGIN@75DBIx::Class::Carp::BEGIN@75
1 | 1 | 1 | 7µs | 7µs | DBIx::Class::Carp::::BEGIN@7DBIx::Class::Carp::BEGIN@7
1 | 1 | 1 | 4µs | 4µs | DBIx::Class::Carp::::BEGIN@17DBIx::Class::Carp::BEGIN@17
1 | 1 | 1 | 3µs | 3µs | DBIx::Class::Carp::::BEGIN@18DBIx::Class::Carp::BEGIN@18
0 | 0 | 0 | 0s | 0s | DBIx::Class::Carp::::__ANON__[:110]DBIx::Class::Carp::__ANON__[:110]
0 | 0 | 0 | 0s | 0s | DBIx::Class::Carp::::__ANON__[:64]DBIx::Class::Carp::__ANON__[:64]
0 | 0 | 0 | 0s | 0s | DBIx::Class::Carp::::__ANON__[:82]DBIx::Class::Carp::__ANON__[:82]
0 | 0 | 0 | 0s | 0s | DBIx::Class::Carp::::__ANON__[:93]DBIx::Class::Carp::__ANON__[:93]
0 | 0 | 0 | 0s | 0s | DBIx::Class::Carp::::unimportDBIx::Class::Carp::unimport

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package DBIx::Class::Carp;
2 |  |  |  |  |
3 | 3 | 18µs | 2 | 17µs | # spent 14µs (12+2) within DBIx::Class::Carp::BEGIN@3 which was called: # once (12µs+2µs) by DBIx::Class::Componentised::BEGIN@10 at line 3 use strict; # spent 14µs making 1 call to DBIx::Class::Carp::BEGIN@3 # spent 2µs making 1 call to strict::import
4 | 3 | 58µs | 2 | 29µs | # spent 18µs (7+11) within DBIx::Class::Carp::BEGIN@4 which was called: # once (7µs+11µs) by DBIx::Class::Componentised::BEGIN@10 at line 4 use warnings; # spent 18µs making 1 call to DBIx::Class::Carp::BEGIN@4 # spent 11µs making 1 call to warnings::import
5 |  |  |  |  |
6 |  |  |  |  | # This is here instead of DBIx::Class because of load-order issues
7 |  |  |  |  | # spent 7µs within DBIx::Class::Carp::BEGIN@7 which was called: # once (7µs+0s) by DBIx::Class::Componentised::BEGIN@10 at line 15 BEGIN {
8 |  |  |  |  | # something is tripping up V::M on 5.8.1, leading to segfaults.
9 |  |  |  |  | # A similar test in n::c itself is disabled on 5.8.1 for the same
10 |  |  |  |  | # reason. There isn't much motivation to try to find why it happens
11 |  |  |  |  | *DBIx::Class::_ENV_::BROKEN_NAMESPACE_CLEAN = ($] < 5.008005)
12 |  |  |  |  | ? sub () { 1 }
13 |  |  |  |  | : sub () { 0 }
14 | 1 | 7µs |  |  | ;
15 | 1 | 14µs | 1 | 7µs | } # spent 7µs making 1 call to DBIx::Class::Carp::BEGIN@7
16 |  |  |  |  |
17 | 3 | 16µs | 1 | 4µs | # spent 4µs within DBIx::Class::Carp::BEGIN@17 which was called: # once (4µs+0s) by DBIx::Class::Componentised::BEGIN@10 at line 17 use Carp (); # spent 4µs making 1 call to DBIx::Class::Carp::BEGIN@17
18 | 3 | 223µs | 1 | 3µs | # spent 3µs within DBIx::Class::Carp::BEGIN@18 which was called: # once (3µs+0s) by DBIx::Class::Componentised::BEGIN@10 at line 18 use namespace::clean (); # spent 3µs making 1 call to DBIx::Class::Carp::BEGIN@18
19 |  |  |  |  |
20 |  |  |  |  | # spent 4.14ms (914µs+3.22) within DBIx::Class::Carp::__find_caller which was called 2 times, avg 2.07ms/call: # 2 times (914µs+3.22ms) by DBIx::Class::Exception::throw at line 58 of DBIx/Class/Exception.pm, avg 2.07ms/call sub __find_caller {
21 | 16 | 174µs |  |  | my ($skip_pattern, $class) = @_;
22 |  |  |  |  |
23 |  |  | 4 | 68µs | my $skip_class_data = $class->_skip_namespace_frames # spent 59µs making 2 calls to DBIx::Class::_skip_namespace_frames, avg 30µs/call # spent 8µs making 2 calls to UNIVERSAL::can, avg 4µs/call
24 |  |  |  |  | if ($class and $class->can('_skip_namespace_frames'));
25 |  |  |  |  |
26 |  |  | 4 | 34µs | $skip_pattern = qr/$skip_pattern|$skip_class_data/ # spent 22µs making 2 calls to DBIx::Class::Carp::CORE:regcomp, avg 11µs/call # spent 12µs making 2 calls to DBIx::Class::Carp::CORE:qr, avg 6µs/call
27 |  |  |  |  | if $skip_class_data;
28 |  |  |  |  |
29 |  |  |  |  | my $fr_num = 1; # skip us and the calling carp*
30 |  |  |  |  | my @f;
31 |  |  |  |  | while (@f = caller($fr_num++)) {
32 | 94 | 938µs | 96 | 207µs | last unless $f[0] =~ $skip_pattern; # spent 159µs making 48 calls to DBIx::Class::Carp::CORE:match, avg 3µs/call # spent 48µs making 48 calls to DBIx::Class::Carp::CORE:regcomp, avg 994ns/call
33 |  |  |  |  |
34 | 38 | 2.00ms | 84 | 1.04ms | if ( # spent 940µs making 38 calls to DBIx::Class::_skip_namespace_frames, avg 25µs/call # spent 99µs making 46 calls to UNIVERSAL::can, avg 2µs/call
35 |  |  |  |  | $f[0]->can('_skip_namespace_frames')
36 |  |  |  |  | and
37 |  |  |  |  | my $extra_skip = $f[0]->_skip_namespace_frames
38 |  |  |  |  | ) {
39 |  |  | 76 | 1.87ms | $skip_pattern = qr/$skip_pattern|$extra_skip/; # spent 1.83ms making 38 calls to DBIx::Class::Carp::CORE:regcomp, avg 48µs/call # spent 43µs making 38 calls to DBIx::Class::Carp::CORE:qr, avg 1µs/call
40 |  |  |  |  | }
41 |  |  |  |  | }
42 |  |  |  |  |
43 |  |  |  |  | my ($ln, $calling) = @f # if empty - nothing matched - full stack
44 |  |  |  |  | ? ( "at $f[1] line $f[2]", $f[3] )
45 |  |  |  |  | : ( Carp::longmess(), '{UNKNOWN}' )
46 |  |  |  |  | ;
47 |  |  |  |  |
48 |  |  |  |  | return (
49 |  |  | 2 | 3µs | $ln, # spent 3µs making 2 calls to DBIx::Class::Carp::CORE:match, avg 2µs/call
50 |  |  |  |  | $calling =~ /::/ ? "$calling(): " : "$calling: ", # cargo-cult from Carp::Clan
51 |  |  |  |  | );
52 |  |  |  |  | };
53 |  |  |  |  |
54 |  |  |  |  | my $warn = sub {
55 |  |  |  |  | my ($ln, @warn) = @_;
56 |  |  |  |  | @warn = "Warning: something's wrong" unless @warn;
57 |  |  |  |  |
58 |  |  |  |  | # back-compat with Carp::Clan - a warning ending with \n does
59 |  |  |  |  | # not include caller info
60 |  |  |  |  | warn (
61 |  |  |  |  | @warn,
62 |  |  |  |  | $warn[-1] =~ /\n$/ ? '' : " $ln\n"
63 |  |  |  |  | );
64 | 1 | 3µs |  |  | };
65 |  |  |  |  |
66 |  |  |  |  | # spent 1.32ms (527µs+798µs) within DBIx::Class::Carp::import which was called 16 times, avg 83µs/call: # once (32µs+72µs) by DBIx::Class::Componentised::BEGIN@10 at line 10 of DBIx/Class/Componentised.pm # once (42µs+59µs) by DBIx::Class::Storage::BEGIN@15 at line 15 of DBIx/Class/Storage.pm # once (42µs+58µs) by SQL::Translator::Parser::DBIx::Class::BEGIN@17 at line 17 of SQL/Translator/Parser/DBIx/Class.pm # once (37µs+57µs) by DBIx::Class::SQLMaker::BEGIN@46 at line 46 of DBIx/Class/SQLMaker.pm # once (34µs+60µs) by DBIx::Class::Schema::BEGIN@7 at line 7 of DBIx/Class/Schema.pm # once (36µs+57µs) by DBIx::Class::Storage::DBI::SQLite::BEGIN@9 at line 9 of DBIx/Class/Storage/DBI/SQLite.pm # once (38µs+53µs) by DBIx::Class::Relationship::HasOne::BEGIN@6 at line 6 of DBIx/Class/Relationship/HasOne.pm # once (36µs+54µs) by DBIx::Class::InflateColumn::DateTime::BEGIN@6 at line 6 of DBIx/Class/InflateColumn/DateTime.pm # once (35µs+49µs) by DBIx::Class::ResultSet::BEGIN@6 at line 6 of DBIx/Class/ResultSet.pm # once (33µs+50µs) by DBIx::Class::Schema::Versioned::BEGIN@204 at line 204 of DBIx/Class/Schema/Versioned.pm # once (30µs+53µs) by DBIx::Class::Relationship::CascadeActions::BEGIN@6 at line 6 of DBIx/Class/Relationship/CascadeActions.pm # once (34µs+47µs) by DBIx::Class::Storage::DBI::BEGIN@10 at line 10 of DBIx/Class/Storage/DBI.pm # once (31µs+41µs) by DBIx::Class::ResultSource::BEGIN@10 at line 10 of DBIx/Class/ResultSource.pm # once (26µs+34µs) by DBIx::Class::Relationship::ManyToMany::BEGIN@7 at line 7 of DBIx/Class/Relationship/ManyToMany.pm # once (22µs+28µs) by DBIx::Class::Storage::TxnScopeGuard::BEGIN@9 at line 9 of DBIx/Class/Storage/TxnScopeGuard.pm # once (18µs+27µs) by DBIx::Class::ResultSetColumn::BEGIN@7 at line 7 of DBIx/Class/ResultSetColumn.pm sub import {
67 | 144 | 636µs |  |  | my (undef, $skip_pattern) = @_;
68 |  |  |  |  | my $into = caller;
69 |  |  |  |  |
70 |  |  | 18 | 94µs | $skip_pattern = $skip_pattern # spent 73µs making 16 calls to DBIx::Class::Carp::CORE:qr, avg 5µs/call # spent 21µs making 2 calls to DBIx::Class::Carp::CORE:regcomp, avg 11µs/call
71 |  |  |  |  | ? qr/ ^ $into $ | $skip_pattern /xo
72 |  |  |  |  | : qr/ ^ $into $ /xo
73 |  |  |  |  | ;
74 |  |  |  |  |
75 | 3 | 241µs | 2 | 25µs | # spent 16µs (7+9) within DBIx::Class::Carp::BEGIN@75 which was called: # once (7µs+9µs) by DBIx::Class::Componentised::BEGIN@10 at line 75 no strict 'refs'; # spent 16µs making 1 call to DBIx::Class::Carp::BEGIN@75 # spent 9µs making 1 call to strict::unimport
76 |  |  |  |  |
77 |  |  |  |  | *{"${into}::carp"} = sub {
78 |  |  |  |  | $warn->(
79 |  |  |  |  | __find_caller($skip_pattern, $into),
80 |  |  |  |  | @_
81 |  |  |  |  | );
82 |  |  |  |  | };
83 |  |  |  |  |
84 |  |  |  |  | my $fired;
85 |  |  |  |  | *{"${into}::carp_once"} = sub {
86 |  |  |  |  | return if $fired;
87 |  |  |  |  | $fired = 1;
88 |  |  |  |  |
89 |  |  |  |  | $warn->(
90 |  |  |  |  | __find_caller($skip_pattern, $into),
91 |  |  |  |  | @_,
92 |  |  |  |  | );
93 |  |  |  |  | };
94 |  |  |  |  |
95 |  |  |  |  | my $seen;
96 |  |  |  |  | *{"${into}::carp_unique"} = sub {
97 |  |  |  |  | my ($ln, $calling) = __find_caller($skip_pattern, $into);
98 |  |  |  |  | my $msg = join ('', $calling, @_);
99 |  |  |  |  |
100 |  |  |  |  | # unique carping with a hidden caller makes no sense
101 |  |  |  |  | $msg =~ s/\n+$//;
102 |  |  |  |  |
103 |  |  |  |  | return if $seen->{$ln}{$msg};
104 |  |  |  |  | $seen->{$ln}{$msg} = 1;
105 |  |  |  |  |
106 |  |  |  |  | $warn->(
107 |  |  |  |  | $ln,
108 |  |  |  |  | $msg,
109 |  |  |  |  | );
110 |  |  |  |  | };
111 |  |  |  |  |
112 |  |  |  |  | # cleanup after ourselves
113 |  |  | 16 | 704µs | namespace::clean->import(-cleanee => $into, qw/carp carp_once carp_unique/) # spent 704µs making 16 calls to namespace::clean::import, avg 44µs/call
114 |  |  |  |  | ## FIXME FIXME FIXME - something is tripping up V::M on 5.8.1, leading
115 |  |  |  |  | # to segfaults. When n::c/B::H::EndOfScope is rewritten in terms of tie()
116 |  |  |  |  | # see if this starts working
117 |  |  |  |  | unless DBIx::Class::_ENV_::BROKEN_NAMESPACE_CLEAN();
118 |  |  |  |  | }
119 |  |  |  |  |
120 |  |  |  |  | sub unimport {
121 |  |  |  |  | die (__PACKAGE__ . " does not implement unimport yet\n");
122 |  |  |  |  | }
123 |  |  |  |  |
124 | 1 | 2µs |  |  | 1;
125 |  |  |  |  |
126 |  |  |  |  | =head1 NAME
127 |  |  |  |  |
128 |  |  |  |  | DBIx::Class::Carp - Provides advanced Carp::Clan-like warning functions for DBIx::Class internals
129 |  |  |  |  |
130 |  |  |  |  | =head1 DESCRIPTION
131 |  |  |  |  |
132 |  |  |  |  | Documentation is lacking on purpose - this an experiment not yet fit for
133 |  |  |  |  | mass consumption. If you use this do not count on any kind of stability,
134 |  |  |  |  | in fact don't even count on this module's continuing existence (it has
135 |  |  |  |  | been noindexed for a reason).
136 |  |  |  |  |
137 |  |  |  |  | In addition to the classic interface:
138 |  |  |  |  |
139 |  |  |  |  | use DBIx::Class::Carp '^DBIx::Class'
140 |  |  |  |  |
141 |  |  |  |  | this module also supports a class-data based way to specify the exclusion
142 |  |  |  |  | regex. A message is only carped from a callsite that matches neither the
143 |  |  |  |  | closed over string, nor the value of L</_skip_namespace_frames> as declared
144 |  |  |  |  | on any callframe already skipped due to the same mechanism. This is to ensure
145 |  |  |  |  | that intermediate callsites can declare their own additional skip-namespaces.
146 |  |  |  |  |
147 |  |  |  |  | =head1 CLASS ATTRIBUTES
148 |  |  |  |  |
149 |  |  |  |  | =head2 _skip_namespace_frames
150 |  |  |  |  |
151 |  |  |  |  | A classdata attribute holding the stringified regex matching callsites that
152 |  |  |  |  | should be skipped by the carp methods below. An empty string C<q{}> is treated
153 |  |  |  |  | like no setting/C<undef> (the distinction is necessary due to semantics of the
154 |  |  |  |  | class data accessors provided by L<Class::Accessor::Grouped>)
155 |  |  |  |  |
156 |  |  |  |  | =head1 EXPORTED FUNCTIONS
157 |  |  |  |  |
158 |  |  |  |  | This module export the following 3 functions. Only warning related C<carp*>
159 |  |  |  |  | is being handled here, for C<croak>-ing you must use
160 |  |  |  |  | L<DBIx::Class::Schema/throw_exception> or L<DBIx::Class::Exception>.
161 |  |  |  |  |
162 |  |  |  |  | =head2 carp
163 |  |  |  |  |
164 |  |  |  |  | Carps message with the file/line of the first callsite not matching
165 |  |  |  |  | L</_skip_namespace_frames> nor the closed-over arguments to
166 |  |  |  |  | C<use DBIx::Class::Carp>.
167 |  |  |  |  |
168 |  |  |  |  | =head2 carp_unique
169 |  |  |  |  |
170 |  |  |  |  | Like L</carp> but warns once for every distinct callsite (subject to the
171 |  |  |  |  | same ruleset as L</carp>).
172 |  |  |  |  |
173 |  |  |  |  | =head2 carp_once
174 |  |  |  |  |
175 |  |  |  |  | Like L</carp> but warns only once for the life of the perl interpreter
176 |  |  |  |  | (regardless of callsite).
177 |  |  |  |  |
178 |  |  |  |  | =cut
|  |  |  |  | # spent 163µs within DBIx::Class::Carp::CORE:match which was called 50 times, avg 3µs/call: # 48 times (159µs+0s) by DBIx::Class::Carp::__find_caller at line 32, avg 3µs/call # 2 times (3µs+0s) by DBIx::Class::Carp::__find_caller at line 49, avg 2µs/call sub DBIx::Class::Carp::CORE:match; # opcode
|  |  |  |  | # spent 127µs within DBIx::Class::Carp::CORE:qr which was called 56 times, avg 2µs/call: # 38 times (43µs+0s) by DBIx::Class::Carp::__find_caller at line 39, avg 1µs/call # 16 times (73µs+0s) by DBIx::Class::Carp::import at line 70, avg 5µs/call # 2 times (12µs+0s) by DBIx::Class::Carp::__find_caller at line 26, avg 6µs/call sub DBIx::Class::Carp::CORE:qr; # opcode
|  |  |  |  | # spent 1.92ms within DBIx::Class::Carp::CORE:regcomp which was called 90 times, avg 21µs/call: # 48 times (48µs+0s) by DBIx::Class::Carp::__find_caller at line 32, avg 994ns/call # 38 times (1.83ms+0s) by DBIx::Class::Carp::__find_caller at line 39, avg 48µs/call # 2 times (22µs+0s) by DBIx::Class::Carp::__find_caller at line 26, avg 11µs/call # 2 times (21µs+0s) by DBIx::Class::Carp::import at line 70, avg 11µs/call sub DBIx::Class::Carp::CORE:regcomp; # opcode