Filename | /usr/share/perl/5.20/Module/Load.pm |
Statements | Executed 24 statements in 693µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 16µs | 18µs | import | Module::Load::
1 | 1 | 1 | 12µs | 24µs | BEGIN@5 | Module::Load::
1 | 1 | 1 | 8µs | 15µs | BEGIN@6 | Module::Load::
1 | 1 | 1 | 6µs | 16µs | BEGIN@88 | Module::Load::
1 | 1 | 1 | 6µs | 14µs | BEGIN@13 | Module::Load::
1 | 1 | 1 | 3µs | 3µs | BEGIN@7 | Module::Load::
1 | 1 | 1 | 2µs | 2µs | _who | Module::Load::
0 | 0 | 0 | 0s | 0s | _is_file | Module::Load::
0 | 0 | 0 | 0s | 0s | _load | Module::Load::
0 | 0 | 0 | 0s | 0s | _to_file | Module::Load::
0 | 0 | 0 | 0s | 0s | autoload | Module::Load::
0 | 0 | 0 | 0s | 0s | autoload_remote | Module::Load::
0 | 0 | 0 | 0s | 0s | load | Module::Load::
0 | 0 | 0 | 0s | 0s | load_remote | Module::Load::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Module::Load; | ||||
2 | |||||
3 | 1 | 400ns | $VERSION = '0.32'; | ||
4 | |||||
5 | 2 | 25µs | 2 | 37µs | # spent 24µs (12+12) within Module::Load::BEGIN@5 which was called:
# once (12µs+12µs) by Module::Load::Conditional::BEGIN@5 at line 5 # spent 24µs making 1 call to Module::Load::BEGIN@5
# spent 12µs making 1 call to strict::import |
6 | 2 | 21µs | 2 | 21µs | # spent 15µs (8+7) within Module::Load::BEGIN@6 which was called:
# once (8µs+7µs) by Module::Load::Conditional::BEGIN@5 at line 6 # spent 15µs making 1 call to Module::Load::BEGIN@6
# spent 7µs making 1 call to warnings::import |
7 | 2 | 41µs | 1 | 3µs | # spent 3µs within Module::Load::BEGIN@7 which was called:
# once (3µs+0s) by Module::Load::Conditional::BEGIN@5 at line 7 # spent 3µs making 1 call to Module::Load::BEGIN@7 |
8 | |||||
9 | # spent 18µs (16+2) within Module::Load::import which was called:
# once (16µs+2µs) by Module::Load::Conditional::BEGIN@5 at line 5 of Module/Load/Conditional.pm | ||||
10 | 1 | 1µs | 1 | 2µs | my $who = _who(); # spent 2µs making 1 call to Module::Load::_who |
11 | 2 | 200ns | my $h; shift; | ||
12 | |||||
13 | 3 | 370µs | 2 | 23µs | # spent 14µs (6+9) within Module::Load::BEGIN@13 which was called:
# once (6µs+9µs) by Module::Load::Conditional::BEGIN@5 at line 13 # spent 14µs making 1 call to Module::Load::BEGIN@13
# spent 9µs making 1 call to strict::unimport |
14 | |||||
15 | @_ or ( | ||||
16 | *{"${who}::load"} = \&load, # compat to prev version | ||||
17 | 1 | 400ns | *{"${who}::autoload"} = \&autoload, | ||
18 | return | ||||
19 | ); | ||||
20 | |||||
21 | 1 | 2µs | map { $h->{$_} = () if defined $_ } @_; | ||
22 | |||||
23 | 1 | 400ns | (exists $h->{none} or exists $h->{''}) | ||
24 | and shift, last; | ||||
25 | |||||
26 | ((exists $h->{autoload} and shift,1) or (exists $h->{all} and shift)) | ||||
27 | 1 | 400ns | and *{"${who}::autoload"} = \&autoload; | ||
28 | |||||
29 | ((exists $h->{load} and shift,1) or exists $h->{all}) | ||||
30 | 1 | 3µs | and *{"${who}::load"} = \&load; | ||
31 | |||||
32 | ((exists $h->{load_remote} and shift,1) or exists $h->{all}) | ||||
33 | 1 | 300ns | and *{"${who}::load_remote"} = \&load_remote; | ||
34 | |||||
35 | ((exists $h->{autoload_remote} and shift,1) or exists $h->{all}) | ||||
36 | 1 | 2µs | and *{"${who}::autoload_remote"} = \&autoload_remote; | ||
37 | |||||
38 | } | ||||
39 | |||||
40 | } | ||||
41 | |||||
42 | sub load(*;@){ | ||||
43 | goto &_load; | ||||
44 | } | ||||
45 | |||||
46 | sub autoload(*;@){ | ||||
47 | unshift @_, 'autoimport'; | ||||
48 | goto &_load; | ||||
49 | } | ||||
50 | |||||
51 | sub load_remote($$;@){ | ||||
52 | my ($dst, $src, @exp) = @_; | ||||
53 | |||||
54 | eval "package $dst;Module::Load::load('$src', qw/@exp/);"; | ||||
55 | $@ && die "$@"; | ||||
56 | } | ||||
57 | |||||
58 | sub autoload_remote($$;@){ | ||||
59 | my ($dst, $src, @exp) = @_; | ||||
60 | |||||
61 | eval "package $dst;Module::Load::autoload('$src', qw/@exp/);"; | ||||
62 | $@ && die "$@"; | ||||
63 | } | ||||
64 | |||||
65 | sub _load{ | ||||
66 | my $autoimport = $_[0] eq 'autoimport' and shift; | ||||
67 | my $mod = shift or return; | ||||
68 | my $who = _who(); | ||||
69 | |||||
70 | if( _is_file( $mod ) ) { | ||||
71 | require $mod; | ||||
72 | } else { | ||||
73 | LOAD: { | ||||
74 | my $err; | ||||
75 | for my $flag ( qw[1 0] ) { | ||||
76 | my $file = _to_file( $mod, $flag); | ||||
77 | eval { require $file }; | ||||
78 | $@ ? $err .= $@ : last LOAD; | ||||
79 | } | ||||
80 | die $err if $err; | ||||
81 | } | ||||
82 | } | ||||
83 | |||||
84 | ### This addresses #41883: Module::Load cannot import | ||||
85 | ### non-Exporter module. ->import() routines weren't | ||||
86 | ### properly called when load() was used. | ||||
87 | |||||
88 | 2 | 216µs | 2 | 25µs | # spent 16µs (6+9) within Module::Load::BEGIN@88 which was called:
# once (6µs+9µs) by Module::Load::Conditional::BEGIN@5 at line 88 # spent 16µs making 1 call to Module::Load::BEGIN@88
# spent 9µs making 1 call to strict::unimport |
89 | my $import; | ||||
90 | |||||
91 | ((@_ or $autoimport) and ( | ||||
92 | $import = $mod->can('import') | ||||
93 | ) and ( | ||||
94 | unshift(@_, $mod), | ||||
95 | goto &$import, | ||||
96 | return | ||||
97 | ) | ||||
98 | ); | ||||
99 | } | ||||
100 | |||||
101 | } | ||||
102 | |||||
103 | sub _to_file{ | ||||
104 | local $_ = shift; | ||||
105 | my $pm = shift || ''; | ||||
106 | |||||
107 | ## trailing blanks ignored by default. [rt #69886] | ||||
108 | my @parts = split /::|'/, $_, -1; | ||||
109 | ## make sure that we can't hop out of @INC | ||||
110 | shift @parts if @parts && !$parts[0]; | ||||
111 | |||||
112 | ### because of [perl #19213], see caveats ### | ||||
113 | my $file = $^O eq 'MSWin32' | ||||
114 | ? join "/", @parts | ||||
115 | : File::Spec->catfile( @parts ); | ||||
116 | |||||
117 | $file .= '.pm' if $pm; | ||||
118 | |||||
119 | ### on perl's before 5.10 (5.9.5@31746) if you require | ||||
120 | ### a file in VMS format, it's stored in %INC in VMS | ||||
121 | ### format. Therefor, better unixify it first | ||||
122 | ### Patch in reply to John Malmbergs patch (as mentioned | ||||
123 | ### above) on p5p Tue 21 Aug 2007 04:55:07 | ||||
124 | $file = VMS::Filespec::unixify($file) if $^O eq 'VMS'; | ||||
125 | |||||
126 | return $file; | ||||
127 | } | ||||
128 | |||||
129 | 1 | 6µs | # spent 2µs within Module::Load::_who which was called:
# once (2µs+0s) by Module::Load::import at line 10 | ||
130 | |||||
131 | sub _is_file { | ||||
132 | local $_ = shift; | ||||
133 | return /^\./ ? 1 : | ||||
134 | /[^\w:']/ ? 1 : | ||||
135 | undef | ||||
136 | } | ||||
137 | |||||
- - | |||||
140 | 1 | 2µs | 1; | ||
141 | |||||
142 | __END__ |