← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:10:03 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Package/DeprecationManager.pm
StatementsExecuted 88 statements in 3.25ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
222286µs1.41msPackage::DeprecationManager::::importPackage::DeprecationManager::import
666217µs217µsPackage::DeprecationManager::::__ANON__[:61]Package::DeprecationManager::__ANON__[:61]
21195µs95µsPackage::DeprecationManager::::_build_warnPackage::DeprecationManager::_build_warn
11146µs555µsPackage::DeprecationManager::::BEGIN@11Package::DeprecationManager::BEGIN@11
11145µs45µsPackage::DeprecationManager::::BEGIN@2Package::DeprecationManager::BEGIN@2
21141µs41µsPackage::DeprecationManager::::_build_importPackage::DeprecationManager::_build_import
11140µs175µsPackage::DeprecationManager::::BEGIN@10Package::DeprecationManager::BEGIN@10
11139µs60µsPackage::DeprecationManager::::BEGIN@12Package::DeprecationManager::BEGIN@12
11139µs56µsPackage::DeprecationManager::::BEGIN@6Package::DeprecationManager::BEGIN@6
11139µs200µsPackage::DeprecationManager::::BEGIN@9Package::DeprecationManager::BEGIN@9
11137µs102µsPackage::DeprecationManager::::BEGIN@7Package::DeprecationManager::BEGIN@7
0000s0sPackage::DeprecationManager::::__ANON__[:123]Package::DeprecationManager::__ANON__[:123]
0000s0sPackage::DeprecationManager::::__ANON__[:83]Package::DeprecationManager::__ANON__[:83]
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
# spent 45µs within Package::DeprecationManager::BEGIN@2 which was called: # once (45µs+0s) by Class::MOP::Deprecated::BEGIN@10 at line 4
BEGIN {
3127µs $Package::DeprecationManager::VERSION = '0.10';
4183µs145µs}
# spent 45µs making 1 call to Package::DeprecationManager::BEGIN@2
5
6392µs273µ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
use strict;
# spent 56µs making 1 call to Package::DeprecationManager::BEGIN@6 # spent 17µs making 1 call to strict::import
73120µs2168µ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
use warnings;
# spent 102µs making 1 call to Package::DeprecationManager::BEGIN@7 # spent 66µs making 1 call to warnings::import
8
93125µs2362µ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
use Carp qw( croak );
# spent 200µs making 1 call to Package::DeprecationManager::BEGIN@9 # spent 161µs making 1 call to Exporter::import
103104µs2310µ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
use List::MoreUtils qw( any );
# spent 175µs making 1 call to Package::DeprecationManager::BEGIN@10 # spent 135µs making 1 call to Exporter::import
113110µs21.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
use Params::Util qw( _HASH );
# spent 555µs making 1 call to Package::DeprecationManager::BEGIN@11 # spent 509µs making 1 call to Exporter::import
1231.87ms282µ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
use Sub::Install;
# 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
sub import {
1520270µs shift;
16 my %args = @_;
17
18213µ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
24241µs my $import = _build_import( \%registry );
# spent 41µs making 2 calls to Package::DeprecationManager::_build_import, avg 21µs/call
25295µ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
292482µ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
372495µ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
sub _build_import {
49451µ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
return sub {
5230278µ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
sub _build_warn {
6514106µ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
126111µs1;
127
128# ABSTRACT: Manage deprecation warnings for your distribution
129
- -
132=pod
133
- -
275__END__