← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:11 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Module/Pluggable/Object.pm
StatementsExecuted 11010 statements in 19.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1411184.2ms1.24sModule::Pluggable::Object::::_requireModule::Pluggable::Object::_require
5117.83ms1.29sModule::Pluggable::Object::::search_pathsModule::Pluggable::Object::search_paths
1117.18ms7.57msModule::Pluggable::Object::::BEGIN@4Module::Pluggable::Object::BEGIN@4
141114.94ms1.24sModule::Pluggable::Object::::handle_finding_pluginModule::Pluggable::Object::handle_finding_plugin
282211.75ms1.75msModule::Pluggable::Object::::_is_legitModule::Pluggable::Object::_is_legit
1146811.17ms1.17msModule::Pluggable::Object::::CORE:matchModule::Pluggable::Object::CORE:match (opcode)
15921957┬Ás1.32msModule::Pluggable::Object::::__ANON__[:317]Module::Pluggable::Object::__ANON__[:317]
14111876┬Ás1.00msModule::Pluggable::Object::::_is_editor_junkModule::Pluggable::Object::_is_editor_junk
111527┬Ás1.29sModule::Pluggable::Object::::pluginsModule::Pluggable::Object::plugins
111487┬Ás712┬ÁsModule::Pluggable::Object::::BEGIN@6Module::Pluggable::Object::BEGIN@6
111475┬Ás1.30msModule::Pluggable::Object::::BEGIN@8Module::Pluggable::Object::BEGIN@8
30021417┬Ás417┬ÁsModule::Pluggable::Object::::CORE:regcompModule::Pluggable::Object::CORE:regcomp (opcode)
11167┬Ás1.29sModule::Pluggable::Object::::search_directoriesModule::Pluggable::Object::search_directories
11150┬Ás9.08msModule::Pluggable::Object::::find_filesModule::Pluggable::Object::find_files
1411134┬Ás34┬ÁsModule::Pluggable::Object::::CORE:substModule::Pluggable::Object::CORE:subst (opcode)
51132┬Ás32┬ÁsModule::Pluggable::Object::::CORE:ftisModule::Pluggable::Object::CORE:ftis (opcode)
11128┬Ás28┬ÁsModule::Pluggable::Object::::CORE:sortModule::Pluggable::Object::CORE:sort (opcode)
11128┬Ás44┬ÁsModule::Pluggable::Object::::BEGIN@3Module::Pluggable::Object::BEGIN@3
11113┬Ás106┬ÁsModule::Pluggable::Object::::BEGIN@11Module::Pluggable::Object::BEGIN@11
62110┬Ás10┬ÁsModule::Pluggable::Object::::CORE:qrModule::Pluggable::Object::CORE:qr (opcode)
1119┬Ás43┬ÁsModule::Pluggable::Object::::BEGIN@5Module::Pluggable::Object::BEGIN@5
1118┬Ás36┬ÁsModule::Pluggable::Object::::BEGIN@7Module::Pluggable::Object::BEGIN@7
1118┬Ás8┬ÁsModule::Pluggable::Object::::handle_inc_hooksModule::Pluggable::Object::handle_inc_hooks
1117┬Ás24┬ÁsModule::Pluggable::Object::::BEGIN@9Module::Pluggable::Object::BEGIN@9
2215┬Ás5┬ÁsModule::Pluggable::Object::::handle_innerpackagesModule::Pluggable::Object::handle_innerpackages
1114┬Ás4┬ÁsModule::Pluggable::Object::::_setup_exceptionsModule::Pluggable::Object::_setup_exceptions
1114┬Ás4┬ÁsModule::Pluggable::Object::::newModule::Pluggable::Object::new
111600ns600nsModule::Pluggable::Object::::CORE:ftdirModule::Pluggable::Object::CORE:ftdir (opcode)
0000s0sModule::Pluggable::Object::::__ANON__[:51]Module::Pluggable::Object::__ANON__[:51]
0000s0sModule::Pluggable::Object::::__ANON__[:52]Module::Pluggable::Object::__ANON__[:52]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Module::Pluggable::Object;
2
3228┬Ás261┬Ás
# spent 44┬Ás (28+17) within Module::Pluggable::Object::BEGIN@3 which was called: # once (28┬Ás+17┬Ás) by Module::Pluggable::BEGIN@5 at line 3
use strict;
# spent 44┬Ás making 1 call to Module::Pluggable::Object::BEGIN@3 # spent 17┬Ás making 1 call to strict::import
42120┬Ás17.57ms
# spent 7.57ms (7.18+385┬Ás) within Module::Pluggable::Object::BEGIN@4 which was called: # once (7.18ms+385┬Ás) by Module::Pluggable::BEGIN@5 at line 4
use File::Find ();
# spent 7.57ms making 1 call to Module::Pluggable::Object::BEGIN@4
5226┬Ás277┬Ás
# spent 43┬Ás (9+34) within Module::Pluggable::Object::BEGIN@5 which was called: # once (9┬Ás+34┬Ás) by Module::Pluggable::BEGIN@5 at line 5
use File::Basename;
# spent 43┬Ás making 1 call to Module::Pluggable::Object::BEGIN@5 # spent 34┬Ás making 1 call to Exporter::import
6289┬Ás2778┬Ás
# spent 712┬Ás (487+224) within Module::Pluggable::Object::BEGIN@6 which was called: # once (487┬Ás+224┬Ás) by Module::Pluggable::BEGIN@5 at line 6
use File::Spec::Functions qw(splitdir catdir curdir catfile abs2rel);
# spent 712┬Ás making 1 call to Module::Pluggable::Object::BEGIN@6 # spent 66┬Ás making 1 call to Exporter::import
7222┬Ás264┬Ás
# spent 36┬Ás (8+28) within Module::Pluggable::Object::BEGIN@7 which was called: # once (8┬Ás+28┬Ás) by Module::Pluggable::BEGIN@5 at line 7
use Carp qw(croak carp confess);
# spent 36┬Ás making 1 call to Module::Pluggable::Object::BEGIN@7 # spent 28┬Ás making 1 call to Exporter::import
8284┬Ás21.32ms
# spent 1.30ms (475┬Ás+826┬Ás) within Module::Pluggable::Object::BEGIN@8 which was called: # once (475┬Ás+826┬Ás) by Module::Pluggable::BEGIN@5 at line 8
use Devel::InnerPackage;
# spent 1.30ms making 1 call to Module::Pluggable::Object::BEGIN@8 # spent 15┬Ás making 1 call to Exporter::import
9225┬Ás242┬Ás
# spent 24┬Ás (7+18) within Module::Pluggable::Object::BEGIN@9 which was called: # once (7┬Ás+18┬Ás) by Module::Pluggable::BEGIN@5 at line 9
use vars qw($VERSION);
# spent 24┬Ás making 1 call to Module::Pluggable::Object::BEGIN@9 # spent 18┬Ás making 1 call to vars::import
10
1121.61ms2108┬Ás
# spent 106┬Ás (13+93) within Module::Pluggable::Object::BEGIN@11 which was called: # once (13┬Ás+93┬Ás) by Module::Pluggable::BEGIN@5 at line 11
use if $] > 5.017, 'deprecate';
# spent 106┬Ás making 1 call to Module::Pluggable::Object::BEGIN@11 # spent 2┬Ás making 1 call to if::import
12
131800ns$VERSION = '5.1';
14
15
16
# spent 4┬Ás within Module::Pluggable::Object::new which was called: # once (4┬Ás+0s) by Module::Pluggable::import at line 31 of Module/Pluggable.pm
sub new {
171300ns my $class = shift;
1811┬Ás my %opts = @_;
19
2014┬Ás return bless \%opts, $class;
21
22}
23
24### Eugggh, this code smells
25### This is what happens when you keep adding patches
26### *sigh*
27
28
29
# spent 1.29s (527┬Ás+1.29) within Module::Pluggable::Object::plugins which was called: # once (527┬Ás+1.29s) by Module::Pluggable::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Module/Pluggable.pm:32] at line 32 of Module/Pluggable.pm
sub plugins {
301100ns my $self = shift;
311300ns my @args = @_;
32
33 # override 'require'
3412┬Ás $self->{'require'} = 1 if $self->{'inner'};
35
361400ns my $filename = $self->{'filename'};
371100ns my $pkg = $self->{'package'};
38
39 # Get the exception params instantiated
4011┬Ás14┬Ás $self->_setup_exceptions;
# spent 4┬Ás making 1 call to Module::Pluggable::Object::_setup_exceptions
41
42 # automatically turn a scalar search path or namespace into a arrayref
431600ns for (qw(search_path search_dirs)) {
4422┬Ás $self->{$_} = [ $self->{$_} ] if exists $self->{$_} && !ref($self->{$_});
45 }
46
47 # default search path is '<Module>::<Name>::Plugin'
481200ns $self->{'search_path'} ||= ["${pkg}::Plugin"];
49
50 # default error handler
5112┬Ás $self->{'on_require_error'} ||= sub { my ($plugin, $err) = @_; carp "Couldn't require $plugin : $err"; return 0 };
5211┬Ás $self->{'on_instantiate_error'} ||= sub { my ($plugin, $err) = @_; carp "Couldn't instantiate $plugin: $err"; return 0 };
53
54 # default whether to follow symlinks
551400ns $self->{'follow_symlinks'} = 1 unless exists $self->{'follow_symlinks'};
56
57 # check to see if we're running under test
5812┬Ás my @SEARCHDIR = exists $INC{"blib.pm"} && defined $filename && $filename =~ m!(^|/)blib/! && !$self->{'force_search_all_paths'} ? grep {/blib/} @INC : @INC;
59
60 # add any search_dir params
611200ns unshift @SEARCHDIR, @{$self->{'search_dirs'}} if defined $self->{'search_dirs'};
62
63 # set our @INC up to include and prefer our search_dirs if necessary
641800ns my @tmp = @INC;
651600ns unshift @tmp, @{$self->{'search_dirs'} || []};
661100ns local @INC = @tmp if defined $self->{'search_dirs'};
67
68110┬Ás11.29s my @plugins = $self->search_directories(@SEARCHDIR);
# spent 1.29s making 1 call to Module::Pluggable::Object::search_directories
6915┬Ás18┬Ás push(@plugins, $self->handle_inc_hooks($_, @SEARCHDIR)) for @{$self->{'search_path'}};
# spent 8┬Ás making 1 call to Module::Pluggable::Object::handle_inc_hooks
7012┬Ás12┬Ás push(@plugins, $self->handle_innerpackages($_)) for @{$self->{'search_path'}};
# spent 2┬Ás making 1 call to Module::Pluggable::Object::handle_innerpackages
71
72 # return blank unless we've found anything
731300ns return () unless @plugins;
74
75 # remove duplicates
76 # probably not necessary but hey ho
771100ns my %plugins;
781600ns for(@plugins) {
79141138┬Ás141718┬Ás next unless $self->_is_legit($_);
# spent 718┬Ás making 141 calls to Module::Pluggable::Object::_is_legit, avg 5┬Ás/call
80141108┬Ás $plugins{$_} = 1;
81 }
82
83 # are we instantiating or requiring?
841500ns if (defined $self->{'instantiate'}) {
85 my $method = $self->{'instantiate'};
86 my @objs = ();
87 foreach my $package (sort keys %plugins) {
88 next unless $package->can($method);
89 my $obj = eval { $package->$method(@_) };
90 $self->{'on_instantiate_error'}->($package, $@) if $@;
91 push @objs, $obj if $obj;
92 }
93 return @objs;
94 } else {
95 # no? just return the names
96156┬Ás128┬Ás my @objs= sort keys %plugins;
# spent 28┬Ás making 1 call to Module::Pluggable::Object::CORE:sort
97142┬Ás return @objs;
98 }
99}
100
101
# spent 4┬Ás within Module::Pluggable::Object::_setup_exceptions which was called: # once (4┬Ás+0s) by Module::Pluggable::Object::plugins at line 40
sub _setup_exceptions {
1021200ns my $self = shift;
103
1041100ns my %only;
10510s my %except;
10610s my $only;
10710s my $except;
108
1091200ns if (defined $self->{'only'}) {
110 if (ref($self->{'only'}) eq 'ARRAY') {
111 %only = map { $_ => 1 } @{$self->{'only'}};
112 } elsif (ref($self->{'only'}) eq 'Regexp') {
113 $only = $self->{'only'}
114 } elsif (ref($self->{'only'}) eq '') {
115 $only{$self->{'only'}} = 1;
116 }
117 }
118
119
1201100ns if (defined $self->{'except'}) {
121 if (ref($self->{'except'}) eq 'ARRAY') {
122 %except = map { $_ => 1 } @{$self->{'except'}};
123 } elsif (ref($self->{'except'}) eq 'Regexp') {
124 $except = $self->{'except'}
125 } elsif (ref($self->{'except'}) eq '') {
126 $except{$self->{'except'}} = 1;
127 }
128 }
1291800ns $self->{_exceptions}->{only_hash} = \%only;
1301300ns $self->{_exceptions}->{only} = $only;
1311300ns $self->{_exceptions}->{except_hash} = \%except;
13214┬Ás $self->{_exceptions}->{except} = $except;
133
134}
135
136
# spent 1.75ms within Module::Pluggable::Object::_is_legit which was called 282 times, avg 6┬Ás/call: # 141 times (1.04ms+0s) by Module::Pluggable::Object::handle_finding_plugin at line 274, avg 7┬Ás/call # 141 times (718┬Ás+0s) by Module::Pluggable::Object::plugins at line 79, avg 5┬Ás/call
sub _is_legit {
13728231┬Ás my $self = shift;
13828230┬Ás my $plugin = shift;
139282253┬Ás my %only = %{$self->{_exceptions}->{only_hash}||{}};
14028281┬Ás my %except = %{$self->{_exceptions}->{except_hash}||{}};
14128267┬Ás my $only = $self->{_exceptions}->{only};
14228238┬Ás my $except = $self->{_exceptions}->{except};
143282472┬Ás my $depth = () = split '::', $plugin, -1;
144
14528245┬Ás return 0 if (keys %only && !$only{$plugin} );
14628240┬Ás return 0 unless (!defined $only || $plugin =~ m!$only! );
147
14828217┬Ás return 0 if (keys %except && $except{$plugin} );
14928222┬Ás return 0 if (defined $except && $plugin =~ m!$except! );
150
15128245┬Ás return 0 if defined $self->{max_depth} && $depth>$self->{max_depth};
15228238┬Ás return 0 if defined $self->{min_depth} && $depth<$self->{min_depth};
153
154282635┬Ás return 1;
155}
156
157
# spent 1.29s (67┬Ás+1.29) within Module::Pluggable::Object::search_directories which was called: # once (67┬Ás+1.29s) by Module::Pluggable::Object::plugins at line 68
sub search_directories {
1581200ns my $self = shift;
1591900ns my @SEARCHDIR = @_;
160
1611100ns my @plugins;
162 # go through our @INC
1631400ns foreach my $dir (@SEARCHDIR) {
164524┬Ás51.29s push @plugins, $self->search_paths($dir);
# spent 1.29s making 5 calls to Module::Pluggable::Object::search_paths, avg 258ms/call
165 }
166137┬Ás return @plugins;
167}
168
169
170
# spent 1.29s (7.83ms+1.28) within Module::Pluggable::Object::search_paths which was called 5 times, avg 258ms/call: # 5 times (7.83ms+1.28s) by Module::Pluggable::Object::search_directories at line 164, avg 258ms/call
sub search_paths {
17151┬Ás my $self = shift;
1725900ns my $dir = shift;
1735300ns my @plugins;
174
175519┬Ás56┬Ás my $file_regex = $self->{'file_regex'} || qr/\.pm$/;
# spent 6┬Ás making 5 calls to Module::Pluggable::Object::CORE:qr, avg 1┬Ás/call
176
177
178 # and each directory in our search path
17956┬Ás foreach my $searchpath (@{$self->{'search_path'}}) {
180 # create the search directory in a cross platform goodness way
181530┬Ás510┬Ás my $sp = catdir($dir, (split /::/, $searchpath));
# spent 10┬Ás making 5 calls to File::Spec::Unix::_fn_catdir, avg 2┬Ás/call
182
183 # if it doesn't exist or it's not a dir then skip it
184549┬Ás632┬Ás next unless ( -e $sp && -d _ ); # Use the cached stat the second time
# spent 32┬Ás making 5 calls to Module::Pluggable::Object::CORE:ftis, avg 6┬Ás/call # spent 600ns making 1 call to Module::Pluggable::Object::CORE:ftdir
185
186110┬Ás19.08ms my @files = $self->find_files($sp);
# spent 9.08ms making 1 call to Module::Pluggable::Object::find_files
187
188 # foreach one we've found
1891500ns foreach my $file (@files) {
190 # untaint the file; accept .pm only
1911411.12ms282519┬Ás next unless ($file) = ($file =~ /(.*$file_regex)$/);
# spent 299┬Ás making 141 calls to Module::Pluggable::Object::CORE:match, avg 2┬Ás/call # spent 220┬Ás making 141 calls to Module::Pluggable::Object::CORE:regcomp, avg 2┬Ás/call
192 # parse the file to get the name
193141258┬Ás1413.18ms my ($name, $directory, $suffix) = fileparse($file, $file_regex);
# spent 3.18ms making 141 calls to File::Basename::fileparse, avg 23┬Ás/call
194
195141260┬Ás1411.00ms next if (!$self->{include_editor_junk} && $self->_is_editor_junk($name));
# spent 1.00ms making 141 calls to Module::Pluggable::Object::_is_editor_junk, avg 7┬Ás/call
196
197141229┬Ás14124.2ms $directory = abs2rel($directory, $sp);
# spent 24.2ms making 141 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:62], avg 172┬Ás/call
198
199 # If we have a mixed-case package name, assume case has been preserved
200 # correctly. Otherwise, root through the file to locate the case-preserved
201 # version of the package name.
20214141┬Ás my @pkg_dirs = ();
203141110┬Ás if ( $name eq lc($name) || $name eq uc($name) ) {
204 my $pkg_file = catfile($sp, $directory, "$name$suffix");
205 open PKGFILE, "<$pkg_file" or die "search_paths: Can't open $pkg_file: $!";
206 my $in_pod = 0;
207 while ( my $line = <PKGFILE> ) {
208 $in_pod = 1 if $line =~ m/^=\w/;
209 $in_pod = 0 if $line =~ /^=cut/;
210 next if ($in_pod || $line =~ /^=cut/); # skip pod text
211 next if $line =~ /^\s*#/; # and comments
212 if ( $line =~ m/^\s*package\s+(.*::)?($name)\s*;/i ) {
213 @pkg_dirs = split /::/, $1 if defined $1;;
214 $name = $2;
215 last;
216 }
217 }
218 close PKGFILE;
219 }
220
221 # then create the class name in a cross platform way
222141497┬Ás141254┬Ás $directory =~ s/^[a-z]://i if($^O =~ /MSWin32|dos/); # remove volume
# spent 254┬Ás making 141 calls to Module::Pluggable::Object::CORE:match, avg 2┬Ás/call
22314132┬Ás my @dirs = ();
22414137┬Ás if ($directory) {
225141512┬Ás141196┬Ás ($directory) = ($directory =~ /(.*)/);
# spent 196┬Ás making 141 calls to Module::Pluggable::Object::CORE:match, avg 1┬Ás/call
226141334┬Ás141623┬Ás @dirs = grep(length($_), splitdir($directory))
# spent 623┬Ás making 141 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:62], avg 4┬Ás/call
227 unless $directory eq curdir();
22814161┬Ás for my $d (reverse @dirs) {
22914137┬Ás my $pkg_dir = pop @pkg_dirs;
23014190┬Ás last unless defined $pkg_dir;
231 $d =~ s/\Q$pkg_dir\E/$pkg_dir/i; # Correct case
232 }
233 } else {
234 $directory = "";
235 }
23614199┬Ás my $plugin = join '::', $searchpath, @dirs, $name;
237
238141404┬Ás141155┬Ás next unless $plugin =~ m!(?:[a-z\d]+)[a-z\d]*!i;
# spent 155┬Ás making 141 calls to Module::Pluggable::Object::CORE:match, avg 1┬Ás/call
239
240141386┬Ás1411.24s $self->handle_finding_plugin($plugin, \@plugins)
# spent 1.24s making 141 calls to Module::Pluggable::Object::handle_finding_plugin, avg 8.82ms/call
241 }
242
243 # now add stuff that may have been in package
244 # NOTE we should probably use all the stuff we've been given already
245 # but then we can't unload it :(
246129┬Ás13┬Ás push @plugins, $self->handle_innerpackages($searchpath);
# spent 3┬Ás making 1 call to Module::Pluggable::Object::handle_innerpackages
247 } # foreach $searchpath
248
249574┬Ás return @plugins;
250}
251
252
# spent 1.00ms (876┬Ás+127┬Ás) within Module::Pluggable::Object::_is_editor_junk which was called 141 times, avg 7┬Ás/call: # 141 times (876┬Ás+127┬Ás) by Module::Pluggable::Object::search_paths at line 195, avg 7┬Ás/call
sub _is_editor_junk {
25314131┬Ás my $self = shift;
25414120┬Ás my $name = shift;
255
256 # Emacs (and other Unix-y editors) leave temp files ending in a
257 # tilde as a backup.
258141297┬Ás14155┬Ás return 1 if $name =~ /~$/;
# spent 55┬Ás making 141 calls to Module::Pluggable::Object::CORE:match, avg 390ns/call
259 # Emacs makes these files while a buffer is edited but not yet
260 # saved.
261141203┬Ás14130┬Ás return 1 if $name =~ /^\.#/;
# spent 30┬Ás making 141 calls to Module::Pluggable::Object::CORE:match, avg 213ns/call
262 # Vim can leave these files behind if it crashes.
263141202┬Ás14142┬Ás return 1 if $name =~ /\.sw[po]$/;
# spent 42┬Ás making 141 calls to Module::Pluggable::Object::CORE:match, avg 298ns/call
264
265141275┬Ás return 0;
266}
267
268
# spent 1.24s (4.94ms+1.24) within Module::Pluggable::Object::handle_finding_plugin which was called 141 times, avg 8.82ms/call: # 141 times (4.94ms+1.24s) by Module::Pluggable::Object::search_paths at line 240, avg 8.82ms/call
sub handle_finding_plugin {
26914132┬Ás my $self = shift;
27014117┬Ás my $plugin = shift;
27114115┬Ás my $plugins = shift;
27214129┬Ás my $no_req = shift || 0;
273
274141136┬Ás1411.04ms return unless $self->_is_legit($plugin);
# spent 1.04ms making 141 calls to Module::Pluggable::Object::_is_legit, avg 7┬Ás/call
27514153┬Ás unless (defined $self->{'instantiate'} || $self->{'require'}) {
276 push @$plugins, $plugin;
277 return;
278 }
279
28014117┬Ás $self->{before_require}->($plugin) || return if defined $self->{before_require};
28114119┬Ás unless ($no_req) {
28214129┬Ás my $tmp = $@;
283282232┬Ás1411.24s my $res = eval { $self->_require($plugin) };
# spent 1.24s making 141 calls to Module::Pluggable::Object::_require, avg 8.78ms/call
28414127┬Ás my $err = $@;
28514116┬Ás $@ = $tmp;
28614131┬Ás if ($err) {
287 if (defined $self->{on_require_error}) {
288 $self->{on_require_error}->($plugin, $err) || return;
289 } else {
290 return;
291 }
292 }
293 }
29414161┬Ás $self->{after_require}->($plugin) || return if defined $self->{after_require};
295141386┬Ás push @$plugins, $plugin;
296}
297
298
# spent 9.08ms (50┬Ás+9.03) within Module::Pluggable::Object::find_files which was called: # once (50┬Ás+9.03ms) by Module::Pluggable::Object::search_paths at line 186
sub find_files {
2991200ns my $self = shift;
3001200ns my $search_path = shift;
30117┬Ás14┬Ás my $file_regex = $self->{'file_regex'} || qr/\.pm$/;
# spent 4┬Ás making 1 call to Module::Pluggable::Object::CORE:qr
302
303
304 # find all the .pm files in it
305 # this isn't perfect and won't find multiple plugins per file
306 #my $cwd = Cwd::getcwd;
3071300ns my @files = ();
308 { # for the benefit of perl 5.6.1's Find, localize topic
30923┬Ás local $_;
310 File::Find::find( { no_chdir => 1,
311 follow => $self->{'follow_symlinks'},
312
# spent 1.32ms (957┬Ás+367┬Ás) within Module::Pluggable::Object::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Module/Pluggable/Object.pm:317] which was called 159 times, avg 8┬Ás/call: # 141 times (880┬Ás+344┬Ás) by File::Find::_find_dir_symlnk at line 1012 of File/Find.pm, avg 9┬Ás/call # 18 times (77┬Ás+23┬Ás) by File::Find::_find_dir_symlnk at line 933 of File/Find.pm, avg 6┬Ás/call
wanted => sub {
313 # Inlined from File::Find::Rule C< name => '*.pm' >
314159832┬Ás318332┬Ás return unless $File::Find::name =~ /$file_regex/;
# spent 197┬Ás making 159 calls to Module::Pluggable::Object::CORE:regcomp, avg 1┬Ás/call # spent 135┬Ás making 159 calls to Module::Pluggable::Object::CORE:match, avg 849ns/call
315141252┬Ás14134┬Ás (my $path = $File::Find::name) =~ s#^\\./##;
# spent 34┬Ás making 141 calls to Module::Pluggable::Object::CORE:subst, avg 245ns/call
316141314┬Ás push @files, $path;
317 }
31814┬Ás19.03ms }, $search_path );
# spent 9.03ms making 1 call to File::Find::find
319 }
320 #chdir $cwd;
321140┬Ás return @files;
322
323}
324
325
# spent 8┬Ás within Module::Pluggable::Object::handle_inc_hooks which was called: # once (8┬Ás+0s) by Module::Pluggable::Object::plugins at line 69
sub handle_inc_hooks {
3261400ns my $self = shift;
3271500ns my $path = shift;
32812┬Ás my @SEARCHDIR = @_;
329
3301100ns my @plugins;
33111┬Ás for my $dir ( @SEARCHDIR ) {
3325400ns next unless ref $dir && eval { $dir->can( 'files' ) };
333
334 foreach my $plugin ( $dir->files ) {
335 $plugin =~ s/\.pm$//;
336 $plugin =~ s{/}{::}g;
337 next unless $plugin =~ m!^${path}::!;
338 $self->handle_finding_plugin( $plugin, \@plugins );
339 }
340 }
34114┬Ás return @plugins;
342}
343
344
# spent 5┬Ás within Module::Pluggable::Object::handle_innerpackages which was called 2 times, avg 2┬Ás/call: # once (3┬Ás+0s) by Module::Pluggable::Object::search_paths at line 246 # once (2┬Ás+0s) by Module::Pluggable::Object::plugins at line 70
sub handle_innerpackages {
3452600ns my $self = shift;
34628┬Ás return () if (exists $self->{inner} && !$self->{inner});
347
348 my $path = shift;
349 my @plugins;
350
351 foreach my $plugin (Devel::InnerPackage::list_packages($path)) {
352 $self->handle_finding_plugin($plugin, \@plugins, 1);
353 }
354 return @plugins;
355
356}
357
358
359
# spent 1.24s (84.2ms+1.15) within Module::Pluggable::Object::_require which was called 141 times, avg 8.78ms/call: # 141 times (84.2ms+1.15s) by Module::Pluggable::Object::handle_finding_plugin at line 283, avg 8.78ms/call
sub _require {
36014126┬Ás my $self = shift;
36114116┬Ás my $pack = shift;
3621412.61ms eval "CORE::require $pack";
# spent 177┬Ás executing statements in 2 string evals (merged) # spent 125┬Ás executing statements in string eval # spent 107┬Ás executing statements in string eval # spent 105┬Ás executing statements in string eval # spent 102┬Ás executing statements in string eval # spent 91┬Ás executing statements in string eval # spent 91┬Ás executing statements in string eval # spent 90┬Ás executing statements in string eval # spent 90┬Ás executing statements in string eval # spent 89┬Ás executing statements in string eval # spent 88┬Ás executing statements in string eval # spent 87┬Ás executing statements in string eval # spent 83┬Ás executing statements in string eval # spent 78┬Ás executing statements in string eval # spent 77┬Ás executing statements in string eval # spent 76┬Ás executing statements in string eval # spent 76┬Ás executing statements in string eval # spent 75┬Ás executing statements in string eval # spent 75┬Ás executing statements in string eval # spent 75┬Ás executing statements in string eval # spent 74┬Ás executing statements in string eval # spent 73┬Ás executing statements in string eval # spent 73┬Ás executing statements in string eval # spent 72┬Ás executing statements in string eval # spent 72┬Ás executing statements in string eval # spent 72┬Ás executing statements in string eval # spent 72┬Ás executing statements in string eval # spent 72┬Ás executing statements in string eval # spent 72┬Ás executing statements in string eval # spent 72┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 71┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 70┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 69┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 68┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 67┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 66┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 65┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 64┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 63┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval # spent 62┬Ás executing statements in string eval
36314115┬Ás die ($@) if $@;
3641413.73ms return 1;
365}
366
367
36812┬Ás1;
369
370=pod
371
372=head1 NAME
373
374Module::Pluggable::Object - automatically give your module the ability to have plugins
375
376=head1 SYNOPSIS
377
378
379Simple use Module::Pluggable -
380
381 package MyClass;
382 use Module::Pluggable::Object;
383
384 my $finder = Module::Pluggable::Object->new(%opts);
385 print "My plugins are: ".join(", ", $finder->plugins)."\n";
386
387=head1 DESCRIPTION
388
389Provides a simple but, hopefully, extensible way of having 'plugins' for
390your module. Obviously this isn't going to be the be all and end all of
391solutions but it works for me.
392
393Essentially all it does is export a method into your namespace that
394looks through a search path for .pm files and turn those into class names.
395
396Optionally it instantiates those classes for you.
397
398This object is wrapped by C<Module::Pluggable>. If you want to do something
399odd or add non-general special features you're probably best to wrap this
400and produce your own subclass.
401
402=head1 OPTIONS
403
404See the C<Module::Pluggable> docs.
405
406=head1 AUTHOR
407
408Simon Wistow <simon@thegestalt.org>
409
410=head1 COPYING
411
412Copyright, 2006 Simon Wistow
413
414Distributed under the same terms as Perl itself.
415
416=head1 BUGS
417
418None known.
419
420=head1 SEE ALSO
421
422L<Module::Pluggable>
423
424=cut
425
 
# spent 600ns within Module::Pluggable::Object::CORE:ftdir which was called: # once (600ns+0s) by Module::Pluggable::Object::search_paths at line 184
sub Module::Pluggable::Object::CORE:ftdir; # opcode
# spent 32┬Ás within Module::Pluggable::Object::CORE:ftis which was called 5 times, avg 6┬Ás/call: # 5 times (32┬Ás+0s) by Module::Pluggable::Object::search_paths at line 184, avg 6┬Ás/call
sub Module::Pluggable::Object::CORE:ftis; # opcode
# spent 1.17ms within Module::Pluggable::Object::CORE:match which was called 1146 times, avg 1┬Ás/call: # 159 times (135┬Ás+0s) by Module::Pluggable::Object::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Module/Pluggable/Object.pm:317] at line 314, avg 849ns/call # 141 times (299┬Ás+0s) by Module::Pluggable::Object::search_paths at line 191, avg 2┬Ás/call # 141 times (254┬Ás+0s) by Module::Pluggable::Object::search_paths at line 222, avg 2┬Ás/call # 141 times (196┬Ás+0s) by Module::Pluggable::Object::search_paths at line 225, avg 1┬Ás/call # 141 times (155┬Ás+0s) by Module::Pluggable::Object::search_paths at line 238, avg 1┬Ás/call # 141 times (55┬Ás+0s) by Module::Pluggable::Object::_is_editor_junk at line 258, avg 390ns/call # 141 times (42┬Ás+0s) by Module::Pluggable::Object::_is_editor_junk at line 263, avg 298ns/call # 141 times (30┬Ás+0s) by Module::Pluggable::Object::_is_editor_junk at line 261, avg 213ns/call
sub Module::Pluggable::Object::CORE:match; # opcode
# spent 10┬Ás within Module::Pluggable::Object::CORE:qr which was called 6 times, avg 2┬Ás/call: # 5 times (6┬Ás+0s) by Module::Pluggable::Object::search_paths at line 175, avg 1┬Ás/call # once (4┬Ás+0s) by Module::Pluggable::Object::find_files at line 301
sub Module::Pluggable::Object::CORE:qr; # opcode
# spent 417┬Ás within Module::Pluggable::Object::CORE:regcomp which was called 300 times, avg 1┬Ás/call: # 159 times (197┬Ás+0s) by Module::Pluggable::Object::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Module/Pluggable/Object.pm:317] at line 314, avg 1┬Ás/call # 141 times (220┬Ás+0s) by Module::Pluggable::Object::search_paths at line 191, avg 2┬Ás/call
sub Module::Pluggable::Object::CORE:regcomp; # opcode
# spent 28┬Ás within Module::Pluggable::Object::CORE:sort which was called: # once (28┬Ás+0s) by Module::Pluggable::Object::plugins at line 96
sub Module::Pluggable::Object::CORE:sort; # opcode
# spent 34┬Ás within Module::Pluggable::Object::CORE:subst which was called 141 times, avg 245ns/call: # 141 times (34┬Ás+0s) by Module::Pluggable::Object::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Module/Pluggable/Object.pm:317] at line 315, avg 245ns/call
sub Module::Pluggable::Object::CORE:subst; # opcode