Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/vars.pm |
Statements | Executed 188 statements in 1.46ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
10 | 10 | 9 | 1.10ms | 1.42ms | import | vars::
111 | 3 | 1 | 327µs | 327µs | CORE:match (opcode) | vars::
0 | 0 | 0 | 0s | 0s | BEGIN | vars::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package vars; | ||||
2 | |||||
3 | use 5.006; | ||||
4 | |||||
5 | our $VERSION = '1.03'; | ||||
6 | |||||
7 | use warnings::register; | ||||
8 | use strict qw(vars subs); | ||||
9 | |||||
10 | # spent 1.42ms (1.10+327µs) within vars::import which was called 10 times, avg 142µs/call:
# once (554µs+167µs) by Archive::Tar::BEGIN@24 at line 27 of Archive/Tar.pm
# once (136µs+23µs) by parent::BEGIN@3 at line 3 of parent.pm
# once (74µs+16µs) by Term::Cap::BEGIN@20 at line 20 of Term/Cap.pm
# once (68µs+21µs) by IO::Zlib::BEGIN@289 at line 289 of IO/Zlib.pm
# once (68µs+20µs) by Storable::BEGIN@23 at line 23 of Storable.pm
# once (47µs+19µs) by Term::Cap::BEGIN@19 at line 19 of Term/Cap.pm
# once (43µs+17µs) by Digest::SHA::BEGIN@7 at line 7 of Digest/SHA.pm
# once (41µs+15µs) by Tie::StdHandle::BEGIN@6 at line 6 of Tie/StdHandle.pm
# once (37µs+15µs) by Archive::Tar::File::BEGIN@14 at line 14 of Archive/Tar/File.pm
# once (29µs+14µs) by Digest::base::BEGIN@4 at line 4 of Digest/base.pm | ||||
11 | 10 | 26µs | my $callpack = caller; | ||
12 | 10 | 30µs | my (undef, @imports) = @_; | ||
13 | 10 | 8µs | my ($sym, $ch); | ||
14 | 10 | 99µs | foreach (@imports) { | ||
15 | 37 | 612µs | 37 | 224µs | if (($ch, $sym) = /^([\$\@\%\*\&])(.+)/) { # spent 224µs making 37 calls to vars::CORE:match, avg 6µs/call |
16 | 37 | 141µs | 37 | 62µs | if ($sym =~ /\W/) { # spent 62µs making 37 calls to vars::CORE:match, avg 2µs/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 | 37 | 194µs | 37 | 41µs | $sym = "${callpack}::$sym" unless $sym =~ /::/; # spent 41µs making 37 calls to vars::CORE:match, avg 1µs/call |
29 | *$sym = | ||||
30 | ( $ch eq "\$" ? \$$sym | ||||
31 | : $ch eq "\@" ? \@$sym | ||||
32 | : $ch eq "\%" ? \%$sym | ||||
33 | : $ch eq "\*" ? \*$sym | ||||
34 | : $ch eq "\&" ? \&$sym | ||||
35 | 37 | 349µ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; | ||||
47 | __END__ | ||||
sub vars::CORE:match; # opcode |