| Filename | /usr/share/perl5/Path/Class/Entity.pm |
| Statements | Executed 48 statements in 757µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.55ms | 10.3ms | Path::Class::Entity::BEGIN@9 |
| 17 | 7 | 2 | 95µs | 95µs | Path::Class::Entity::_spec |
| 5 | 2 | 2 | 14µs | 14µs | Path::Class::Entity::new |
| 1 | 1 | 1 | 11µs | 46µs | Path::Class::Entity::BEGIN@10 |
| 1 | 1 | 1 | 10µs | 22µs | Path::Class::Entity::BEGIN@8 |
| 1 | 1 | 1 | 8µs | 16µs | parent::BEGIN@1 |
| 1 | 1 | 1 | 5µs | 38µs | Path::Class::Entity::BEGIN@14 |
| 1 | 1 | 1 | 3µs | 3µs | Path::Class::Entity::BEGIN@11 |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::PRUNE |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::_spec_class |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::absolute |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::boolify |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::cleanup |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::is_absolute |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::is_dir |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::is_relative |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::lstat |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::new_foreign |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::relative |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::resolve |
| 0 | 0 | 0 | 0s | 0s | Path::Class::Entity::stat |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 38µs | 2 | 23µs | # spent 16µs (8+8) within parent::BEGIN@1 which was called:
# once (8µs+8µs) by parent::import at line 1 # spent 16µs making 1 call to parent::BEGIN@1
# spent 8µs making 1 call to strict::import |
| 2 | |||||
| 3 | package Path::Class::Entity; | ||||
| 4 | { | ||||
| 5 | 2 | 900ns | $Path::Class::Entity::VERSION = '0.33'; | ||
| 6 | } | ||||
| 7 | |||||
| 8 | 3 | 37µs | 2 | 34µ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 # spent 22µs making 1 call to Path::Class::Entity::BEGIN@8
# spent 12µs making 1 call to UNIVERSAL::VERSION |
| 9 | 2 | 89µs | 1 | 10.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 # spent 10.3ms making 1 call to Path::Class::Entity::BEGIN@9 |
| 10 | 2 | 23µs | 2 | 81µ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 # spent 46µs making 1 call to Path::Class::Entity::BEGIN@10
# spent 35µs making 1 call to Exporter::import |
| 11 | 2 | 27µs | 1 | 3µs | # spent 3µs within Path::Class::Entity::BEGIN@11 which was called:
# once (3µs+0s) by parent::import at line 11 # spent 3µs making 1 call to Path::Class::Entity::BEGIN@11 |
| 12 | |||||
| 13 | use 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 | ||||
| 15 | 1 | 6µs | 1 | 33µs | q[""] => 'stringify', # spent 33µs making 1 call to overload::import |
| 16 | 'bool' => 'boolify', | ||||
| 17 | fallback => 1, | ||||
| 18 | 1 | 396µs | 1 | 38µ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 | ||||
| 21 | 5 | 2µs | my $from = shift; | ||
| 22 | 5 | 2µs | my ($class, $fs_class) = (ref($from) | ||
| 23 | ? (ref $from, $from->{file_spec_class}) | ||||
| 24 | : ($from, $Path::Class::Foreign)); | ||||
| 25 | 5 | 18µs | return bless {file_spec_class => $fs_class}, $class; | ||
| 26 | } | ||||
| 27 | |||||
| 28 | sub is_dir { 0 } | ||||
| 29 | |||||
| 30 | sub _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 | |||||
| 40 | sub new_foreign { | ||||
| 41 | my ($class, $type) = (shift, shift); | ||||
| 42 | local $Path::Class::Foreign = $class->_spec_class($type); | ||||
| 43 | return $class->new(@_); | ||||
| 44 | } | ||||
| 45 | |||||
| 46 | 17 | 116µ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 | ||
| 47 | |||||
| 48 | sub boolify { 1 } | ||||
| 49 | |||||
| 50 | sub 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 | |||||
| 56 | sub is_relative { ! $_[0]->is_absolute } | ||||
| 57 | |||||
| 58 | sub cleanup { | ||||
| 59 | my $self = shift; | ||||
| 60 | my $cleaned = $self->new( $self->_spec->canonpath("$self") ); | ||||
| 61 | %$self = %$cleaned; | ||||
| 62 | return $self; | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | sub 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 | |||||
| 77 | sub absolute { | ||||
| 78 | my $self = shift; | ||||
| 79 | return $self if $self->is_absolute; | ||||
| 80 | return $self->new($self->_spec->rel2abs($self->stringify, @_)); | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | sub relative { | ||||
| 84 | my $self = shift; | ||||
| 85 | return $self->new($self->_spec->abs2rel($self->stringify, @_)); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | sub stat { File::stat::stat("$_[0]") } | ||||
| 89 | sub lstat { File::stat::lstat("$_[0]") } | ||||
| 90 | |||||
| 91 | sub PRUNE { return \&PRUNE; } | ||||
| 92 | |||||
| 93 | 1 | 2µs | 1; | ||
| 94 | __END__ |