| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Sub/Identify.pm |
| Statements | Executed 17 statements in 471µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 18µs | 129µs | Sub::Identify::BEGIN@6 |
| 1 | 1 | 1 | 7µs | 8µs | Sub::Identify::BEGIN@3 |
| 1 | 1 | 1 | 4µs | 15µs | Sub::Identify::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Sub::Identify::__ANON__[:49] |
| 0 | 0 | 0 | 0s | 0s | Sub::Identify::__ANON__[:58] |
| 0 | 0 | 0 | 0s | 0s | Sub::Identify::__ANON__[:70] |
| 0 | 0 | 0 | 0s | 0s | Sub::Identify::stash_name |
| 0 | 0 | 0 | 0s | 0s | Sub::Identify::sub_fullname |
| 0 | 0 | 0 | 0s | 0s | Sub::Identify::sub_name |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Sub::Identify; | ||||
| 2 | |||||
| 3 | 2 | 13µs | 2 | 9µs | # spent 8µs (7+1) within Sub::Identify::BEGIN@3 which was called:
# once (7µs+1µs) by Devel::OverloadInfo::BEGIN@18 at line 3 # spent 8µs making 1 call to Sub::Identify::BEGIN@3
# spent 1µs making 1 call to strict::import |
| 4 | 2 | 256µs | 2 | 25µs | # spent 15µs (4+11) within Sub::Identify::BEGIN@4 which was called:
# once (4µs+11µs) by Devel::OverloadInfo::BEGIN@18 at line 4 # spent 15µs making 1 call to Sub::Identify::BEGIN@4
# spent 11µs making 1 call to Exporter::import |
| 5 | |||||
| 6 | # spent 129µs (18+111) within Sub::Identify::BEGIN@6 which was called:
# once (18µs+111µs) by Devel::OverloadInfo::BEGIN@18 at line 72 | ||||
| 7 | 1 | 200ns | our $VERSION = '0.12'; | ||
| 8 | 1 | 4µs | our @ISA = ('Exporter'); | ||
| 9 | 1 | 2µ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 | 200ns | our $IsPurePerl = 1; | ||
| 23 | 1 | 600ns | unless ($ENV{PERL_SUB_IDENTIFY_PP}) { | ||
| 24 | 1 | 500ns | if ( | ||
| 25 | eval { | ||||
| 26 | 1 | 400ns | require XSLoader; | ||
| 27 | 1 | 116µs | 1 | 111µs | XSLoader::load(__PACKAGE__, $VERSION); # spent 111µs making 1 call to XSLoader::load |
| 28 | 1 | 500ns | 1; | ||
| 29 | } | ||||
| 30 | ) { | ||||
| 31 | 1 | 200ns | $IsPurePerl = 0; | ||
| 32 | } | ||||
| 33 | else { | ||||
| 34 | die $@ if $@ && $@ !~ /object version|loadable object/; | ||||
| 35 | } | ||||
| 36 | } | ||||
| 37 | |||||
| 38 | 1 | 100ns | 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 | 3µ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 | 73µs | 1 | 129µs | } # spent 129µs making 1 call to Sub::Identify::BEGIN@6 |
| 73 | |||||
| 74 | sub stash_name ($) { (get_code_info($_[0]))[0] } | ||||
| 75 | sub sub_name ($) { (get_code_info($_[0]))[1] } | ||||
| 76 | sub sub_fullname ($) { join '::', get_code_info($_[0]) } | ||||
| 77 | |||||
| 78 | 1 | 2µs | 1; | ||
| 79 | |||||
| 80 | __END__ |