← 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:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm
StatementsExecuted 120 statements in 1.95ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2215.50ms8.43msFile::ShareDir::ProjectDistDir::::_pathFile::ShareDir::ProjectDistDir::_path
1111.54ms3.76msFile::ShareDir::ProjectDistDir::::BEGIN@237File::ShareDir::ProjectDistDir::BEGIN@237
111390µs4.84msFile::ShareDir::ProjectDistDir::::BEGIN@234File::ShareDir::ProjectDistDir::BEGIN@234
111320µs751µsFile::ShareDir::ProjectDistDir::::BEGIN@235File::ShareDir::ProjectDistDir::BEGIN@235
11136µs107µsFile::ShareDir::ProjectDistDir::::__ANON__[:676]File::ShareDir::ProjectDistDir::__ANON__[:676]
11133µs118msFile::ShareDir::ProjectDistDir::::_get_cached_dist_dir_resultFile::ShareDir::ProjectDistDir::_get_cached_dist_dir_result
11125µs36µsFile::ShareDir::ProjectDistDir::::build_dist_fileFile::ShareDir::ProjectDistDir::build_dist_file
11120µs20µsFile::ShareDir::ProjectDistDir::::importFile::ShareDir::ProjectDistDir::import
11117µs17µsPod::Wordlist::::BEGIN@1 Pod::Wordlist::BEGIN@1
11113µs118msFile::ShareDir::ProjectDistDir::::__ANON__[:682]File::ShareDir::ProjectDistDir::__ANON__[:682]
66112µs12µsFile::ShareDir::ProjectDistDir::::_get_defaultsFile::ShareDir::ProjectDistDir::_get_defaults
1119µs23µsFile::ShareDir::ProjectDistDir::::BEGIN@257File::ShareDir::ProjectDistDir::BEGIN@257
1119µs11µsPod::Wordlist::::BEGIN@4.5 Pod::Wordlist::BEGIN@4.5
1118µs10µsFile::ShareDir::ProjectDistDir::::CORE:ftisFile::ShareDir::ProjectDistDir::CORE:ftis (opcode)
1118µs124µsFile::ShareDir::ProjectDistDir::::BEGIN@236File::ShareDir::ProjectDistDir::BEGIN@236
1117µs9µsFile::ShareDir::ProjectDistDir::::CORE:ftdirFile::ShareDir::ProjectDistDir::CORE:ftdir (opcode)
1117µs20µsPod::Wordlist::::BEGIN@2.3 Pod::Wordlist::BEGIN@2.3
1117µs13µsPod::Wordlist::::BEGIN@3.4 Pod::Wordlist::BEGIN@3.4
1117µs8µsFile::ShareDir::ProjectDistDir::::CORE:ftereadFile::ShareDir::ProjectDistDir::CORE:fteread (opcode)
1115µs5µsFile::ShareDir::ProjectDistDir::::_wrap_returnFile::ShareDir::ProjectDistDir::_wrap_return
1111µs1µsFile::ShareDir::ProjectDistDir::::_debugFile::ShareDir::ProjectDistDir::_debug
0000s0sFile::ShareDir::ProjectDistDir::::__ANON__[:260]File::ShareDir::ProjectDistDir::__ANON__[:260]
0000s0sFile::ShareDir::ProjectDistDir::::__ANON__[:593]File::ShareDir::ProjectDistDir::__ANON__[:593]
0000s0sFile::ShareDir::ProjectDistDir::::__ANON__[:598]File::ShareDir::ProjectDistDir::__ANON__[:598]
0000s0sFile::ShareDir::ProjectDistDir::::__ANON__[:688]File::ShareDir::ProjectDistDir::__ANON__[:688]
0000s0sFile::ShareDir::ProjectDistDir::::_carpFile::ShareDir::ProjectDistDir::_carp
0000s0sFile::ShareDir::ProjectDistDir::::_croakFile::ShareDir::ProjectDistDir::_croak
0000s0sFile::ShareDir::ProjectDistDir::::_need_pathclassFile::ShareDir::ProjectDistDir::_need_pathclass
0000s0sFile::ShareDir::ProjectDistDir::::build_dist_dirFile::ShareDir::ProjectDistDir::build_dist_dir
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1239µs117µs
# spent 17µs within Pod::Wordlist::BEGIN@1 which was called: # once (17µs+0s) by Pod::Wordlist::BEGIN@5 at line 1
use 5.008;
# spent 17µs making 1 call to Pod::Wordlist::BEGIN@1
2219µs233µs
# spent 20µs (7+13) within Pod::Wordlist::BEGIN@2.3 which was called: # once (7µs+13µs) by Pod::Wordlist::BEGIN@5 at line 2
use strict;
# spent 20µs making 1 call to Pod::Wordlist::BEGIN@2.3 # spent 13µs making 1 call to strict::import
3218µs219µs
# spent 13µs (7+6) within Pod::Wordlist::BEGIN@3.4 which was called: # once (7µs+6µs) by Pod::Wordlist::BEGIN@5 at line 3
use warnings;
# spent 13µs making 1 call to Pod::Wordlist::BEGIN@3.4 # spent 6µs making 1 call to warnings::import
42101µs214µs
# spent 11µs (9+3) within Pod::Wordlist::BEGIN@4.5 which was called: # once (9µs+3µs) by Pod::Wordlist::BEGIN@5 at line 4
use utf8;
# spent 11µs making 1 call to Pod::Wordlist::BEGIN@4.5 # spent 3µs making 1 call to utf8::import
5
6package File::ShareDir::ProjectDistDir;
71600ns$File::ShareDir::ProjectDistDir::VERSION = '1.000002';
8# ABSTRACT: Simple set-and-forget using of a '/share' directory in your projects root
9
101200nsour $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
11
- -
234273µs14.84ms
# spent 4.84ms (390µs+4.45) within File::ShareDir::ProjectDistDir::BEGIN@234 which was called: # once (390µs+4.45ms) by Pod::Wordlist::BEGIN@5 at line 234
use Path::IsDev qw();
# spent 4.84ms making 1 call to File::ShareDir::ProjectDistDir::BEGIN@234
235286µs2871µs
# spent 751µs (320+430) within File::ShareDir::ProjectDistDir::BEGIN@235 which was called: # once (320µs+430µs) by Pod::Wordlist::BEGIN@5 at line 235
use Path::FindDev qw(find_dev);
# spent 751µs making 1 call to File::ShareDir::ProjectDistDir::BEGIN@235 # spent 120µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
236225µs2240µs
# spent 124µs (8+116) within File::ShareDir::ProjectDistDir::BEGIN@236 which was called: # once (8µs+116µs) by Pod::Wordlist::BEGIN@5 at line 236
use Sub::Exporter qw(build_exporter);
# spent 124µs making 1 call to File::ShareDir::ProjectDistDir::BEGIN@236 # spent 116µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
2372181µs13.76ms
# spent 3.76ms (1.54+2.22) within File::ShareDir::ProjectDistDir::BEGIN@237 which was called: # once (1.54ms+2.22ms) by Pod::Wordlist::BEGIN@5 at line 237
use File::ShareDir qw();
# spent 3.76ms making 1 call to File::ShareDir::ProjectDistDir::BEGIN@237
238
23918µs1202µsmy ($exporter) = build_exporter(
# spent 202µs making 1 call to Sub::Exporter::build_exporter
240 {
241 exports => [ dist_dir => \&build_dist_dir, dist_file => \&build_dist_file ],
242 groups => {
243 all => [qw( dist_dir dist_file )],
244 'default' => [qw( dist_dir dist_file )],
245 },
246 collectors => [ 'defaults', ],
247 },
248);
2491400nsmy $env_key = 'FILE_SHAREDIR_PROJECTDISTDIR_DEBUG';
250
251## no critic (Subroutines::ProhibitSubroutinePrototypes)
25216µs
# spent 1µs within File::ShareDir::ProjectDistDir::_debug which was called: # once (1µs+0s) by File::ShareDir::ProjectDistDir::_get_cached_dist_dir_result at line 548
sub _debug($) { }
253## use critic
254
2551700nsif ( $ENV{$env_key} ) {
256 ## no critic (ProtectPrivateVars,TestingAndDebugging::ProhibitNoWarnings)
25721.18ms237µs
# spent 23µs (9+14) within File::ShareDir::ProjectDistDir::BEGIN@257 which was called: # once (9µs+14µs) by Pod::Wordlist::BEGIN@5 at line 257
no warnings 'redefine';
# spent 23µs making 1 call to File::ShareDir::ProjectDistDir::BEGIN@257 # spent 14µs making 1 call to warnings::unimport
258 *File::ShareDir::ProjectDistDir::_debug = sub ($) {
259 *STDERR->printf( qq{[ProjectDistDir] %s\n}, $_[0] );
260 };
261 $Path::IsDev::DEBUG = 1;
262 $Path::FindDev::DEBUG = 1;
263}
264
265## no critic (RequireArgUnpacking)
266sub _croak { require Carp; goto &Carp::croak }
267sub _carp { require Carp; goto &Carp::carp }
268
269476µs246µs
# spent 8.43ms (5.50+2.93) within File::ShareDir::ProjectDistDir::_path which was called 2 times, avg 4.22ms/call: # once (5.50ms+2.93ms) by File::ShareDir::ProjectDistDir::_get_cached_dist_dir_result at line 549 # once (3µs+0s) by File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:676] at line 667
sub _path { require Path::Tiny; goto &Path::Tiny::path }
# spent 46µs making 2 calls to Path::Tiny::path, avg 23µs/call
270
271sub _need_pathclass {
272 for my $package ( q[], q[::File], q[::Dir] ) {
273 ## no critic (Variables::RequireInitializationForLocalVars)
274 local $@ = undef;
275 my $code = sprintf 'require %s%s;1', 'Path::Class', $package;
276 ## no critic (BuiltinFunctions::ProhibitStringyEval,Lax::ProhibitStringyEval::ExceptForRequire)
277 next if eval $code;
278 my $err = $@;
279 _carp('Path::Class is not installed.');
280 ## no critic (RequireCarping, ErrorHandling::RequireUseOfExceptions)
281 die $err;
282 }
283 return 1;
284}
285
- -
413
# spent 20µs within File::ShareDir::ProjectDistDir::import which was called: # once (20µs+0s) by Pod::Wordlist::BEGIN@5 at line 6 of Pod/Wordlist.pm
sub import {
41411µs my ( $class, @args ) = @_;
415
41611µs my ( undef, $xfilename, undef ) = caller;
417
41811µs my $defaults = {
419 filename => $xfilename,
420 projectdir => 'share',
421 pathclass => undef,
422 strict => undef,
423 };
424
4251200ns if ( not @args ) {
426 @_ = ( $class, ':all', defaults => $defaults );
427 goto $exporter;
428 }
429
43012µs for ( 0 .. $#args - 1 ) {
4312100ns my ( $key, $value );
43221µs next unless $key = $args[$_] and $value = $args[ $_ + 1 ];
433
4342400ns if ( 'defaults' eq $key ) {
4351900ns $defaults = $value;
4361300ns undef $args[$_];
4371200ns undef $args[ $_ + 1 ];
4381300ns next;
439 }
4401700ns for my $setting (qw( projectdir filename distname pathclass pathtiny strict )) {
44161µs if ( $key eq $setting and not ref $value ) {
442 $defaults->{$setting} = $value;
443 undef $args[$_];
444 undef $args[ $_ + 1 ];
445 last;
446 }
447 }
448 }
449
4501900ns $defaults->{filename} = $xfilename if not defined $defaults->{filename};
4511500ns $defaults->{projectdir} = 'share' if not defined $defaults->{projectdir};
452
4531200ns if ( defined $defaults->{pathclass} ) {
454 _carp( 'Path::Class support depecated and will be removed from a future release.' . ' see Documentation for details' );
455 _need_pathclass();
456 }
457
45812µs @_ = ( $class, ( grep { defined } @args ), 'defaults' => $defaults );
459
46016µs1185µs goto $exporter;
# spent 185µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
461}
462
- -
510
# spent 12µs within File::ShareDir::ProjectDistDir::_get_defaults which was called 6 times, avg 2µs/call: # once (2µs+0s) by File::ShareDir::ProjectDistDir::build_dist_file at line 651 # once (2µs+0s) by File::ShareDir::ProjectDistDir::build_dist_file at line 656 # once (2µs+0s) by File::ShareDir::ProjectDistDir::build_dist_file at line 653 # once (2µs+0s) by File::ShareDir::ProjectDistDir::build_dist_file at line 655 # once (2µs+0s) by File::ShareDir::ProjectDistDir::build_dist_file at line 652 # once (2µs+0s) by File::ShareDir::ProjectDistDir::build_dist_file at line 658
sub _get_defaults {
51161µs my ( $field, $arg, $col ) = @_;
51260s my $result;
51363µs $result = $col->{defaults}->{$field} if $col->{defaults}->{$field};
5146200ns $result = $arg->{$field} if $arg->{$field};
515618µs return $result;
516}
517
518
# spent 5µs within File::ShareDir::ProjectDistDir::_wrap_return which was called: # once (5µs+0s) by File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:676] at line 675
sub _wrap_return {
5191800ns my ( $type, $value ) = @_;
5201300ns if ( not $type ) {
521 return $value unless ref $value;
522 return "$value";
523 }
5241700ns if ( 'pathtiny' eq $type ) {
52515µs return $value if 'Path::Tiny' eq ref $value;
526 return _path($value);
527 }
528 if ( 'pathclassdir' eq $type ) {
529 return $value if 'Path::Class::Dir' eq ref $value;
530 _need_pathclass;
531 return Path::Class::Dir->new("$value");
532 }
533 if ( 'pathclassfile' eq $type ) {
534 return $value if 'Path::Class::File' eq ref $value;
535 _need_pathclass;
536 return Path::Class::File->new("$value");
537 }
538 return _croak("Unknown return type $type");
539}
540
5411100nsour %DIST_DIR_CACHE;
542
543
# spent 118ms (33µs+118) within File::ShareDir::ProjectDistDir::_get_cached_dist_dir_result which was called: # once (33µs+118ms) by File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:682] at line 680
sub _get_cached_dist_dir_result {
54411µs my ( undef, $filename, $projectdir, $distname, $strict ) = @_;
5451300ns if ( defined $DIST_DIR_CACHE{$distname} ) {
546 return $DIST_DIR_CACHE{$distname};
547 }
54812µs11µs _debug( 'Working on: ' . $filename );
# spent 1µs making 1 call to File::ShareDir::ProjectDistDir::_debug
54917µs3118ms my $dev = find_dev( _path($filename)->parent );
# spent 109ms making 1 call to Path::FindDev::__ANON__[Path/FindDev.pm:81] # spent 8.43ms making 1 call to File::ShareDir::ProjectDistDir::_path # spent 68µs making 1 call to Path::Tiny::parent
550
5511400ns if ( not defined $dev ) {
552 ## no critic (Variables::ProhibitPackageVars)
5531600ns local $Carp::CarpLevel = $Carp::CarpLevel + 1;
55417µs182µs return File::ShareDir::dist_dir($distname);
# spent 82µs making 1 call to File::ShareDir::dist_dir
555 }
556
557 my $devel_share_dir = $dev->child($projectdir);
558
559 if ($strict) {
560 $devel_share_dir = $devel_share_dir->child( 'dist', $distname );
561 }
562 if ( -d $devel_share_dir ) {
563 _debug( 'ISDEV : exists : <devroot>/' . $devel_share_dir->relative($dev) );
564 return ( $DIST_DIR_CACHE{$distname} = $devel_share_dir );
565 }
566 _debug( 'ISPROD: does not exist : <devroot>/' . $devel_share_dir->relative($dev) );
567 ## no critic (Variables::ProhibitPackageVars)
568 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
569 return File::ShareDir::dist_dir($distname);
570}
571
572sub build_dist_dir {
573 my ( $class, undef, $arg, $col ) = @_;
574
575 my $projectdir = _get_defaults( projectdir => $arg, $col );
576 my $pathclass = _get_defaults( pathclass => $arg, $col );
577 my $pathtiny = _get_defaults( pathtiny => $arg, $col );
578 my $strict = _get_defaults( strict => $arg, $col );
579 my $filename = _get_defaults( filename => $arg, $col );
580
581 my $wrap_return_type;
582
583 if ($pathclass) { $wrap_return_type = 'pathclassdir' }
584 if ($pathtiny) { $wrap_return_type = 'pathtiny' }
585
586 my $distname = _get_defaults( distname => $arg, $col );
587
588 if ( not $distname ) {
589 return sub {
590 my ($udistname) = @_;
591 my $distdir = $class->_get_cached_dist_dir_result( $filename, $projectdir, $udistname, $strict );
592 return _wrap_return( $wrap_return_type, $distdir );
593 };
594 }
595 return sub {
596 my $distdir = $class->_get_cached_dist_dir_result( $filename, $projectdir, $distname, $strict );
597 return _wrap_return( $wrap_return_type, $distdir );
598 };
599}
600
- -
648
# spent 36µs (25+11) within File::ShareDir::ProjectDistDir::build_dist_file which was called: # once (25µs+11µs) by Sub::Exporter::default_generator at line 419 of Sub/Exporter.pm
sub build_dist_file {
6491500ns my ( $class, undef, $arg, $col ) = @_;
650
65111µs12µs my $projectdir = _get_defaults( projectdir => $arg, $col );
# spent 2µs making 1 call to File::ShareDir::ProjectDistDir::_get_defaults
6521900ns12µs my $pathclass = _get_defaults( pathclass => $arg, $col );
# spent 2µs making 1 call to File::ShareDir::ProjectDistDir::_get_defaults
6531800ns12µs my $pathtiny = _get_defaults( pathtiny => $arg, $col );
# spent 2µs making 1 call to File::ShareDir::ProjectDistDir::_get_defaults
654
6551900ns12µs my $strict = _get_defaults( strict => $arg, $col );
# spent 2µs making 1 call to File::ShareDir::ProjectDistDir::_get_defaults
6561900ns12µs my $filename = _get_defaults( filename => $arg, $col );
# spent 2µs making 1 call to File::ShareDir::ProjectDistDir::_get_defaults
657
6581900ns12µs my $distname = _get_defaults( distname => $arg, $col );
# spent 2µs making 1 call to File::ShareDir::ProjectDistDir::_get_defaults
659
66010s my $wrap_return_type;
661
66210s if ($pathclass) { $wrap_return_type = 'pathclassfile' }
6631200ns if ($pathtiny) { $wrap_return_type = 'pathtiny' }
664
665
# spent 107µs (36+72) within File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:676] which was called: # once (36µs+72µs) by File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:682] at line 681
my $check_file = sub {
6661800ns my ( $distdir, $wanted_file ) = @_;
66714µs224µs my $child = _path($distdir)->child($wanted_file);
# spent 22µs making 1 call to Path::Tiny::child # spent 3µs making 1 call to File::ShareDir::ProjectDistDir::_path
668112µs211µs return unless -e $child;
# spent 10µs making 1 call to File::ShareDir::ProjectDistDir::CORE:ftis # spent 1µs making 1 call to Path::Tiny::__ANON__[Path/Tiny.pm:31]
669110µs210µs if ( -d $child ) {
# spent 9µs making 1 call to File::ShareDir::ProjectDistDir::CORE:ftdir # spent 1µs making 1 call to Path::Tiny::__ANON__[Path/Tiny.pm:31]
670 return _croak("Found dist_file '$child', but is a dir");
671 }
672110µs29µs if ( not -r $child ) {
# spent 8µs making 1 call to File::ShareDir::ProjectDistDir::CORE:fteread # spent 1µs making 1 call to Path::Tiny::__ANON__[Path/Tiny.pm:31]
673 return _croak("File '$child', no read permissions");
674 }
67516µs15µs return _wrap_return( $wrap_return_type, $child );
# spent 5µs making 1 call to File::ShareDir::ProjectDistDir::_wrap_return
67612µs };
6771100ns if ( not $distname ) {
678
# spent 118ms (13µs+118) within File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:682] which was called: # once (13µs+118ms) by Pod::Spell::BEGIN@10 at line 22 of Pod/Wordlist.pm
return sub {
6791700ns my ( $udistname, $wanted_file ) = @_;
68012µs1118ms my $distdir = $class->_get_cached_dist_dir_result( $filename, $projectdir, $udistname, $strict );
68116µs1107µs return $check_file->( $distdir, $wanted_file );
68215µs };
683 }
684 return sub {
685 my ($wanted_file) = @_;
686 my $distdir = $class->_get_cached_dist_dir_result( $filename, $projectdir, $distname, $strict );
687 return $check_file->( $distdir, $wanted_file );
688 };
689}
690
69117µs1;
692
693__END__
 
# spent 9µs (7+1) within File::ShareDir::ProjectDistDir::CORE:ftdir which was called: # once (7µs+1µs) by File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:676] at line 669
sub File::ShareDir::ProjectDistDir::CORE:ftdir; # opcode
# spent 8µs (7+1) within File::ShareDir::ProjectDistDir::CORE:fteread which was called: # once (7µs+1µs) by File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:676] at line 672
sub File::ShareDir::ProjectDistDir::CORE:fteread; # opcode
# spent 10µs (8+1) within File::ShareDir::ProjectDistDir::CORE:ftis which was called: # once (8µs+1µs) by File::ShareDir::ProjectDistDir::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/ShareDir/ProjectDistDir.pm:676] at line 668
sub File::ShareDir::ProjectDistDir::CORE:ftis; # opcode