| Filename | /usr/share/perl/5.10/vars.pm |
| Statements | Executed 239 statements in 1.68ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 14 | 14 | 14 | 679µs | 853µs | vars::import |
| 1 | 1 | 1 | 327µs | 396µs | vars::BEGIN@7 |
| 129 | 3 | 1 | 174µs | 174µs | vars::CORE:match (opcode) |
| 1 | 1 | 1 | 30µs | 30µs | vars::BEGIN@3 |
| 1 | 1 | 1 | 8µs | 22µs | vars::BEGIN@8 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package vars; | ||||
| 2 | |||||
| 3 | 3 | 63µs | 1 | 30µs | # spent 30µs within vars::BEGIN@3 which was called:
# once (30µs+0s) by Scalar::Util::BEGIN@10 at line 3 # spent 30µs making 1 call to vars::BEGIN@3 |
| 4 | |||||
| 5 | 1 | 700ns | our $VERSION = '1.01'; | ||
| 6 | |||||
| 7 | 3 | 350µs | 2 | 466µs | # spent 396µs (327+70) within vars::BEGIN@7 which was called:
# once (327µs+70µs) by Scalar::Util::BEGIN@10 at line 7 # spent 396µs making 1 call to vars::BEGIN@7
# spent 70µs making 1 call to warnings::register::import |
| 8 | 3 | 374µs | 2 | 35µs | # spent 22µs (8+13) within vars::BEGIN@8 which was called:
# once (8µs+13µs) by Scalar::Util::BEGIN@10 at line 8 # spent 22µs making 1 call to vars::BEGIN@8
# spent 13µs making 1 call to strict::import |
| 9 | |||||
| 10 | # spent 853µs (679+174) within vars::import which was called 14 times, avg 61µs/call:
# once (105µs+28µs) by Params::Validate::BEGIN@7 at line 7 of Params/Validate.pm
# once (78µs+23µs) by DateTime::TimeZone::Catalog::BEGIN@15 at line 15 of DateTime/TimeZone/Catalog.pm
# once (74µs+19µs) by List::Util::BEGIN@12 at line 12 of List/Util.pm
# once (69µs+17µs) by Scalar::Util::BEGIN@10 at line 10 of Scalar/Util.pm
# once (67µs+15µs) by List::MoreUtils::BEGIN@8 at line 8 of List/MoreUtils.pm
# once (58µs+15µs) by Time::Local::BEGIN@9 at line 9 of Time/Local.pm
# once (47µs+12µs) by Digest::MD5::BEGIN@4 at line 4 of Digest/MD5.pm
# once (35µs+8µs) by Tie::IxHash::BEGIN@15 at line 15 of Tie/IxHash.pm
# once (35µs+9µs) by File::Spec::BEGIN@4 at line 4 of File/Spec.pm
# once (31µs+8µs) by constant::BEGIN@6 at line 6 of constant.pm
# once (20µs+6µs) by base::BEGIN@4 at line 4 of base.pm
# once (20µs+5µs) by parent::BEGIN@3 at line 3 of parent.pm
# once (20µs+5µs) by File::Spec::Unix::BEGIN@4 at line 4 of File/Spec/Unix.pm
# once (19µs+5µs) by Digest::base::BEGIN@4 at line 4 of Digest/base.pm | ||||
| 11 | 14 | 12µs | my $callpack = caller; | ||
| 12 | 14 | 27µs | my ($pack, @imports) = @_; | ||
| 13 | 14 | 4µs | my ($sym, $ch); | ||
| 14 | 14 | 77µs | foreach (@imports) { | ||
| 15 | 43 | 326µs | 43 | 117µs | if (($ch, $sym) = /^([\$\@\%\*\&])(.+)/) { # spent 117µs making 43 calls to vars::CORE:match, avg 3µs/call |
| 16 | 43 | 103µs | 43 | 32µs | if ($sym =~ /\W/) { # spent 32µs making 43 calls to vars::CORE:match, avg 740ns/call |
| 17 | # time for a more-detailed check-up | ||||
| 18 | if ($sym =~ /^\w+[[{].*[]}]$/) { | ||||
| 19 | require Carp; | ||||
| 20 | Carp::croak("Can't declare individual elements of hash or array"); | ||||
| 21 | } elsif (warnings::enabled() and length($sym) == 1 and $sym !~ tr/a-zA-Z//) { | ||||
| 22 | warnings::warn("No need to declare built-in vars"); | ||||
| 23 | } elsif (($^H &= strict::bits('vars'))) { | ||||
| 24 | require Carp; | ||||
| 25 | Carp::croak("'$_' is not a valid variable name under strict vars"); | ||||
| 26 | } | ||||
| 27 | } | ||||
| 28 | 43 | 114µs | 43 | 26µs | $sym = "${callpack}::$sym" unless $sym =~ /::/; # spent 26µs making 43 calls to vars::CORE:match, avg 598ns/call |
| 29 | *$sym = | ||||
| 30 | ( $ch eq "\$" ? \$$sym | ||||
| 31 | : $ch eq "\@" ? \@$sym | ||||
| 32 | : $ch eq "\%" ? \%$sym | ||||
| 33 | : $ch eq "\*" ? \*$sym | ||||
| 34 | : $ch eq "\&" ? \&$sym | ||||
| 35 | 43 | 224µs | : do { | ||
| 36 | require Carp; | ||||
| 37 | Carp::croak("'$_' is not a valid variable name"); | ||||
| 38 | }); | ||||
| 39 | } else { | ||||
| 40 | require Carp; | ||||
| 41 | Carp::croak("'$_' is not a valid variable name"); | ||||
| 42 | } | ||||
| 43 | } | ||||
| 44 | }; | ||||
| 45 | |||||
| 46 | 1 | 4µs | 1; | ||
| 47 | __END__ | ||||
sub vars::CORE:match; # opcode |