Filename | /usr/lib/perl/5.10/File/Glob.pm |
Statements | Executed 55 statements in 1.65ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
5 | 1 | 1 | 264µs | 302µs | AUTOLOAD | File::Glob::
2 | 2 | 2 | 51µs | 366µs | GLOB_CSH | File::Glob::
5 | 1 | 1 | 20µs | 20µs | CORE:subst (opcode) | File::Glob::
1 | 1 | 1 | 18µs | 23µs | BEGIN@3 | File::Glob::
5 | 1 | 1 | 18µs | 18µs | constant (xsub) | File::Glob::
1 | 1 | 1 | 9µs | 11µs | import | File::Glob::
2 | 2 | 1 | 5µs | 5µs | CORE:match (opcode) | File::Glob::
1 | 1 | 1 | 4µs | 4µs | BEGIN@7 | File::Glob::
0 | 0 | 0 | 0s | 0s | GLOB_ERROR | File::Glob::
0 | 0 | 0 | 0s | 0s | bsd_glob | File::Glob::
0 | 0 | 0 | 0s | 0s | csh_glob | File::Glob::
0 | 0 | 0 | 0s | 0s | glob | File::Glob::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package File::Glob; | ||||
2 | |||||
3 | 3 | 63µs | 2 | 27µs | # spent 23µs (18+4) within File::Glob::BEGIN@3 which was called:
# once (18µs+4µs) by File::GlobMapper::BEGIN@10 at line 3 # spent 23µs making 1 call to File::Glob::BEGIN@3
# spent 4µs making 1 call to strict::import |
4 | 1 | 1µs | our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, | ||
5 | $AUTOLOAD, $DEFAULT_FLAGS); | ||||
6 | |||||
7 | 3 | 991µs | 1 | 4µs | # spent 4µs within File::Glob::BEGIN@7 which was called:
# once (4µs+0s) by File::GlobMapper::BEGIN@10 at line 7 # spent 4µs making 1 call to File::Glob::BEGIN@7 |
8 | |||||
9 | 1 | 10µs | @ISA = qw(Exporter); | ||
10 | |||||
11 | # NOTE: The glob() export is only here for compatibility with 5.6.0. | ||||
12 | # csh_glob() should not be used directly, unless you know what you're doing. | ||||
13 | |||||
14 | 1 | 3µs | @EXPORT_OK = qw( | ||
15 | csh_glob | ||||
16 | bsd_glob | ||||
17 | glob | ||||
18 | GLOB_ABEND | ||||
19 | GLOB_ALPHASORT | ||||
20 | GLOB_ALTDIRFUNC | ||||
21 | GLOB_BRACE | ||||
22 | GLOB_CSH | ||||
23 | GLOB_ERR | ||||
24 | GLOB_ERROR | ||||
25 | GLOB_LIMIT | ||||
26 | GLOB_MARK | ||||
27 | GLOB_NOCASE | ||||
28 | GLOB_NOCHECK | ||||
29 | GLOB_NOMAGIC | ||||
30 | GLOB_NOSORT | ||||
31 | GLOB_NOSPACE | ||||
32 | GLOB_QUOTE | ||||
33 | GLOB_TILDE | ||||
34 | ); | ||||
35 | |||||
36 | 1 | 9µs | %EXPORT_TAGS = ( | ||
37 | 'glob' => [ qw( | ||||
38 | GLOB_ABEND | ||||
39 | GLOB_ALPHASORT | ||||
40 | GLOB_ALTDIRFUNC | ||||
41 | GLOB_BRACE | ||||
42 | GLOB_CSH | ||||
43 | GLOB_ERR | ||||
44 | GLOB_ERROR | ||||
45 | GLOB_LIMIT | ||||
46 | GLOB_MARK | ||||
47 | GLOB_NOCASE | ||||
48 | GLOB_NOCHECK | ||||
49 | GLOB_NOMAGIC | ||||
50 | GLOB_NOSORT | ||||
51 | GLOB_NOSPACE | ||||
52 | GLOB_QUOTE | ||||
53 | GLOB_TILDE | ||||
54 | glob | ||||
55 | bsd_glob | ||||
56 | ) ], | ||||
57 | ); | ||||
58 | |||||
59 | 1 | 400ns | $VERSION = '1.06'; | ||
60 | |||||
61 | # spent 11µs (9+2) within File::Glob::import which was called:
# once (9µs+2µs) by File::GlobMapper::BEGIN@10 at line 19 of File/GlobMapper.pm | ||||
62 | 1 | 800ns | require Exporter; | ||
63 | 1 | 400ns | my $i = 1; | ||
64 | 1 | 1µs | while ($i < @_) { | ||
65 | 1 | 5µs | 1 | 2µs | if ($_[$i] =~ /^:(case|nocase|globally)$/) { # spent 2µs making 1 call to File::Glob::CORE:match |
66 | splice(@_, $i, 1); | ||||
67 | $DEFAULT_FLAGS &= ~GLOB_NOCASE() if $1 eq 'case'; | ||||
68 | $DEFAULT_FLAGS |= GLOB_NOCASE() if $1 eq 'nocase'; | ||||
69 | if ($1 eq 'globally') { | ||||
70 | local $^W; | ||||
71 | *CORE::GLOBAL::glob = \&File::Glob::csh_glob; | ||||
72 | } | ||||
73 | next; | ||||
74 | } | ||||
75 | 1 | 1µs | ++$i; | ||
76 | } | ||||
77 | 1 | 6µs | 1 | 405µs | goto &Exporter::import; # spent 405µs making 1 call to Exporter::import |
78 | } | ||||
79 | |||||
80 | # spent 302µs (264+38) within File::Glob::AUTOLOAD which was called 5 times, avg 60µs/call:
# 5 times (264µs+38µs) by File::Glob::GLOB_CSH at line 105, avg 60µs/call | ||||
81 | # This AUTOLOAD is used to 'autoload' constants from the constant() | ||||
82 | # XS function. If a constant is not found then control is passed | ||||
83 | # to the AUTOLOAD in AutoLoader. | ||||
84 | |||||
85 | 5 | 2µs | my $constname; | ||
86 | 5 | 50µs | 5 | 20µs | ($constname = $AUTOLOAD) =~ s/.*:://; # spent 20µs making 5 calls to File::Glob::CORE:subst, avg 4µs/call |
87 | 5 | 40µs | 5 | 18µs | my ($error, $val) = constant($constname); # spent 18µs making 5 calls to File::Glob::constant, avg 4µs/call |
88 | 5 | 2µs | if ($error) { | ||
89 | require Carp; | ||||
90 | Carp::croak($error); | ||||
91 | } | ||||
92 | 5 | 183µs | eval "sub $AUTOLOAD { $val }"; # spent 6µs executing statements in string eval # includes 2µs spent executing 2 calls to 1 sub defined therein. # spent 6µs executing statements in string eval # includes 3µs spent executing 2 calls to 1 sub defined therein. # spent 6µs executing statements in string eval # includes 3µs spent executing 2 calls to 1 sub defined therein. # spent 5µs executing statements in string eval # includes 3µs spent executing 2 calls to 1 sub defined therein. # spent 5µs executing statements in string eval # includes 2µs spent executing 2 calls to 1 sub defined therein. | ||
93 | 5 | 36µs | 5 | 8µs | goto &$AUTOLOAD; # spent 2µs making 1 call to File::Glob::GLOB_BRACE
# spent 2µs making 1 call to File::Glob::GLOB_NOMAGIC
# spent 2µs making 1 call to File::Glob::GLOB_TILDE
# spent 2µs making 1 call to File::Glob::GLOB_QUOTE
# spent 2µs making 1 call to File::Glob::GLOB_ALPHASORT |
94 | } | ||||
95 | |||||
96 | 1 | 195µs | 1 | 187µs | XSLoader::load 'File::Glob', $VERSION; # spent 187µs making 1 call to XSLoader::load |
97 | |||||
98 | # Preloaded methods go here. | ||||
99 | |||||
100 | sub GLOB_ERROR { | ||||
101 | return (constant('GLOB_ERROR'))[1]; | ||||
102 | } | ||||
103 | |||||
104 | # spent 366µs (51+315) within File::Glob::GLOB_CSH which was called 2 times, avg 183µs/call:
# once (38µs+310µs) by File::GlobMapper::BEGIN@10 at line 112
# once (13µs+5µs) by File::GlobMapper::BEGIN@10 at line 20 of File/GlobMapper.pm | ||||
105 | 2 | 27µs | 10 | 307µs | GLOB_BRACE() # spent 302µs making 5 calls to File::Glob::AUTOLOAD, avg 60µs/call
# spent 1µs making 1 call to File::Glob::GLOB_BRACE
# spent 1µs making 1 call to File::Glob::GLOB_NOMAGIC
# spent 1µs making 1 call to File::Glob::GLOB_TILDE
# spent 900ns making 1 call to File::Glob::GLOB_ALPHASORT
# spent 900ns making 1 call to File::Glob::GLOB_QUOTE |
106 | | GLOB_NOMAGIC() | ||||
107 | | GLOB_QUOTE() | ||||
108 | | GLOB_TILDE() | ||||
109 | | GLOB_ALPHASORT() | ||||
110 | } | ||||
111 | |||||
112 | 1 | 3µs | 1 | 348µs | $DEFAULT_FLAGS = GLOB_CSH(); # spent 348µs making 1 call to File::Glob::GLOB_CSH |
113 | 1 | 8µs | 1 | 4µs | if ($^O =~ /^(?:MSWin32|VMS|os2|dos|riscos|MacOS)$/) { # spent 4µs making 1 call to File::Glob::CORE:match |
114 | $DEFAULT_FLAGS |= GLOB_NOCASE(); | ||||
115 | } | ||||
116 | |||||
117 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||
118 | |||||
119 | sub bsd_glob { | ||||
120 | my ($pat,$flags) = @_; | ||||
121 | $flags = $DEFAULT_FLAGS if @_ < 2; | ||||
122 | return doglob($pat,$flags); | ||||
123 | } | ||||
124 | |||||
125 | # File::Glob::glob() is deprecated because its prototype is different from | ||||
126 | # CORE::glob() (use bsd_glob() instead) | ||||
127 | sub glob { | ||||
128 | splice @_, 1; # don't pass PL_glob_index as flags! | ||||
129 | goto &bsd_glob; | ||||
130 | } | ||||
131 | |||||
132 | ## borrowed heavily from gsar's File::DosGlob | ||||
133 | 1 | 400ns | my %iter; | ||
134 | 1 | 200ns | my %entries; | ||
135 | |||||
136 | sub csh_glob { | ||||
137 | my $pat = shift; | ||||
138 | my $cxix = shift; | ||||
139 | my @pat; | ||||
140 | |||||
141 | # glob without args defaults to $_ | ||||
142 | $pat = $_ unless defined $pat; | ||||
143 | |||||
144 | # extract patterns | ||||
145 | $pat =~ s/^\s+//; # Protect against empty elements in | ||||
146 | $pat =~ s/\s+$//; # things like < *.c> and <*.c >. | ||||
147 | # These alone shouldn't trigger ParseWords. | ||||
148 | if ($pat =~ /\s/) { | ||||
149 | # XXX this is needed for compatibility with the csh | ||||
150 | # implementation in Perl. Need to support a flag | ||||
151 | # to disable this behavior. | ||||
152 | require Text::ParseWords; | ||||
153 | @pat = Text::ParseWords::parse_line('\s+',0,$pat); | ||||
154 | } | ||||
155 | |||||
156 | # assume global context if not provided one | ||||
157 | $cxix = '_G_' unless defined $cxix; | ||||
158 | $iter{$cxix} = 0 unless exists $iter{$cxix}; | ||||
159 | |||||
160 | # if we're just beginning, do it all first | ||||
161 | if ($iter{$cxix} == 0) { | ||||
162 | if (@pat) { | ||||
163 | $entries{$cxix} = [ map { doglob($_, $DEFAULT_FLAGS) } @pat ]; | ||||
164 | } | ||||
165 | else { | ||||
166 | $entries{$cxix} = [ doglob($pat, $DEFAULT_FLAGS) ]; | ||||
167 | } | ||||
168 | } | ||||
169 | |||||
170 | # chuck it all out, quick or slow | ||||
171 | if (wantarray) { | ||||
172 | delete $iter{$cxix}; | ||||
173 | return @{delete $entries{$cxix}}; | ||||
174 | } | ||||
175 | else { | ||||
176 | if ($iter{$cxix} = scalar @{$entries{$cxix}}) { | ||||
177 | return shift @{$entries{$cxix}}; | ||||
178 | } | ||||
179 | else { | ||||
180 | # return undef for EOL | ||||
181 | delete $iter{$cxix}; | ||||
182 | delete $entries{$cxix}; | ||||
183 | return undef; | ||||
184 | } | ||||
185 | } | ||||
186 | } | ||||
187 | |||||
188 | 1 | 13µs | 1; | ||
189 | __END__ | ||||
sub File::Glob::CORE:match; # opcode | |||||
# spent 20µs within File::Glob::CORE:subst which was called 5 times, avg 4µs/call:
# 5 times (20µs+0s) by File::Glob::AUTOLOAD at line 86, avg 4µs/call | |||||
# spent 18µs within File::Glob::constant which was called 5 times, avg 4µs/call:
# 5 times (18µs+0s) by File::Glob::AUTOLOAD at line 87, avg 4µs/call |