| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Package/DeprecationManager.pm |
| Statements | Executed 117 statements in 3.60ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3 | 3 | 3 | 434µs | 2.00ms | Package::DeprecationManager::import |
| 8 | 8 | 8 | 260µs | 260µs | Package::DeprecationManager::__ANON__[:61] |
| 3 | 1 | 1 | 126µs | 126µs | Package::DeprecationManager::_build_warn |
| 1 | 1 | 1 | 73µs | 92µs | Package::DeprecationManager::BEGIN@6 |
| 3 | 1 | 1 | 69µs | 69µs | Package::DeprecationManager::_build_import |
| 1 | 1 | 1 | 47µs | 541µs | Package::DeprecationManager::BEGIN@11 |
| 1 | 1 | 1 | 46µs | 46µs | Package::DeprecationManager::BEGIN@2 |
| 1 | 1 | 1 | 40µs | 62µs | Package::DeprecationManager::BEGIN@12 |
| 1 | 1 | 1 | 39µs | 167µs | Package::DeprecationManager::BEGIN@10 |
| 1 | 1 | 1 | 38µs | 107µs | Package::DeprecationManager::BEGIN@7 |
| 1 | 1 | 1 | 38µs | 199µs | Package::DeprecationManager::BEGIN@9 |
| 0 | 0 | 0 | 0s | 0s | Package::DeprecationManager::__ANON__[:123] |
| 0 | 0 | 0 | 0s | 0s | Package::DeprecationManager::__ANON__[:83] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Package::DeprecationManager; | ||||
| 2 | # spent 46µs within Package::DeprecationManager::BEGIN@2 which was called:
# once (46µs+0s) by Package::Stash::BEGIN@48 at line 4 | ||||
| 3 | 1 | 28µs | $Package::DeprecationManager::VERSION = '0.10'; | ||
| 4 | 1 | 105µs | 1 | 46µs | } # spent 46µs making 1 call to Package::DeprecationManager::BEGIN@2 |
| 5 | |||||
| 6 | 3 | 96µs | 2 | 111µs | # spent 92µs (73+19) within Package::DeprecationManager::BEGIN@6 which was called:
# once (73µs+19µs) by Package::Stash::BEGIN@48 at line 6 # spent 92µs making 1 call to Package::DeprecationManager::BEGIN@6
# spent 19µs making 1 call to strict::import |
| 7 | 3 | 124µs | 2 | 177µs | # spent 107µs (38+70) within Package::DeprecationManager::BEGIN@7 which was called:
# once (38µs+70µs) by Package::Stash::BEGIN@48 at line 7 # spent 107µs making 1 call to Package::DeprecationManager::BEGIN@7
# spent 70µs making 1 call to warnings::import |
| 8 | |||||
| 9 | 3 | 109µs | 2 | 361µs | # spent 199µs (38+161) within Package::DeprecationManager::BEGIN@9 which was called:
# once (38µs+161µs) by Package::Stash::BEGIN@48 at line 9 # spent 199µs making 1 call to Package::DeprecationManager::BEGIN@9
# spent 161µs making 1 call to Exporter::import |
| 10 | 3 | 101µs | 2 | 295µs | # spent 167µs (39+128) within Package::DeprecationManager::BEGIN@10 which was called:
# once (39µs+128µs) by Package::Stash::BEGIN@48 at line 10 # spent 167µs making 1 call to Package::DeprecationManager::BEGIN@10
# spent 128µs making 1 call to Exporter::import |
| 11 | 3 | 126µs | 2 | 1.04ms | # spent 541µs (47+494) within Package::DeprecationManager::BEGIN@11 which was called:
# once (47µs+494µs) by Package::Stash::BEGIN@48 at line 11 # spent 541µs making 1 call to Package::DeprecationManager::BEGIN@11
# spent 494µs making 1 call to Exporter::import |
| 12 | 3 | 1.91ms | 2 | 84µs | # spent 62µs (40+22) within Package::DeprecationManager::BEGIN@12 which was called:
# once (40µs+22µs) by Package::Stash::BEGIN@48 at line 12 # spent 62µs making 1 call to Package::DeprecationManager::BEGIN@12
# spent 22µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284] |
| 13 | |||||
| 14 | # spent 2.00ms (434µs+1.57) within Package::DeprecationManager::import which was called 3 times, avg 667µs/call:
# once (165µs+548µs) by Package::Stash::BEGIN@48 at line 48 of Package/Stash.pm
# once (145µs+502µs) by Class::MOP::Deprecated::BEGIN@10 at line 10 of Class/MOP/Deprecated.pm
# once (124µs+517µs) by Moose::Deprecated::BEGIN@10 at line 10 of Moose/Deprecated.pm | ||||
| 15 | 3 | 10µs | shift; | ||
| 16 | 3 | 23µs | my %args = @_; | ||
| 17 | |||||
| 18 | 3 | 95µs | 3 | 21µs | croak # spent 21µs making 3 calls to Params::Util::_HASH, avg 7µs/call |
| 19 | 'You must provide a hash reference -deprecations parameter when importing Package::DeprecationManager' | ||||
| 20 | unless $args{-deprecations} && _HASH( $args{-deprecations} ); | ||||
| 21 | |||||
| 22 | 3 | 7µs | my %registry; | ||
| 23 | |||||
| 24 | 3 | 40µs | 3 | 69µs | my $import = _build_import( \%registry ); # spent 69µs making 3 calls to Package::DeprecationManager::_build_import, avg 23µs/call |
| 25 | 3 | 54µs | 3 | 126µs | my $warn = _build_warn( \%registry, $args{-deprecations}, $args{-ignore} ); # spent 126µs making 3 calls to Package::DeprecationManager::_build_warn, avg 42µs/call |
| 26 | |||||
| 27 | 3 | 14µs | my $caller = caller(); | ||
| 28 | |||||
| 29 | 3 | 75µs | 3 | 783µs | Sub::Install::install_sub( # spent 783µs making 3 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 261µs/call |
| 30 | { | ||||
| 31 | code => $import, | ||||
| 32 | into => $caller, | ||||
| 33 | as => 'import', | ||||
| 34 | } | ||||
| 35 | ); | ||||
| 36 | |||||
| 37 | 3 | 53µs | 3 | 568µs | Sub::Install::install_sub( # spent 568µs making 3 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 189µs/call |
| 38 | { | ||||
| 39 | code => $warn, | ||||
| 40 | into => $caller, | ||||
| 41 | as => 'deprecated', | ||||
| 42 | } | ||||
| 43 | ); | ||||
| 44 | |||||
| 45 | 3 | 56µs | return; | ||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 69µs within Package::DeprecationManager::_build_import which was called 3 times, avg 23µs/call:
# 3 times (69µs+0s) by Package::DeprecationManager::import at line 24, avg 23µs/call | ||||
| 49 | 3 | 11µs | my $registry = shift; | ||
| 50 | |||||
| 51 | # spent 260µs within Package::DeprecationManager::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Package/DeprecationManager.pm:61] which was called 8 times, avg 32µs/call:
# once (37µs+0s) by Class::MOP::Package::BEGIN@9 at line 9 of Class/MOP/Package.pm
# once (34µs+0s) by Moose::Meta::Attribute::Native::Trait::BEGIN@7 at line 7 of Moose/Meta/Attribute/Native/Trait.pm
# once (34µs+0s) by Moose::BEGIN@14 at line 14 of Moose.pm
# once (32µs+0s) by namespace::clean::BEGIN@16 at line 16 of namespace/clean.pm
# once (31µs+0s) by Moose::Util::TypeConstraints::BEGIN@28 at line 28 of Moose/Util/TypeConstraints.pm
# once (31µs+0s) by Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@7 at line 7 of Moose/Util/TypeConstraints/OptimizedConstraints.pm
# once (30µs+0s) by Moose::Meta::Attribute::BEGIN@16 at line 16 of Moose/Meta/Attribute.pm
# once (30µs+0s) by Moose::Util::MetaRole::BEGIN@13 at line 13 of Moose/Util/MetaRole.pm | ||||
| 52 | 8 | 36µs | my $class = shift; | ||
| 53 | 8 | 36µs | my %args = @_; | ||
| 54 | |||||
| 55 | 8 | 71µs | $args{-api_version} ||= delete $args{-compatible}; | ||
| 56 | |||||
| 57 | 8 | 26µs | $registry->{ caller() } = $args{-api_version} | ||
| 58 | if $args{-api_version}; | ||||
| 59 | |||||
| 60 | 8 | 164µs | return; | ||
| 61 | 3 | 74µs | }; | ||
| 62 | } | ||||
| 63 | |||||
| 64 | # spent 126µs within Package::DeprecationManager::_build_warn which was called 3 times, avg 42µs/call:
# 3 times (126µs+0s) by Package::DeprecationManager::import at line 25, avg 42µs/call | ||||
| 65 | 3 | 9µs | my $registry = shift; | ||
| 66 | 3 | 6µs | my $deprecated_at = shift; | ||
| 67 | 3 | 11µs | my $ignore = shift; | ||
| 68 | |||||
| 69 | 3 | 20µs | my %ignore = map { $_ => 1 } grep { !ref } @{ $ignore || [] }; | ||
| 70 | 3 | 16µs | my @ignore_res = grep {ref} @{ $ignore || [] }; | ||
| 71 | |||||
| 72 | 3 | 6µs | my %warned; | ||
| 73 | |||||
| 74 | return sub { | ||||
| 75 | my %args = @_ < 2 ? ( message => shift ) : @_; | ||||
| 76 | |||||
| 77 | my ( $package, undef, undef, $sub ) = caller(1); | ||||
| 78 | |||||
| 79 | my $skipped = 1; | ||||
| 80 | |||||
| 81 | if ( @ignore_res || keys %ignore ) { | ||||
| 82 | while ( defined $package | ||||
| 83 | && ( $ignore{$package} || any { $package =~ $_ } @ignore_res ) | ||||
| 84 | ) { | ||||
| 85 | $package = caller( $skipped++ ); | ||||
| 86 | } | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | $package = 'unknown package' unless defined $package; | ||||
| 90 | |||||
| 91 | unless ( defined $args{feature} ) { | ||||
| 92 | $args{feature} = $sub; | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | my $compat_version = $registry->{$package}; | ||||
| 96 | |||||
| 97 | my $deprecated_at = $deprecated_at->{ $args{feature} }; | ||||
| 98 | |||||
| 99 | return | ||||
| 100 | if defined $compat_version | ||||
| 101 | && defined $deprecated_at | ||||
| 102 | && $compat_version lt $deprecated_at; | ||||
| 103 | |||||
| 104 | my $msg; | ||||
| 105 | if ( defined $args{message} ) { | ||||
| 106 | $msg = $args{message}; | ||||
| 107 | } | ||||
| 108 | else { | ||||
| 109 | $msg = "$args{feature} has been deprecated"; | ||||
| 110 | $msg .= " since version $deprecated_at" | ||||
| 111 | if defined $deprecated_at; | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | return if $warned{$package}{ $args{feature} }{$msg}; | ||||
| 115 | |||||
| 116 | $warned{$package}{ $args{feature} }{$msg} = 1; | ||||
| 117 | |||||
| 118 | # We skip at least two levels. One for this anon sub, and one for the | ||||
| 119 | # sub calling it. | ||||
| 120 | local $Carp::CarpLevel = $Carp::CarpLevel + $skipped; | ||||
| 121 | |||||
| 122 | Carp::cluck($msg); | ||||
| 123 | 3 | 73µs | }; | ||
| 124 | } | ||||
| 125 | |||||
| 126 | 1 | 10µs | 1; | ||
| 127 | |||||
| 128 | # ABSTRACT: Manage deprecation warnings for your distribution | ||||
| 129 | |||||
| - - | |||||
| 132 | =pod | ||||
| 133 | |||||
| - - | |||||
| 275 | __END__ |