Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Package/DeprecationManager.pm |
Statements | Executed 89 statements in 791µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 253µs | 802µs | BEGIN@10 | Package::DeprecationManager::
2 | 2 | 2 | 53µs | 205µs | import | Package::DeprecationManager::
4 | 4 | 4 | 21µs | 21µs | __ANON__[:87] | Package::DeprecationManager::
1 | 1 | 1 | 18µs | 114µs | BEGIN@9 | Package::DeprecationManager::
2 | 1 | 1 | 14µs | 14µs | _build_warn | Package::DeprecationManager::
1 | 1 | 1 | 11µs | 13µs | BEGIN@3 | Package::DeprecationManager::
1 | 1 | 1 | 9µs | 72µs | BEGIN@11 | Package::DeprecationManager::
1 | 1 | 1 | 6µs | 10µs | BEGIN@4 | Package::DeprecationManager::
1 | 1 | 1 | 6µs | 35µs | BEGIN@8 | Package::DeprecationManager::
1 | 1 | 1 | 6µs | 11µs | BEGIN@12 | Package::DeprecationManager::
2 | 1 | 1 | 6µs | 6µs | _build_import | Package::DeprecationManager::
0 | 0 | 0 | 0s | 0s | __ANON__[:109] | Package::DeprecationManager::
0 | 0 | 0 | 0s | 0s | __ANON__[:149] | Package::DeprecationManager::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Package::DeprecationManager; | ||||
2 | |||||
3 | 2 | 30µs | 2 | 15µs | # spent 13µs (11+2) within Package::DeprecationManager::BEGIN@3 which was called:
# once (11µs+2µs) by Moose::Deprecated::BEGIN@7 at line 3 # spent 13µs making 1 call to Package::DeprecationManager::BEGIN@3
# spent 2µs making 1 call to strict::import |
4 | 2 | 32µs | 2 | 14µs | # spent 10µs (6+4) within Package::DeprecationManager::BEGIN@4 which was called:
# once (6µs+4µs) by Moose::Deprecated::BEGIN@7 at line 4 # spent 10µs making 1 call to Package::DeprecationManager::BEGIN@4
# spent 4µs making 1 call to warnings::import |
5 | |||||
6 | 1 | 300ns | our $VERSION = '0.15'; | ||
7 | |||||
8 | 2 | 29µs | 2 | 63µs | # spent 35µs (6+28) within Package::DeprecationManager::BEGIN@8 which was called:
# once (6µs+28µs) by Moose::Deprecated::BEGIN@7 at line 8 # spent 35µs making 1 call to Package::DeprecationManager::BEGIN@8
# spent 28µs making 1 call to Exporter::import |
9 | 3 | 54µs | 3 | 138µs | # spent 114µs (18+96) within Package::DeprecationManager::BEGIN@9 which was called:
# once (18µs+96µs) by Moose::Deprecated::BEGIN@7 at line 9 # spent 114µs making 1 call to Package::DeprecationManager::BEGIN@9
# spent 13µs making 1 call to List::Util::import
# spent 10µs making 1 call to UNIVERSAL::VERSION |
10 | 2 | 108µs | 1 | 802µs | # spent 802µs (253+549) within Package::DeprecationManager::BEGIN@10 which was called:
# once (253µs+549µs) by Moose::Deprecated::BEGIN@7 at line 10 # spent 802µs making 1 call to Package::DeprecationManager::BEGIN@10 |
11 | 2 | 22µs | 2 | 135µs | # spent 72µs (9+63) within Package::DeprecationManager::BEGIN@11 which was called:
# once (9µs+63µs) by Moose::Deprecated::BEGIN@7 at line 11 # spent 72µs making 1 call to Package::DeprecationManager::BEGIN@11
# spent 63µs making 1 call to Exporter::import |
12 | 2 | 411µs | 2 | 16µs | # spent 11µs (6+5) within Package::DeprecationManager::BEGIN@12 which was called:
# once (6µs+5µs) by Moose::Deprecated::BEGIN@7 at line 12 # spent 11µs making 1 call to Package::DeprecationManager::BEGIN@12
# spent 5µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:270] |
13 | |||||
14 | # spent 205µs (53+151) within Package::DeprecationManager::import which was called 2 times, avg 102µs/call:
# once (28µs+83µs) by Moose::Deprecated::BEGIN@7 at line 7 of Moose/Deprecated.pm
# once (26µs+68µs) by Class::MOP::Deprecated::BEGIN@7 at line 7 of Class/MOP/Deprecated.pm | ||||
15 | 2 | 200ns | shift; | ||
16 | 2 | 2µs | my %args = @_; | ||
17 | |||||
18 | croak | ||||
19 | 'You must provide a hash reference -deprecations parameter when importing Package::DeprecationManager' | ||||
20 | 2 | 11µs | 2 | 2µs | unless $args{-deprecations} && _HASH0( $args{-deprecations} ); # spent 2µs making 2 calls to Params::Util::_HASH0, avg 1µs/call |
21 | |||||
22 | 2 | 300ns | my %registry; | ||
23 | |||||
24 | 2 | 1µs | my $caller = caller(); | ||
25 | |||||
26 | 2 | 14µs | 2 | 4µs | my $orig_import = $caller->can('import'); # spent 4µs making 2 calls to UNIVERSAL::can, avg 2µs/call |
27 | |||||
28 | 2 | 3µs | 2 | 6µs | my $import = _build_import( \%registry, $orig_import ); # spent 6µs making 2 calls to Package::DeprecationManager::_build_import, avg 3µs/call |
29 | my $warn | ||||
30 | 2 | 6µs | 2 | 14µs | = _build_warn( \%registry, $args{-deprecations}, $args{-ignore} ); # spent 14µs making 2 calls to Package::DeprecationManager::_build_warn, avg 7µs/call |
31 | |||||
32 | # We need to remove this to prevent a 'subroutine redefined' warning. | ||||
33 | 2 | 600ns | if ($orig_import) { | ||
34 | Package::Stash->new($caller)->remove_symbol('&import'); | ||||
35 | } | ||||
36 | |||||
37 | Sub::Install::install_sub( | ||||
38 | { | ||||
39 | 2 | 7µs | 2 | 92µs | code => $import, # spent 92µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 46µs/call |
40 | into => $caller, | ||||
41 | as => 'import', | ||||
42 | } | ||||
43 | ); | ||||
44 | |||||
45 | 2 | 4µs | 2 | 32µs | Sub::Install::install_sub( # spent 32µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 16µs/call |
46 | { | ||||
47 | code => $warn, | ||||
48 | into => $caller, | ||||
49 | as => 'deprecated', | ||||
50 | } | ||||
51 | ); | ||||
52 | |||||
53 | 2 | 6µs | return; | ||
54 | } | ||||
55 | |||||
56 | # spent 6µs within Package::DeprecationManager::_build_import which was called 2 times, avg 3µs/call:
# 2 times (6µs+0s) by Package::DeprecationManager::import at line 28, avg 3µs/call | ||||
57 | 2 | 500ns | my $registry = shift; | ||
58 | 2 | 500ns | my $orig_import = shift; | ||
59 | |||||
60 | # spent 21µs within Package::DeprecationManager::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Package/DeprecationManager.pm:87] which was called 4 times, avg 5µs/call:
# once (7µs+0s) by Moose::Util::MetaRole::BEGIN@9 at line 9 of Moose/Util/MetaRole.pm
# once (6µs+0s) by Moose::Meta::Attribute::BEGIN@12 at line 12 of Moose/Meta/Attribute.pm
# once (5µs+0s) by Moose::Util::TypeConstraints::BEGIN@7 at line 7 of Moose/Util/TypeConstraints.pm
# once (4µs+0s) by Moose::BEGIN@14 at line 14 of Moose.pm | ||||
61 | 4 | 2µs | my $class = shift; | ||
62 | |||||
63 | 4 | 2µs | my @args; | ||
64 | |||||
65 | my $api_version; | ||||
66 | ## no critic (ControlStructures::ProhibitCStyleForLoops) | ||||
67 | 4 | 5µs | for ( my $i = 0; $i < @_; $i++ ) { | ||
68 | if ( $_[$i] eq '-api_version' || $_[$i] eq '-compatible' ) { | ||||
69 | $api_version = $_[ ++$i ]; | ||||
70 | } | ||||
71 | else { | ||||
72 | push @args, $_[$i]; | ||||
73 | } | ||||
74 | } | ||||
75 | ## use critic | ||||
76 | |||||
77 | 4 | 3µs | my $caller = caller(); | ||
78 | 4 | 1µs | $registry->{$caller} = $api_version | ||
79 | if defined $api_version; | ||||
80 | |||||
81 | 4 | 900ns | if ($orig_import) { | ||
82 | @_ = ( $class, @args ); | ||||
83 | goto &{$orig_import}; | ||||
84 | } | ||||
85 | |||||
86 | 4 | 12µs | return; | ||
87 | 2 | 7µs | }; | ||
88 | } | ||||
89 | |||||
90 | # spent 14µs within Package::DeprecationManager::_build_warn which was called 2 times, avg 7µs/call:
# 2 times (14µs+0s) by Package::DeprecationManager::import at line 30, avg 7µs/call | ||||
91 | 2 | 600ns | my $registry = shift; | ||
92 | 2 | 400ns | my $deprecated_at = shift; | ||
93 | 2 | 800ns | my $ignore = shift; | ||
94 | |||||
95 | 2 | 4µs | my %ignore = map { $_ => 1 } grep { !ref } @{ $ignore || [] }; | ||
96 | 2 | 2µs | my @ignore_res = grep {ref} @{ $ignore || [] }; | ||
97 | |||||
98 | 2 | 200ns | my %warned; | ||
99 | |||||
100 | return sub { | ||||
101 | my %args = @_ < 2 ? ( message => shift ) : @_; | ||||
102 | |||||
103 | my ( $package, undef, undef, $sub ) = caller(1); | ||||
104 | |||||
105 | my $skipped = 1; | ||||
106 | |||||
107 | if ( @ignore_res || keys %ignore ) { | ||||
108 | while ( defined $package | ||||
109 | && ( $ignore{$package} || any { $package =~ $_ } @ignore_res ) | ||||
110 | ) { | ||||
111 | $package = caller( $skipped++ ); | ||||
112 | } | ||||
113 | } | ||||
114 | |||||
115 | $package = 'unknown package' unless defined $package; | ||||
116 | |||||
117 | unless ( defined $args{feature} ) { | ||||
118 | $args{feature} = $sub; | ||||
119 | } | ||||
120 | |||||
121 | my $compat_version = $registry->{$package}; | ||||
122 | |||||
123 | my $at = $deprecated_at->{ $args{feature} }; | ||||
124 | |||||
125 | return | ||||
126 | if defined $compat_version | ||||
127 | && defined $deprecated_at | ||||
128 | && $compat_version lt $at; | ||||
129 | |||||
130 | my $msg; | ||||
131 | if ( defined $args{message} ) { | ||||
132 | $msg = $args{message}; | ||||
133 | } | ||||
134 | else { | ||||
135 | $msg = "$args{feature} has been deprecated"; | ||||
136 | $msg .= " since version $at" | ||||
137 | if defined $at; | ||||
138 | } | ||||
139 | |||||
140 | return if $warned{$package}{ $args{feature} }{$msg}; | ||||
141 | |||||
142 | $warned{$package}{ $args{feature} }{$msg} = 1; | ||||
143 | |||||
144 | # We skip at least two levels. One for this anon sub, and one for the | ||||
145 | # sub calling it. | ||||
146 | local $Carp::CarpLevel = $Carp::CarpLevel + $skipped; | ||||
147 | |||||
148 | Carp::cluck($msg); | ||||
149 | 2 | 9µs | }; | ||
150 | } | ||||
151 | |||||
152 | 1 | 2µs | 1; | ||
153 | |||||
154 | # ABSTRACT: Manage deprecation warnings for your distribution | ||||
155 | |||||
156 | __END__ |