← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Package/DeprecationManager.pm
StatementsExecuted 89 statements in 791µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111253µs802µsPackage::DeprecationManager::::BEGIN@10Package::DeprecationManager::BEGIN@10
22253µs205µsPackage::DeprecationManager::::importPackage::DeprecationManager::import
44421µs21µsPackage::DeprecationManager::::__ANON__[:87]Package::DeprecationManager::__ANON__[:87]
11118µs114µsPackage::DeprecationManager::::BEGIN@9Package::DeprecationManager::BEGIN@9
21114µs14µsPackage::DeprecationManager::::_build_warnPackage::DeprecationManager::_build_warn
11111µs13µsPackage::DeprecationManager::::BEGIN@3Package::DeprecationManager::BEGIN@3
1119µs72µsPackage::DeprecationManager::::BEGIN@11Package::DeprecationManager::BEGIN@11
1116µs10µsPackage::DeprecationManager::::BEGIN@4Package::DeprecationManager::BEGIN@4
1116µs35µsPackage::DeprecationManager::::BEGIN@8Package::DeprecationManager::BEGIN@8
1116µs11µsPackage::DeprecationManager::::BEGIN@12Package::DeprecationManager::BEGIN@12
2116µs6µsPackage::DeprecationManager::::_build_importPackage::DeprecationManager::_build_import
0000s0sPackage::DeprecationManager::::__ANON__[:109]Package::DeprecationManager::__ANON__[:109]
0000s0sPackage::DeprecationManager::::__ANON__[:149]Package::DeprecationManager::__ANON__[:149]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Package::DeprecationManager;
2
3230µs215µ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
use strict;
# spent 13µs making 1 call to Package::DeprecationManager::BEGIN@3 # spent 2µs making 1 call to strict::import
4232µs214µ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
use warnings;
# spent 10µs making 1 call to Package::DeprecationManager::BEGIN@4 # spent 4µs making 1 call to warnings::import
5
61300nsour $VERSION = '0.15';
7
8229µs263µ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
use Carp qw( croak );
# spent 35µs making 1 call to Package::DeprecationManager::BEGIN@8 # spent 28µs making 1 call to Exporter::import
9354µs3138µ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
use List::Util 1.33 qw( any );
# 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
102108µs1802µ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
use Package::Stash;
# spent 802µs making 1 call to Package::DeprecationManager::BEGIN@10
11222µs2135µ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
use Params::Util qw( _HASH0 );
# spent 72µs making 1 call to Package::DeprecationManager::BEGIN@11 # spent 63µs making 1 call to Exporter::import
122411µs216µ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
use Sub::Install;
# 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
sub import {
152200ns shift;
1622µs my %args = @_;
17
18 croak
19 'You must provide a hash reference -deprecations parameter when importing Package::DeprecationManager'
20211µs22µs unless $args{-deprecations} && _HASH0( $args{-deprecations} );
# spent 2µs making 2 calls to Params::Util::_HASH0, avg 1µs/call
21
222300ns my %registry;
23
2421µs my $caller = caller();
25
26214µs24µs my $orig_import = $caller->can('import');
# spent 4µs making 2 calls to UNIVERSAL::can, avg 2µs/call
27
2823µs26µ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
3026µs214µ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.
332600ns if ($orig_import) {
34 Package::Stash->new($caller)->remove_symbol('&import');
35 }
36
37 Sub::Install::install_sub(
38 {
3927µs292µ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
4524µs232µ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
5326µ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
sub _build_import {
572500ns my $registry = shift;
582500ns 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
return sub {
6142µs my $class = shift;
62
6342µs my @args;
64
65 my $api_version;
66 ## no critic (ControlStructures::ProhibitCStyleForLoops)
6745µ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
7743µs my $caller = caller();
7841µs $registry->{$caller} = $api_version
79 if defined $api_version;
80
814900ns if ($orig_import) {
82 @_ = ( $class, @args );
83 goto &{$orig_import};
84 }
85
86412µs return;
8727µ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
sub _build_warn {
912600ns my $registry = shift;
922400ns my $deprecated_at = shift;
932800ns my $ignore = shift;
94
9524µs my %ignore = map { $_ => 1 } grep { !ref } @{ $ignore || [] };
9622µs my @ignore_res = grep {ref} @{ $ignore || [] };
97
982200ns 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);
14929µs };
150}
151
15212µs1;
153
154# ABSTRACT: Manage deprecation warnings for your distribution
155
156__END__