← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/share/perl5/Path/Class/Entity.pm
StatementsExecuted 48 statements in 757µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.55ms10.3msPath::Class::Entity::::BEGIN@9Path::Class::Entity::BEGIN@9
177295µs95µsPath::Class::Entity::::_specPath::Class::Entity::_spec
52214µs14µsPath::Class::Entity::::newPath::Class::Entity::new
11111µs46µsPath::Class::Entity::::BEGIN@10Path::Class::Entity::BEGIN@10
11110µs22µsPath::Class::Entity::::BEGIN@8Path::Class::Entity::BEGIN@8
1118µs16µsparent::::BEGIN@1 parent::BEGIN@1
1115µs38µsPath::Class::Entity::::BEGIN@14Path::Class::Entity::BEGIN@14
1113µs3µsPath::Class::Entity::::BEGIN@11Path::Class::Entity::BEGIN@11
0000s0sPath::Class::Entity::::PRUNEPath::Class::Entity::PRUNE
0000s0sPath::Class::Entity::::_spec_classPath::Class::Entity::_spec_class
0000s0sPath::Class::Entity::::absolutePath::Class::Entity::absolute
0000s0sPath::Class::Entity::::boolifyPath::Class::Entity::boolify
0000s0sPath::Class::Entity::::cleanupPath::Class::Entity::cleanup
0000s0sPath::Class::Entity::::is_absolutePath::Class::Entity::is_absolute
0000s0sPath::Class::Entity::::is_dirPath::Class::Entity::is_dir
0000s0sPath::Class::Entity::::is_relativePath::Class::Entity::is_relative
0000s0sPath::Class::Entity::::lstatPath::Class::Entity::lstat
0000s0sPath::Class::Entity::::new_foreignPath::Class::Entity::new_foreign
0000s0sPath::Class::Entity::::relativePath::Class::Entity::relative
0000s0sPath::Class::Entity::::resolvePath::Class::Entity::resolve
0000s0sPath::Class::Entity::::statPath::Class::Entity::stat
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1238µs223µs
# spent 16µs (8+8) within parent::BEGIN@1 which was called: # once (8µs+8µs) by parent::import at line 1
use strict;
# spent 16µs making 1 call to parent::BEGIN@1 # spent 8µs making 1 call to strict::import
2
3package Path::Class::Entity;
4{
52900ns $Path::Class::Entity::VERSION = '0.33';
6}
7
8337µs234µs
# spent 22µs (10+12) within Path::Class::Entity::BEGIN@8 which was called: # once (10µs+12µs) by parent::import at line 8
use File::Spec 3.26;
# spent 22µs making 1 call to Path::Class::Entity::BEGIN@8 # spent 12µs making 1 call to UNIVERSAL::VERSION
9289µs110.3ms
# spent 10.3ms (1.55+8.79) within Path::Class::Entity::BEGIN@9 which was called: # once (1.55ms+8.79ms) by parent::import at line 9
use File::stat ();
# spent 10.3ms making 1 call to Path::Class::Entity::BEGIN@9
10223µs281µs
# spent 46µs (11+35) within Path::Class::Entity::BEGIN@10 which was called: # once (11µs+35µs) by parent::import at line 10
use Cwd;
# spent 46µs making 1 call to Path::Class::Entity::BEGIN@10 # spent 35µs making 1 call to Exporter::import
11227µs13µs
# spent 3µs within Path::Class::Entity::BEGIN@11 which was called: # once (3µs+0s) by parent::import at line 11
use Carp();
# spent 3µs making 1 call to Path::Class::Entity::BEGIN@11
12
13use overload
14
# spent 38µs (5+33) within Path::Class::Entity::BEGIN@14 which was called: # once (5µs+33µs) by parent::import at line 18
(
1516µs133µs q[""] => 'stringify',
# spent 33µs making 1 call to overload::import
16 'bool' => 'boolify',
17 fallback => 1,
181396µs138µs );
# spent 38µs making 1 call to Path::Class::Entity::BEGIN@14
19
20
# spent 14µs within Path::Class::Entity::new which was called 5 times, avg 3µs/call: # 3 times (7µs+0s) by Path::Class::Dir::new at line 23 of Path/Class/Dir.pm, avg 2µs/call # 2 times (7µs+0s) by Path::Class::File::new at line 17 of Path/Class/File.pm, avg 3µs/call
sub new {
2152µs my $from = shift;
2252µs my ($class, $fs_class) = (ref($from)
23 ? (ref $from, $from->{file_spec_class})
24 : ($from, $Path::Class::Foreign));
25518µs return bless {file_spec_class => $fs_class}, $class;
26}
27
28sub is_dir { 0 }
29
30sub _spec_class {
31 my ($class, $type) = @_;
32
33 die "Invalid system type '$type'" unless ($type) = $type =~ /^(\w+)$/; # Untaint
34 my $spec = "File::Spec::$type";
35 ## no critic
36 eval "require $spec; 1" or die $@;
37 return $spec;
38}
39
40sub new_foreign {
41 my ($class, $type) = (shift, shift);
42 local $Path::Class::Foreign = $class->_spec_class($type);
43 return $class->new(@_);
44}
45
4617116µs
# spent 95µs within Path::Class::Entity::_spec which was called 17 times, avg 6µs/call: # 5 times (4µs+0s) by Path::Class::Dir::stringify at line 79 of Path/Class/Dir.pm, avg 760ns/call # 4 times (6µs+0s) by Path::Class::File::stringify at line 47 of Path/Class/File.pm, avg 1µs/call # 3 times (36µs+0s) by Path::Class::Dir::new at line 31 of Path/Class/Dir.pm, avg 12µs/call # 2 times (44µs+0s) by Path::Class::File::new at line 21 of Path/Class/File.pm, avg 22µs/call # once (2µs+0s) by Path::Class::File::BEGIN@8 at line 19 of Path/Class/Dir.pm # once (2µs+0s) by Path::Class::File::new at line 23 of Path/Class/File.pm # once (500ns+0s) by Path::Class::File::BEGIN@8 at line 20 of Path/Class/Dir.pm
sub _spec { (ref($_[0]) && $_[0]->{file_spec_class}) || 'File::Spec' }
47
48sub boolify { 1 }
49
50sub is_absolute {
51 # 5.6.0 has a bug with regexes and stringification that's ticked by
52 # file_name_is_absolute(). Help it along with an explicit stringify().
53 $_[0]->_spec->file_name_is_absolute($_[0]->stringify)
54}
55
56sub is_relative { ! $_[0]->is_absolute }
57
58sub cleanup {
59 my $self = shift;
60 my $cleaned = $self->new( $self->_spec->canonpath("$self") );
61 %$self = %$cleaned;
62 return $self;
63}
64
65sub resolve {
66 my $self = shift;
67 Carp::croak($! . " $self") unless -e $self; # No such file or directory
68 my $cleaned = $self->new( scalar Cwd::realpath($self->stringify) );
69
70 # realpath() always returns absolute path, kind of annoying
71 $cleaned = $cleaned->relative if $self->is_relative;
72
73 %$self = %$cleaned;
74 return $self;
75}
76
77sub absolute {
78 my $self = shift;
79 return $self if $self->is_absolute;
80 return $self->new($self->_spec->rel2abs($self->stringify, @_));
81}
82
83sub relative {
84 my $self = shift;
85 return $self->new($self->_spec->abs2rel($self->stringify, @_));
86}
87
88sub stat { File::stat::stat("$_[0]") }
89sub lstat { File::stat::lstat("$_[0]") }
90
91sub PRUNE { return \&PRUNE; }
92
9312µs1;
94__END__