| Filename | /usr/share/perl/5.28/Symbol.pm |
| Statements | Executed 109642 statements in 384ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 9136 | 2 | 1 | 142ms | 178ms | Symbol::qualify_to_ref |
| 13704 | 2 | 2 | 100ms | 121ms | Symbol::qualify |
| 9136 | 2 | 1 | 74.8ms | 74.8ms | Symbol::gensym |
| 4568 | 1 | 1 | 16.5ms | 16.5ms | Symbol::CORE:match (opcode) |
| 4568 | 1 | 1 | 4.00ms | 4.00ms | Symbol::CORE:subst (opcode) |
| 1 | 1 | 1 | 11µs | 11µs | Symbol::BEGIN@3 |
| 0 | 0 | 0 | 0s | 0s | Symbol::delete_package |
| 0 | 0 | 0 | 0s | 0s | Symbol::geniosym |
| 0 | 0 | 0 | 0s | 0s | Symbol::ungensym |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Symbol; | ||||
| 2 | |||||
| 3 | 1 | 520µs | 1 | 11µs | # spent 11µs within Symbol::BEGIN@3 which was called:
# once (11µs+0s) by IO::Handle::BEGIN@6 at line 3 # spent 11µs making 1 call to Symbol::BEGIN@3 |
| 4 | |||||
| 5 | 1 | 600ns | require Exporter; | ||
| 6 | 1 | 6µs | @ISA = qw(Exporter); | ||
| 7 | 1 | 700ns | @EXPORT = qw(gensym ungensym qualify qualify_to_ref); | ||
| 8 | 1 | 300ns | @EXPORT_OK = qw(delete_package geniosym); | ||
| 9 | |||||
| 10 | 1 | 200ns | $VERSION = '1.08'; | ||
| 11 | |||||
| 12 | 1 | 200ns | my $genpkg = "Symbol::"; | ||
| 13 | 1 | 200ns | my $genseq = 0; | ||
| 14 | |||||
| 15 | 1 | 7µs | my %global = map {$_ => 1} qw(ARGV ARGVOUT ENV INC SIG STDERR STDIN STDOUT); | ||
| 16 | |||||
| 17 | # | ||||
| 18 | # Note that we never _copy_ the glob; we just make a ref to it. | ||||
| 19 | # If we did copy it, then SVf_FAKE would be set on the copy, and | ||||
| 20 | # glob-specific behaviors (e.g. C<*$ref = \&func>) wouldn't work. | ||||
| 21 | # | ||||
| 22 | # spent 74.8ms within Symbol::gensym which was called 9136 times, avg 8µs/call:
# 4568 times (50.2ms+0s) by IO::CaptureOutput::_proxy::new at line 156 of IO/CaptureOutput.pm, avg 11µs/call
# 4568 times (24.6ms+0s) by IO::CaptureOutput::_proxy::new at line 164 of IO/CaptureOutput.pm, avg 5µs/call | ||||
| 23 | 9136 | 6.05ms | my $name = "GEN" . $genseq++; | ||
| 24 | 9136 | 50.7ms | my $ref = \*{$genpkg . $name}; | ||
| 25 | 9136 | 7.07ms | delete $$genpkg{$name}; | ||
| 26 | 9136 | 29.2ms | $ref; | ||
| 27 | } | ||||
| 28 | |||||
| 29 | sub geniosym () { | ||||
| 30 | my $sym = gensym(); | ||||
| 31 | # force the IO slot to be filled | ||||
| 32 | select(select $sym); | ||||
| 33 | *$sym{IO}; | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | sub ungensym ($) {} | ||||
| 37 | |||||
| 38 | # spent 121ms (100+20.5) within Symbol::qualify which was called 13704 times, avg 9µs/call:
# 9136 times (36.3ms+0s) by Symbol::qualify_to_ref at line 57, avg 4µs/call
# 4568 times (63.8ms+20.5ms) by IO::CaptureOutput::_proxy::new at line 148 of IO/CaptureOutput.pm, avg 18µs/call | ||||
| 39 | 13704 | 8.64ms | my ($name) = @_; | ||
| 40 | 13704 | 21.5ms | if (!ref($name) && index($name, '::') == -1 && index($name, "'") == -1) { | ||
| 41 | 4568 | 609µs | my $pkg; | ||
| 42 | # Global names: special character, "^xyz", or other. | ||||
| 43 | 4568 | 36.9ms | 4568 | 16.5ms | if ($name =~ /^(([^a-z])|(\^[a-z_]+))\z/i || $global{$name}) { # spent 16.5ms making 4568 calls to Symbol::CORE:match, avg 4µs/call |
| 44 | # RGS 2001-11-05 : translate leading ^X to control-char | ||||
| 45 | 4568 | 17.2ms | 4568 | 4.00ms | $name =~ s/^\^([a-z_])/'qq(\c'.$1.')'/eei; # spent 4.00ms making 4568 calls to Symbol::CORE:subst, avg 877ns/call |
| 46 | 4568 | 2.53ms | $pkg = "main"; | ||
| 47 | } | ||||
| 48 | else { | ||||
| 49 | $pkg = (@_ > 1) ? $_[1] : caller; | ||||
| 50 | } | ||||
| 51 | 4568 | 3.26ms | $name = $pkg . "::" . $name; | ||
| 52 | } | ||||
| 53 | 13704 | 62.3ms | $name; | ||
| 54 | } | ||||
| 55 | |||||
| 56 | # spent 178ms (142+36.3) within Symbol::qualify_to_ref which was called 9136 times, avg 20µs/call:
# 4568 times (93.5ms+29.5ms) by IO::CaptureOutput::_proxy::DESTROY at line 193 of IO/CaptureOutput.pm, avg 27µs/call
# 4568 times (48.5ms+6.78ms) by IO::CaptureOutput::_proxy::new at line 149 of IO/CaptureOutput.pm, avg 12µs/call | ||||
| 57 | 9136 | 137ms | 9136 | 36.3ms | return \*{ qualify $_[0], @_ > 1 ? $_[1] : caller }; # spent 36.3ms making 9136 calls to Symbol::qualify, avg 4µs/call |
| 58 | } | ||||
| 59 | |||||
| 60 | # | ||||
| 61 | # of Safe.pm lineage | ||||
| 62 | # | ||||
| 63 | sub delete_package ($) { | ||||
| 64 | my $pkg = shift; | ||||
| 65 | |||||
| 66 | # expand to full symbol table name if needed | ||||
| 67 | |||||
| 68 | unless ($pkg =~ /^main::.*::$/) { | ||||
| 69 | $pkg = "main$pkg" if $pkg =~ /^::/; | ||||
| 70 | $pkg = "main::$pkg" unless $pkg =~ /^main::/; | ||||
| 71 | $pkg .= '::' unless $pkg =~ /::$/; | ||||
| 72 | } | ||||
| 73 | |||||
| 74 | my($stem, $leaf) = $pkg =~ m/(.*::)(\w+::)$/; | ||||
| 75 | my $stem_symtab = *{$stem}{HASH}; | ||||
| 76 | return unless defined $stem_symtab and exists $stem_symtab->{$leaf}; | ||||
| 77 | |||||
| 78 | # free all the symbols in the package | ||||
| 79 | |||||
| 80 | my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; | ||||
| 81 | foreach my $name (keys %$leaf_symtab) { | ||||
| 82 | undef *{$pkg . $name}; | ||||
| 83 | } | ||||
| 84 | |||||
| 85 | # delete the symbol table | ||||
| 86 | |||||
| 87 | %$leaf_symtab = (); | ||||
| 88 | delete $stem_symtab->{$leaf}; | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | 1 | 7µs | 1; | ||
# spent 16.5ms within Symbol::CORE:match which was called 4568 times, avg 4µs/call:
# 4568 times (16.5ms+0s) by Symbol::qualify at line 43, avg 4µs/call | |||||
# spent 4.00ms within Symbol::CORE:subst which was called 4568 times, avg 877ns/call:
# 4568 times (4.00ms+0s) by Symbol::qualify at line 45, avg 877ns/call |