Filename | /usr/local/lib/perl/5.18.2/Sub/Identify.pm |
Statements | Executed 33 statements in 1.17ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
16 | 1 | 1 | 55µs | 75µs | stash_name | Sub::Identify::
1 | 1 | 1 | 33µs | 239µs | BEGIN@6 | Sub::Identify::
16 | 1 | 1 | 20µs | 20µs | get_code_info (xsub) | Sub::Identify::
1 | 1 | 1 | 15µs | 33µs | BEGIN@3 | Sub::Identify::
1 | 1 | 1 | 12µs | 36µs | BEGIN@4 | Sub::Identify::
0 | 0 | 0 | 0s | 0s | __ANON__[:49] | Sub::Identify::
0 | 0 | 0 | 0s | 0s | __ANON__[:58] | Sub::Identify::
0 | 0 | 0 | 0s | 0s | __ANON__[:70] | Sub::Identify::
0 | 0 | 0 | 0s | 0s | sub_fullname | Sub::Identify::
0 | 0 | 0 | 0s | 0s | sub_name | Sub::Identify::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Sub::Identify; | ||||
2 | |||||
3 | 2 | 40µs | 2 | 50µs | # spent 33µs (15+18) within Sub::Identify::BEGIN@3 which was called:
# once (15µs+18µs) by namespace::autoclean::_method_check at line 3 # spent 33µs making 1 call to Sub::Identify::BEGIN@3
# spent 18µs making 1 call to strict::import |
4 | 2 | 630µs | 2 | 60µs | # spent 36µs (12+24) within Sub::Identify::BEGIN@4 which was called:
# once (12µs+24µs) by namespace::autoclean::_method_check at line 4 # spent 36µs making 1 call to Sub::Identify::BEGIN@4
# spent 24µs making 1 call to Exporter::import |
5 | |||||
6 | # spent 239µs (33+207) within Sub::Identify::BEGIN@6 which was called:
# once (33µs+207µs) by namespace::autoclean::_method_check at line 72 | ||||
7 | 1 | 800ns | our $VERSION = '0.12'; | ||
8 | 1 | 7µs | our @ISA = ('Exporter'); | ||
9 | 1 | 4µs | our %EXPORT_TAGS = ( | ||
10 | all => [ | ||||
11 | our @EXPORT_OK = qw( | ||||
12 | sub_name | ||||
13 | stash_name | ||||
14 | sub_fullname | ||||
15 | get_code_info | ||||
16 | get_code_location | ||||
17 | is_sub_constant | ||||
18 | ) | ||||
19 | ] | ||||
20 | ); | ||||
21 | |||||
22 | 1 | 300ns | our $IsPurePerl = 1; | ||
23 | 1 | 900ns | unless ($ENV{PERL_SUB_IDENTIFY_PP}) { | ||
24 | 1 | 1µs | if ( | ||
25 | eval { | ||||
26 | 1 | 600ns | require XSLoader; | ||
27 | 1 | 216µs | 1 | 207µs | XSLoader::load(__PACKAGE__, $VERSION); # spent 207µs making 1 call to XSLoader::load |
28 | 1 | 900ns | 1; | ||
29 | } | ||||
30 | ) { | ||||
31 | 1 | 500ns | $IsPurePerl = 0; | ||
32 | } | ||||
33 | else { | ||||
34 | die $@ if $@ && $@ !~ /object version|loadable object/; | ||||
35 | } | ||||
36 | } | ||||
37 | |||||
38 | 1 | 300ns | if ($IsPurePerl) { | ||
39 | require B; | ||||
40 | *get_code_info = sub ($) { | ||||
41 | my ($coderef) = @_; | ||||
42 | ref $coderef or return; | ||||
43 | my $cv = B::svref_2object($coderef); | ||||
44 | $cv->isa('B::CV') or return; | ||||
45 | # bail out if GV is undefined | ||||
46 | $cv->GV->isa('B::SPECIAL') and return; | ||||
47 | |||||
48 | return ($cv->GV->STASH->NAME, $cv->GV->NAME); | ||||
49 | }; | ||||
50 | *get_code_location = sub ($) { | ||||
51 | my ($coderef) = @_; | ||||
52 | ref $coderef or return; | ||||
53 | my $cv = B::svref_2object($coderef); | ||||
54 | $cv->isa('B::CV') && $cv->START->isa('B::COP') | ||||
55 | or return; | ||||
56 | |||||
57 | return ($cv->START->file, $cv->START->line); | ||||
58 | }; | ||||
59 | } | ||||
60 | 1 | 5µs | if ($IsPurePerl || $] < 5.016) { | ||
61 | require B; | ||||
62 | *is_sub_constant = sub ($) { | ||||
63 | my ($coderef) = @_; | ||||
64 | ref $coderef or return 0; | ||||
65 | my $cv = B::svref_2object($coderef); | ||||
66 | $cv->isa('B::CV') or return 0; | ||||
67 | my $p = prototype $coderef; | ||||
68 | defined $p && $p eq "" or return 0; | ||||
69 | return ($cv->CvFLAGS & B::CVf_CONST()) == B::CVf_CONST(); | ||||
70 | }; | ||||
71 | } | ||||
72 | 1 | 163µs | 1 | 239µs | } # spent 239µs making 1 call to Sub::Identify::BEGIN@6 |
73 | |||||
74 | 16 | 93µs | 16 | 20µs | # spent 75µs (55+20) within Sub::Identify::stash_name which was called 16 times, avg 5µs/call:
# 16 times (55µs+20µs) by namespace::autoclean::__ANON__[/usr/local/share/perl/5.18.2/namespace/autoclean.pm:210] at line 204 of namespace/autoclean.pm, avg 5µs/call # spent 20µs making 16 calls to Sub::Identify::get_code_info, avg 1µs/call |
75 | sub sub_name ($) { (get_code_info($_[0]))[1] } | ||||
76 | sub sub_fullname ($) { join '::', get_code_info($_[0]) } | ||||
77 | |||||
78 | 1 | 3µs | 1; | ||
79 | |||||
80 | __END__ | ||||
# spent 20µs within Sub::Identify::get_code_info which was called 16 times, avg 1µs/call:
# 16 times (20µs+0s) by Sub::Identify::stash_name at line 74, avg 1µs/call |