| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Package/DeprecationManager.pm |
| Statements | Executed 117 statements in 5.42ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 9.89ms | 22.5ms | Package::DeprecationManager::BEGIN@10 |
| 1 | 1 | 1 | 9.26ms | 11.9ms | Package::DeprecationManager::BEGIN@11 |
| 1 | 1 | 1 | 4.73ms | 6.04ms | Package::DeprecationManager::BEGIN@12 |
| 8 | 8 | 8 | 1.46ms | 1.46ms | Package::DeprecationManager::__ANON__[:61] |
| 3 | 3 | 3 | 682µs | 2.84ms | Package::DeprecationManager::import |
| 3 | 1 | 1 | 154µs | 154µs | Package::DeprecationManager::_build_warn |
| 3 | 1 | 1 | 77µs | 77µs | Package::DeprecationManager::_build_import |
| 1 | 1 | 1 | 63µs | 63µs | Package::DeprecationManager::BEGIN@2 |
| 1 | 1 | 1 | 37µs | 113µs | Package::DeprecationManager::BEGIN@7 |
| 1 | 1 | 1 | 36µs | 52µs | Package::DeprecationManager::BEGIN@6 |
| 1 | 1 | 1 | 35µs | 186µ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 63µs within Package::DeprecationManager::BEGIN@2 which was called:
# once (63µs+0s) by Moose::Deprecated::BEGIN@10 at line 4 | ||||
| 3 | 1 | 37µs | $Package::DeprecationManager::VERSION = '0.10'; | ||
| 4 | 1 | 72µs | 1 | 63µs | } # spent 63µs making 1 call to Package::DeprecationManager::BEGIN@2 |
| 5 | |||||
| 6 | 3 | 88µs | 2 | 68µs | # spent 52µs (36+16) within Package::DeprecationManager::BEGIN@6 which was called:
# once (36µs+16µs) by Moose::Deprecated::BEGIN@10 at line 6 # spent 52µs making 1 call to Package::DeprecationManager::BEGIN@6
# spent 16µs making 1 call to strict::import |
| 7 | 3 | 110µs | 2 | 188µs | # spent 113µs (37+76) within Package::DeprecationManager::BEGIN@7 which was called:
# once (37µs+76µs) by Moose::Deprecated::BEGIN@10 at line 7 # spent 113µs making 1 call to Package::DeprecationManager::BEGIN@7
# spent 76µs making 1 call to warnings::import |
| 8 | |||||
| 9 | 3 | 103µs | 2 | 337µs | # spent 186µs (35+151) within Package::DeprecationManager::BEGIN@9 which was called:
# once (35µs+151µs) by Moose::Deprecated::BEGIN@10 at line 9 # spent 186µs making 1 call to Package::DeprecationManager::BEGIN@9
# spent 151µs making 1 call to Exporter::import |
| 10 | 3 | 657µs | 2 | 23.0ms | # spent 22.5ms (9.89+12.6) within Package::DeprecationManager::BEGIN@10 which was called:
# once (9.89ms+12.6ms) by Moose::Deprecated::BEGIN@10 at line 10 # spent 22.5ms making 1 call to Package::DeprecationManager::BEGIN@10
# spent 544µs making 1 call to Exporter::import |
| 11 | 3 | 633µs | 2 | 12.4ms | # spent 11.9ms (9.26+2.67) within Package::DeprecationManager::BEGIN@11 which was called:
# once (9.26ms+2.67ms) by Moose::Deprecated::BEGIN@10 at line 11 # spent 11.9ms making 1 call to Package::DeprecationManager::BEGIN@11
# spent 503µs making 1 call to Exporter::import |
| 12 | 3 | 2.34ms | 2 | 6.06ms | # spent 6.04ms (4.73+1.32) within Package::DeprecationManager::BEGIN@12 which was called:
# once (4.73ms+1.32ms) by Moose::Deprecated::BEGIN@10 at line 12 # spent 6.04ms making 1 call to Package::DeprecationManager::BEGIN@12
# spent 21µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284] |
| 13 | |||||
| 14 | # spent 2.84ms (682µs+2.16) within Package::DeprecationManager::import which was called 3 times, avg 948µs/call:
# once (325µs+842µs) by Package::Stash::BEGIN@48 at line 48 of Package/Stash.pm
# once (206µs+807µs) by Class::MOP::Deprecated::BEGIN@10 at line 10 of Class/MOP/Deprecated.pm
# once (151µs+512µs) by Moose::Deprecated::BEGIN@10 at line 10 of Moose/Deprecated.pm | ||||
| 15 | 30 | 680µs | shift; | ||
| 16 | my %args = @_; | ||||
| 17 | |||||
| 18 | 3 | 26µs | croak # spent 26µs making 3 calls to Params::Util::_HASH, avg 9µs/call | ||
| 19 | 'You must provide a hash reference -deprecations parameter when importing Package::DeprecationManager' | ||||
| 20 | unless $args{-deprecations} && _HASH( $args{-deprecations} ); | ||||
| 21 | |||||
| 22 | my %registry; | ||||
| 23 | |||||
| 24 | 3 | 77µs | my $import = _build_import( \%registry ); # spent 77µs making 3 calls to Package::DeprecationManager::_build_import, avg 26µs/call | ||
| 25 | 3 | 154µs | my $warn = _build_warn( \%registry, $args{-deprecations}, $args{-ignore} ); # spent 154µs making 3 calls to Package::DeprecationManager::_build_warn, avg 51µs/call | ||
| 26 | |||||
| 27 | my $caller = caller(); | ||||
| 28 | |||||
| 29 | 3 | 1.02ms | Sub::Install::install_sub( # spent 1.02ms making 3 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 341µs/call | ||
| 30 | { | ||||
| 31 | code => $import, | ||||
| 32 | into => $caller, | ||||
| 33 | as => 'import', | ||||
| 34 | } | ||||
| 35 | ); | ||||
| 36 | |||||
| 37 | 3 | 883µs | Sub::Install::install_sub( # spent 883µs making 3 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 294µs/call | ||
| 38 | { | ||||
| 39 | code => $warn, | ||||
| 40 | into => $caller, | ||||
| 41 | as => 'deprecated', | ||||
| 42 | } | ||||
| 43 | ); | ||||
| 44 | |||||
| 45 | return; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 77µs within Package::DeprecationManager::_build_import which was called 3 times, avg 26µs/call:
# 3 times (77µs+0s) by Package::DeprecationManager::import at line 24, avg 26µs/call | ||||
| 49 | 6 | 91µs | my $registry = shift; | ||
| 50 | |||||
| 51 | # spent 1.46ms 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 182µs/call:
# once (1.21ms+0s) by Class::MOP::Package::BEGIN@9 at line 9 of Class/MOP/Package.pm
# once (50µs+0s) by Moose::Util::TypeConstraints::BEGIN@28 at line 28 of Moose/Util/TypeConstraints.pm
# once (35µs+0s) by Moose::BEGIN@14 at line 14 of Moose.pm
# once (33µs+0s) by Moose::Meta::Attribute::Native::Trait::BEGIN@7 at line 7 of Moose/Meta/Attribute/Native/Trait.pm
# once (33µs+0s) by Moose::Util::MetaRole::BEGIN@13 at line 13 of Moose/Util/MetaRole.pm
# once (32µs+0s) by namespace::clean::BEGIN@16 at line 16 of namespace/clean.pm
# once (32µs+0s) by Moose::Meta::Attribute::BEGIN@16 at line 16 of Moose/Meta/Attribute.pm
# once (32µs+0s) by Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@7 at line 7 of Moose/Util/TypeConstraints/OptimizedConstraints.pm | ||||
| 52 | 40 | 423µs | my $class = shift; | ||
| 53 | my %args = @_; | ||||
| 54 | |||||
| 55 | $args{-api_version} ||= delete $args{-compatible}; | ||||
| 56 | |||||
| 57 | $registry->{ caller() } = $args{-api_version} | ||||
| 58 | if $args{-api_version}; | ||||
| 59 | |||||
| 60 | return; | ||||
| 61 | }; | ||||
| 62 | } | ||||
| 63 | |||||
| 64 | # spent 154µs within Package::DeprecationManager::_build_warn which was called 3 times, avg 51µs/call:
# 3 times (154µs+0s) by Package::DeprecationManager::import at line 25, avg 51µs/call | ||||
| 65 | 21 | 171µs | my $registry = shift; | ||
| 66 | my $deprecated_at = shift; | ||||
| 67 | my $ignore = shift; | ||||
| 68 | |||||
| 69 | my %ignore = map { $_ => 1 } grep { !ref } @{ $ignore || [] }; | ||||
| 70 | my @ignore_res = grep {ref} @{ $ignore || [] }; | ||||
| 71 | |||||
| 72 | 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 | }; | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | 1 | 11µs | 1; | ||
| 127 | |||||
| 128 | # ABSTRACT: Manage deprecation warnings for your distribution | ||||
| 129 | |||||
| - - | |||||
| 132 | =pod | ||||
| 133 | |||||
| - - | |||||
| 275 | __END__ |