| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Package/DeprecationManager.pm |
| Statements | Executed 88 statements in 3.25ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 2 | 2 | 286µs | 1.41ms | Package::DeprecationManager::import |
| 6 | 6 | 6 | 217µs | 217µs | Package::DeprecationManager::__ANON__[:61] |
| 2 | 1 | 1 | 95µs | 95µs | Package::DeprecationManager::_build_warn |
| 1 | 1 | 1 | 46µs | 555µs | Package::DeprecationManager::BEGIN@11 |
| 1 | 1 | 1 | 45µs | 45µs | Package::DeprecationManager::BEGIN@2 |
| 2 | 1 | 1 | 41µs | 41µs | Package::DeprecationManager::_build_import |
| 1 | 1 | 1 | 40µs | 175µs | Package::DeprecationManager::BEGIN@10 |
| 1 | 1 | 1 | 39µs | 60µs | Package::DeprecationManager::BEGIN@12 |
| 1 | 1 | 1 | 39µs | 56µs | Package::DeprecationManager::BEGIN@6 |
| 1 | 1 | 1 | 39µs | 200µs | Package::DeprecationManager::BEGIN@9 |
| 1 | 1 | 1 | 37µs | 102µs | Package::DeprecationManager::BEGIN@7 |
| 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 45µs within Package::DeprecationManager::BEGIN@2 which was called:
# once (45µs+0s) by Class::MOP::Deprecated::BEGIN@10 at line 4 | ||||
| 3 | 1 | 27µs | $Package::DeprecationManager::VERSION = '0.10'; | ||
| 4 | 1 | 83µs | 1 | 45µs | } # spent 45µs making 1 call to Package::DeprecationManager::BEGIN@2 |
| 5 | |||||
| 6 | 3 | 92µs | 2 | 73µs | # spent 56µs (39+17) within Package::DeprecationManager::BEGIN@6 which was called:
# once (39µs+17µs) by Class::MOP::Deprecated::BEGIN@10 at line 6 # spent 56µs making 1 call to Package::DeprecationManager::BEGIN@6
# spent 17µs making 1 call to strict::import |
| 7 | 3 | 120µs | 2 | 168µs | # spent 102µs (37+65) within Package::DeprecationManager::BEGIN@7 which was called:
# once (37µs+65µs) by Class::MOP::Deprecated::BEGIN@10 at line 7 # spent 102µs making 1 call to Package::DeprecationManager::BEGIN@7
# spent 66µs making 1 call to warnings::import |
| 8 | |||||
| 9 | 3 | 125µs | 2 | 362µs | # spent 200µs (39+161) within Package::DeprecationManager::BEGIN@9 which was called:
# once (39µs+161µs) by Class::MOP::Deprecated::BEGIN@10 at line 9 # spent 200µs making 1 call to Package::DeprecationManager::BEGIN@9
# spent 161µs making 1 call to Exporter::import |
| 10 | 3 | 104µs | 2 | 310µs | # spent 175µs (40+135) within Package::DeprecationManager::BEGIN@10 which was called:
# once (40µs+135µs) by Class::MOP::Deprecated::BEGIN@10 at line 10 # spent 175µs making 1 call to Package::DeprecationManager::BEGIN@10
# spent 135µs making 1 call to Exporter::import |
| 11 | 3 | 110µs | 2 | 1.06ms | # spent 555µs (46+509) within Package::DeprecationManager::BEGIN@11 which was called:
# once (46µs+509µs) by Class::MOP::Deprecated::BEGIN@10 at line 11 # spent 555µs making 1 call to Package::DeprecationManager::BEGIN@11
# spent 509µs making 1 call to Exporter::import |
| 12 | 3 | 1.87ms | 2 | 82µs | # spent 60µs (39+21) within Package::DeprecationManager::BEGIN@12 which was called:
# once (39µs+21µs) by Class::MOP::Deprecated::BEGIN@10 at line 12 # spent 60µs 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 1.41ms (286µs+1.13) within Package::DeprecationManager::import which was called 2 times, avg 706µs/call:
# once (165µs+579µs) by Class::MOP::Deprecated::BEGIN@10 at line 10 of Class/MOP/Deprecated.pm
# once (121µs+546µs) by Moose::Deprecated::BEGIN@10 at line 10 of Moose/Deprecated.pm | ||||
| 15 | 20 | 270µs | shift; | ||
| 16 | my %args = @_; | ||||
| 17 | |||||
| 18 | 2 | 13µs | croak # spent 13µs making 2 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 | my %registry; | ||||
| 23 | |||||
| 24 | 2 | 41µs | my $import = _build_import( \%registry ); # spent 41µs making 2 calls to Package::DeprecationManager::_build_import, avg 21µs/call | ||
| 25 | 2 | 95µs | my $warn = _build_warn( \%registry, $args{-deprecations}, $args{-ignore} ); # spent 95µs making 2 calls to Package::DeprecationManager::_build_warn, avg 47µs/call | ||
| 26 | |||||
| 27 | my $caller = caller(); | ||||
| 28 | |||||
| 29 | 2 | 482µs | Sub::Install::install_sub( # spent 482µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 241µs/call | ||
| 30 | { | ||||
| 31 | code => $import, | ||||
| 32 | into => $caller, | ||||
| 33 | as => 'import', | ||||
| 34 | } | ||||
| 35 | ); | ||||
| 36 | |||||
| 37 | 2 | 495µs | Sub::Install::install_sub( # spent 495µs making 2 calls to Sub::Install::__ANON__[Sub/Install.pm:132], avg 247µs/call | ||
| 38 | { | ||||
| 39 | code => $warn, | ||||
| 40 | into => $caller, | ||||
| 41 | as => 'deprecated', | ||||
| 42 | } | ||||
| 43 | ); | ||||
| 44 | |||||
| 45 | return; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 41µs within Package::DeprecationManager::_build_import which was called 2 times, avg 21µs/call:
# 2 times (41µs+0s) by Package::DeprecationManager::import at line 24, avg 21µs/call | ||||
| 49 | 4 | 51µs | my $registry = shift; | ||
| 50 | |||||
| 51 | # spent 217µ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 6 times, avg 36µs/call:
# once (46µs+0s) by Moose::Util::TypeConstraints::OptimizedConstraints::BEGIN@7 at line 7 of Moose/Util/TypeConstraints/OptimizedConstraints.pm
# once (39µs+0s) by Moose::Meta::Attribute::BEGIN@16 at line 16 of Moose/Meta/Attribute.pm
# once (36µ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 (32µs+0s) by Moose::Util::TypeConstraints::BEGIN@28 at line 28 of Moose/Util/TypeConstraints.pm
# once (31µs+0s) by Moose::Util::MetaRole::BEGIN@13 at line 13 of Moose/Util/MetaRole.pm | ||||
| 52 | 30 | 278µ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 95µs within Package::DeprecationManager::_build_warn which was called 2 times, avg 47µs/call:
# 2 times (95µs+0s) by Package::DeprecationManager::import at line 25, avg 47µs/call | ||||
| 65 | 14 | 106µ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__ |