← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:37 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Module/Find.pm
StatementsExecuted 427 statements in 1.95ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1114.32ms4.53msModule::Find::::BEGIN@8Module::Find::BEGIN@8
4521546µs9.75msModule::Find::::_wantedModule::Find::_wanted
411278µs12.3msModule::Find::::_findModule::Find::_find
6521215µs215µsModule::Find::::CORE:ftdirModule::Find::CORE:ftdir (opcode)
4111103µs103µsModule::Find::::CORE:ftereadModule::Find::CORE:fteread (opcode)
11135µs35µsModule::Find::::BEGIN@3Module::Find::BEGIN@3
411130µs30µsModule::Find::::CORE:substModule::Find::CORE:subst (opcode)
411121µs21µsModule::Find::::CORE:matchModule::Find::CORE:match (opcode)
41119µs12.3msModule::Find::::findallmodModule::Find::findallmod
11110µs15µsModule::Find::::BEGIN@4Module::Find::BEGIN@4
1119µs26µsModule::Find::::BEGIN@5Module::Find::BEGIN@5
1116µs6µsModule::Find::::BEGIN@7Module::Find::BEGIN@7
0000s0sModule::Find::::findsubmodModule::Find::findsubmod
0000s0sModule::Find::::followsymlinksModule::Find::followsymlinks
0000s0sModule::Find::::ignoresymlinksModule::Find::ignoresymlinks
0000s0sModule::Find::::setmoduledirsModule::Find::setmoduledirs
0000s0sModule::Find::::useallModule::Find::useall
0000s0sModule::Find::::usesubModule::Find::usesub
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Module::Find;
2
3345µs135µs
# spent 35µs within Module::Find::BEGIN@3 which was called: # once (35µs+0s) by DBIx::Class::Schema::_findallmod at line 3
use 5.006001;
# spent 35µs making 1 call to Module::Find::BEGIN@3
4319µs220µs
# spent 15µs (10+5) within Module::Find::BEGIN@4 which was called: # once (10µs+5µs) by DBIx::Class::Schema::_findallmod at line 4
use strict;
# spent 15µs making 1 call to Module::Find::BEGIN@4 # spent 5µs making 1 call to strict::import
5319µs244µs
# spent 26µs (9+17) within Module::Find::BEGIN@5 which was called: # once (9µs+17µs) by DBIx::Class::Schema::_findallmod at line 5
use warnings;
# spent 26µs making 1 call to Module::Find::BEGIN@5 # spent 17µs making 1 call to warnings::import
6
7318µs16µs
# spent 6µs within Module::Find::BEGIN@7 which was called: # once (6µs+0s) by DBIx::Class::Schema::_findallmod at line 7
use File::Spec;
# spent 6µs making 1 call to Module::Find::BEGIN@7
83686µs24.57ms
# spent 4.53ms (4.32+202µs) within Module::Find::BEGIN@8 which was called: # once (4.32ms+202µs) by DBIx::Class::Schema::_findallmod at line 8
use File::Find;
# spent 4.53ms making 1 call to Module::Find::BEGIN@8 # spent 48µs making 1 call to Exporter::import
9
101500nsour $VERSION = '0.10';
11
121400nsour $basedir = undef;
131400nsour @results = ();
141300nsour $prune = 0;
151500nsour $followMode = 1;
16
1716µsour @ISA = qw(Exporter);
18
1911µsour @EXPORT = qw(findsubmod findallmod usesub useall setmoduledirs);
20
211600nsour @EXPORT_OK = qw(followsymlinks ignoresymlinks);
22
23=encoding utf-8
24
25=head1 NAME
26
27Module::Find - Find and use installed modules in a (sub)category
28
29=head1 SYNOPSIS
30
31 use Module::Find;
32
33 # use all modules in the Plugins/ directory
34 @found = usesub Mysoft::Plugins;
35
36 # use modules in all subdirectories
37 @found = useall Mysoft::Plugins;
38
39 # find all DBI::... modules
40 @found = findsubmod DBI;
41
42 # find anything in the CGI/ directory
43 @found = findallmod CGI;
44
45 # set your own search dirs (uses @INC otherwise)
46 setmoduledirs(@INC, @plugindirs, $appdir);
47
48 # not exported by default
49 use Module::Find qw(ignoresymlinks followsymlinks);
50
51 # ignore symlinks
52 ignoresymlinks();
53
54 # follow symlinks (default)
55 followsymlinks();
56
57=head1 DESCRIPTION
58
59Module::Find lets you find and use modules in categories. This can be very
60useful for auto-detecting driver or plugin modules. You can differentiate
61between looking in the category itself or in all subcategories.
62
63If you want Module::Find to search in a certain directory on your
64harddisk (such as the plugins directory of your software installation),
65make sure you modify C<@INC> before you call the Module::Find functions.
66
67=head1 FUNCTIONS
68
69=over
70
71=item C<setmoduledirs(@directories)>
72
73Sets the directories to be searched for modules. If not set, Module::Find
74will use @INC. If you use this function, @INC will I<not> be included
75automatically, so add it if you want it. Set to undef to revert to
76default behaviour.
77
78=cut
79
80sub setmoduledirs {
81 return @Module::Find::ModuleDirs = @_;
82}
83
84=item C<@found = findsubmod Module::Category>
85
86Returns modules found in the Module/Category subdirectories of your perl
87installation. E.g. C<findsubmod CGI> will return C<CGI::Session>, but
88not C<CGI::Session::File> .
89
90=cut
91
92sub findsubmod(*) {
93 $prune = 1;
94
95 return _find($_[0]);
96}
97
98=item C<@found = findallmod Module::Category>
99
100Returns modules found in the Module/Category subdirectories of your perl
101installation. E.g. C<findallmod CGI> will return C<CGI::Session> and also
102C<CGI::Session::File> .
103
104=cut
105
106
# spent 12.3ms (19µs+12.3) within Module::Find::findallmod which was called 4 times, avg 3.07ms/call: # 4 times (19µs+12.3ms) by DBIx::Class::Schema::_findallmod at line 170 of DBIx/Class/Schema.pm, avg 3.07ms/call
sub findallmod(*) {
107824µs $prune = 0;
108
109412.3ms return _find($_[0]);
# spent 12.3ms making 4 calls to Module::Find::_find, avg 3.07ms/call
110}
111
112=item C<@found = usesub Module::Category>
113
114Uses and returns modules found in the Module/Category subdirectories of your perl
115installation. E.g. C<usesub CGI> will return C<CGI::Session>, but
116not C<CGI::Session::File> .
117
118=cut
119
120sub usesub(*) {
121 $prune = 1;
122
123 my @r = _find($_[0]);
124
125 foreach my $m (@r) {
126 eval " require $m; import $m ; ";
127 die $@ if $@;
128 }
129
130 return @r;
131}
132
133=item C<@found = useall Module::Category>
134
135Uses and returns modules found in the Module/Category subdirectories of your perl installation. E.g. C<useall CGI> will return C<CGI::Session> and also
136C<CGI::Session::File> .
137
138=cut
139
140sub useall(*) {
141 $prune = 0;
142
143 my @r = _find($_[0]);
144
145 foreach my $m (@r) {
146 eval " require $m; import $m; ";
147 die $@ if $@;
148 }
149
150 return @r;
151}
152
153# 'wanted' functions for find()
154# you know, this would be a nice application for currying...
155
# spent 9.75ms (546µs+9.20) within Module::Find::_wanted which was called 45 times, avg 217µs/call: # 41 times (519µs+8.45ms) by File::Find::_find_dir_symlnk at line 1211 of File/Find.pm, avg 219µs/call # 4 times (27µs+748µs) by File::Find::_find_dir_symlnk at line 1128 of File/Find.pm, avg 194µs/call
sub _wanted {
156295783µs458.82ms my $name = File::Spec->abs2rel($_, $basedir);
# spent 8.82ms making 45 calls to File::Spec::Unix::abs2rel, avg 196µs/call
1574540µs return unless $name && $name ne File::Spec->curdir();
# spent 40µs making 45 calls to File::Spec::Unix::curdir, avg 884ns/call
158
15941138µs if (-d && $prune) {
# spent 138µs making 41 calls to Module::Find::CORE:ftdir, avg 3µs/call
160 $File::Find::prune = 1;
161 return;
162 }
163
16482124µs return unless /\.pm$/ && -r;
# spent 103µs making 41 calls to Module::Find::CORE:fteread, avg 3µs/call # spent 21µs making 41 calls to Module::Find::CORE:match, avg 502ns/call
165
1664130µs $name =~ s|\.pm$||;
# spent 30µs making 41 calls to Module::Find::CORE:subst, avg 741ns/call
1674151µs $name = join('::', File::Spec->splitdir($name));
# spent 51µs making 41 calls to File::Spec::Unix::splitdir, avg 1µs/call
168
169 push @results, $name;
170}
171
172
173# helper functions for finding files
174
175
# spent 12.3ms (278µs+12.0) within Module::Find::_find which was called 4 times, avg 3.07ms/call: # 4 times (278µs+12.0ms) by Module::Find::findallmod at line 109, avg 3.07ms/call
sub _find(*) {
176100337µs my ($category) = @_;
177 return undef unless defined $category;
178
179497µs my $dir = File::Spec->catdir(split(/::/, $category));
# spent 97µs making 4 calls to File::Spec::Unix::catdir, avg 24µs/call
180
181 my @dirs;
182 if (defined @Module::Find::ModuleDirs) {
183 @dirs = map { File::Spec->catdir($_, $dir) }
184 @Module::Find::ModuleDirs;
185 } else {
18624354µs @dirs = map { File::Spec->catdir($_, $dir) } @INC;
# spent 354µs making 24 calls to File::Spec::Unix::catdir, avg 15µs/call
187 }
188 @results = ();
189
190 foreach $basedir (@dirs) {
1912477µs next unless -d $basedir;
# spent 77µs making 24 calls to Module::Find::CORE:ftdir, avg 3µs/call
192
193411.5ms find({wanted => \&_wanted,
# spent 11.5ms making 4 calls to File::Find::find, avg 2.86ms/call
194 no_chdir => 1,
195 follow => $followMode}, $basedir);
196 }
197
198 # filter duplicate modules
199 my %seen = ();
200 @results = grep { not $seen{$_}++ } @results;
201
202 @results = map "$category\::$_", @results;
203 return @results;
204}
205
206=item C<ignoresymlinks()>
207
208Do not follow symlinks. This function is not exported by default.
209
210=cut
211
212sub ignoresymlinks {
213 $followMode = 0;
214}
215
216=item C<followsymlinks()>
217
218Follow symlinks (default behaviour). This function is not exported by default.
219
220=cut
221
222sub followsymlinks {
223 $followMode = 1;
224}
225
226=back
227
228=head1 HISTORY
229
230=over 8
231
232=item 0.01, 2004-04-22
233
234Original version; created by h2xs 1.22
235
236=item 0.02, 2004-05-25
237
238Added test modules that were left out in the first version. Thanks to
239Stuart Johnston for alerting me to this.
240
241=item 0.03, 2004-06-18
242
243Fixed a bug (non-localized $_) by declaring a loop variable in use functions.
244Thanks to Stuart Johnston for alerting me to this and providing a fix.
245
246Fixed non-platform compatibility by using File::Spec.
247Thanks to brian d foy.
248
249Added setmoduledirs and updated tests. Idea shamelessly stolen from
250...errm... inspired by brian d foy.
251
252=item 0.04, 2005-05-20
253
254Added POD tests.
255
256=item 0.05, 2005-11-30
257
258Fixed issue with bugfix in PathTools-3.14.
259
260=item 0.06, 2008-01-26
261
262Module::Find now won't report duplicate modules several times anymore (thanks to Uwe Völker for the report and the patch)
263
264=item 0.07, 2009-09-08
265
266Fixed RT#38302: Module::Find now follows symlinks by default (can be disabled).
267
268=item 0.08, 2009-09-08
269
270Fixed RT#49511: Removed Mac OS X extended attributes from distribution
271
272=item 0.09, 2010-02-26
273
274Fixed RT#38302: Fixed META.yml generation (thanks very much to cpanservice for the help).
275
276=item 0.10, 2010-02-26
277
278Fixed RT#55010: Removed Unicode BOM from Find.pm.
279
280=back
281
282=head1 DEVELOPMENT NOTES
283
284Please report any bugs using the CPAN RT system. The development repository for this module is hosted on GitHub: L<http://github.com/crenz/Module-Find/>.
285
286=head1 SEE ALSO
287
288L<perl>
289
290=head1 AUTHOR
291
292Christian Renz, E<lt>crenz@web42.comE<gt>
293
294=head1 COPYRIGHT AND LICENSE
295
296Copyright 2004-2010 by Christian Renz <crenz@web42.com>. All rights reserved.
297
298This library is free software; you can redistribute it and/or modify
299it under the same terms as Perl itself.
300
301=cut
302
30315µs1;
 
# spent 215µs within Module::Find::CORE:ftdir which was called 65 times, avg 3µs/call: # 41 times (138µs+0s) by Module::Find::_wanted at line 159, avg 3µs/call # 24 times (77µs+0s) by Module::Find::_find at line 191, avg 3µs/call
sub Module::Find::CORE:ftdir; # opcode
# spent 103µs within Module::Find::CORE:fteread which was called 41 times, avg 3µs/call: # 41 times (103µs+0s) by Module::Find::_wanted at line 164, avg 3µs/call
sub Module::Find::CORE:fteread; # opcode
# spent 21µs within Module::Find::CORE:match which was called 41 times, avg 502ns/call: # 41 times (21µs+0s) by Module::Find::_wanted at line 164, avg 502ns/call
sub Module::Find::CORE:match; # opcode
# spent 30µs within Module::Find::CORE:subst which was called 41 times, avg 741ns/call: # 41 times (30µs+0s) by Module::Find::_wanted at line 166, avg 741ns/call
sub Module::Find::CORE:subst; # opcode