| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev/Object.pm |
| Statements | Executed 183 statements in 1.59ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 785µs | 1.28ms | Path::FindDev::Object::__ANON__[:47] |
| 1 | 1 | 1 | 196µs | 108ms | Path::FindDev::Object::find_dev |
| 11 | 1 | 1 | 152µs | 107ms | Path::FindDev::Object::_step |
| 12 | 3 | 1 | 28µs | 28µs | Path::FindDev::Object::_debug |
| 1 | 1 | 1 | 19µs | 341µs | Path::FindDev::Object::BEGIN@40 |
| 10 | 1 | 1 | 16µs | 16µs | Path::FindDev::Object::has_uplevel_max |
| 1 | 1 | 1 | 16µs | 16µs | Path::FindDev::BEGIN@1 |
| 1 | 1 | 1 | 9µs | 11µs | Path::FindDev::BEGIN@4 |
| 1 | 1 | 1 | 7µs | 11µs | Path::FindDev::BEGIN@3 |
| 1 | 1 | 1 | 6µs | 18µs | Path::FindDev::BEGIN@2 |
| 1 | 1 | 1 | 5µs | 5µs | Path::FindDev::Object::has_set |
| 1 | 1 | 1 | 2µs | 2µs | Path::FindDev::Object::BUILD |
| 0 | 0 | 0 | 0s | 0s | Path::FindDev::Object::__ANON__[:43] |
| 0 | 0 | 0 | 0s | 0s | Path::FindDev::Object::_error |
| 0 | 0 | 0 | 0s | 0s | Path::FindDev::Object::_instance_id |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 40µs | 1 | 16µs | # spent 16µs within Path::FindDev::BEGIN@1 which was called:
# once (16µs+0s) by Path::FindDev::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev.pm:81] at line 1 # spent 16µs making 1 call to Path::FindDev::BEGIN@1 |
| 2 | 2 | 23µs | 2 | 30µs | # spent 18µs (6+12) within Path::FindDev::BEGIN@2 which was called:
# once (6µs+12µs) by Path::FindDev::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev.pm:81] at line 2 # spent 18µs making 1 call to Path::FindDev::BEGIN@2
# spent 12µs making 1 call to strict::import |
| 3 | 2 | 22µs | 2 | 15µs | # spent 11µs (7+4) within Path::FindDev::BEGIN@3 which was called:
# once (7µs+4µs) by Path::FindDev::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev.pm:81] at line 3 # spent 11µs making 1 call to Path::FindDev::BEGIN@3
# spent 4µs making 1 call to warnings::import |
| 4 | 2 | 132µs | 2 | 13µs | # spent 11µs (9+2) within Path::FindDev::BEGIN@4 which was called:
# once (9µs+2µs) by Path::FindDev::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev.pm:81] at line 4 # spent 11µs making 1 call to Path::FindDev::BEGIN@4
# spent 2µs making 1 call to utf8::import |
| 5 | |||||
| 6 | package Path::FindDev::Object; | ||||
| 7 | 1 | 600ns | $Path::FindDev::Object::VERSION = '0.5.0'; | ||
| 8 | # ABSTRACT: Object oriented guts to FindDev | ||||
| 9 | |||||
| 10 | 1 | 200ns | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | ||
| 11 | |||||
| 12 | 1 | 100ns | our $ENV_KEY_DEBUG = 'PATH_FINDDEV_DEBUG'; | ||
| 13 | 1 | 700ns | our $DEBUG = ( exists $ENV{$ENV_KEY_DEBUG} ? $ENV{$ENV_KEY_DEBUG} : undef ); | ||
| 14 | |||||
| - - | |||||
| 40 | # spent 341µs (19+322) within Path::FindDev::Object::BEGIN@40 which was called:
# once (19µs+322µs) by Path::FindDev::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev.pm:81] at line 48 | ||||
| 41 | nest_retry => sub { | ||||
| 42 | return 0; | ||||
| 43 | }, | ||||
| 44 | # spent 1.28ms (785µs+497µs) within Path::FindDev::Object::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev/Object.pm:47] which was called:
# once (785µs+497µs) by Path::FindDev::Object::isdev at line 1 of (eval 287)[Class/Tiny.pm:56] | ||||
| 45 | 1 | 60µs | require Path::IsDev::Object; | ||
| 46 | 1 | 9µs | 2 | 45µs | return Path::IsDev::Object->new( ( $_[0]->has_set ? ( set => $_[0]->set ) : () ) ); # spent 40µs making 1 call to Class::Tiny::Object::new
# spent 5µs making 1 call to Path::FindDev::Object::has_set |
| 47 | }, | ||||
| 48 | 3 | 536µs | 3 | 662µs | }; # spent 341µs making 1 call to Path::FindDev::Object::BEGIN@40
# spent 314µs making 1 call to Class::Tiny::import
# spent 8µs making 1 call to UNIVERSAL::VERSION |
| 49 | |||||
| - - | |||||
| 58 | ## no critic (RequireArgUnpacking) | ||||
| 59 | |||||
| - - | |||||
| 66 | 1 | 9µs | # spent 5µs within Path::FindDev::Object::has_set which was called:
# once (5µs+0s) by Path::FindDev::Object::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev/Object.pm:47] at line 46 | ||
| 67 | |||||
| - - | |||||
| 82 | 10 | 26µs | # spent 16µs within Path::FindDev::Object::has_uplevel_max which was called 10 times, avg 2µs/call:
# 10 times (16µs+0s) by Path::FindDev::Object::_step at line 210, avg 2µs/call | ||
| 83 | |||||
| - - | |||||
| 101 | 1 | 500ns | my $instances = {}; | ||
| 102 | 1 | 100ns | my $instance_id = 0; | ||
| 103 | |||||
| - - | |||||
| 117 | sub _instance_id { | ||||
| 118 | my ($self) = @_; | ||||
| 119 | require Scalar::Util; | ||||
| 120 | my $addr = Scalar::Util::refaddr($self); | ||||
| 121 | return $instances->{$addr} if exists $instances->{$addr}; | ||||
| 122 | $instances->{$addr} = sprintf '%x', $instance_id++; | ||||
| 123 | return $instances->{$addr}; | ||||
| 124 | } | ||||
| 125 | |||||
| - - | |||||
| 135 | # spent 2µs within Path::FindDev::Object::BUILD which was called:
# once (2µs+0s) by Class::Tiny::Object::new at line 126 of Class/Tiny.pm | ||||
| 136 | 1 | 200ns | my ($self) = @_; | ||
| 137 | 1 | 4µs | return $self unless $DEBUG; | ||
| 138 | $self->_debug('{'); | ||||
| 139 | $self->_debug( ' set => ' . $self->set ) if $self->has_set; | ||||
| 140 | $self->_debug( ' uplevel_max => ' . $self->uplevel_max ) if $self->uplevel_max; | ||||
| 141 | $self->_debug( ' nest_retry => ' . $self->nest_retry ); | ||||
| 142 | $self->_debug( ' isdev => ' . $self->isdev ); | ||||
| 143 | $self->_debug('}'); | ||||
| 144 | return $self; | ||||
| 145 | } | ||||
| 146 | |||||
| - - | |||||
| 159 | # spent 28µs within Path::FindDev::Object::_debug which was called 12 times, avg 2µs/call:
# 10 times (25µs+0s) by Path::FindDev::Object::find_dev at line 237, avg 3µs/call
# once (2µs+0s) by Path::FindDev::Object::_step at line 207
# once (2µs+0s) by Path::FindDev::Object::find_dev at line 230 | ||||
| 160 | 12 | 5µs | my ( $self, $message ) = @_; | ||
| 161 | 12 | 28µs | return unless $DEBUG; | ||
| 162 | my $id = $self->_instance_id; | ||||
| 163 | return *STDERR->printf( qq{[Path::FindDev=%s] %s\n}, $id, $message ); | ||||
| 164 | } | ||||
| 165 | |||||
| - - | |||||
| 174 | sub _error { | ||||
| 175 | my ( $self, $message ) = @_; | ||||
| 176 | my $id = $self->_instance_id; | ||||
| 177 | my $f_message = sprintf qq{[Path::FindDev=%s] %s\n}, $id, $message; | ||||
| 178 | require Carp; | ||||
| 179 | Carp::croak($f_message); | ||||
| 180 | } | ||||
| 181 | |||||
| - - | |||||
| 197 | # spent 107ms (152µs+107) within Path::FindDev::Object::_step which was called 11 times, avg 9.76ms/call:
# 11 times (152µs+107ms) by Path::FindDev::Object::find_dev at line 235, avg 9.76ms/call | ||||
| 198 | 11 | 4µs | my ( $self, $search_root, $dev_levels, $uplevels ) = @_; | ||
| 199 | |||||
| 200 | 11 | 475µs | 33 | 107ms | if ( $self->isdev->matches($search_root) ) { # spent 106ms making 11 calls to Path::IsDev::Object::matches, avg 9.61ms/call
# spent 1.31ms making 11 calls to Path::FindDev::Object::isdev, avg 119µs/call
# spent 71µs making 11 calls to Class::Tiny::Object::DESTROY, avg 6µs/call |
| 201 | $self->_debug( 'Found dev dir' . $search_root ); | ||||
| 202 | ${$dev_levels}++; | ||||
| 203 | return { type => 'found', path => $search_root } if ${$dev_levels} >= $self->nest_retry; | ||||
| 204 | $self->_debug( sprintf 'Ignoring found dev dir due to dev_levels(%s) < nest_retry(%s)', ${$dev_levels}, $self->nest_retry ); | ||||
| 205 | } | ||||
| 206 | 11 | 19µs | 11 | 221µs | if ( $search_root->is_rootdir ) { # spent 221µs making 11 calls to Path::Tiny::is_rootdir, avg 20µs/call |
| 207 | 1 | 2µs | 1 | 2µs | $self->_debug('OS Root hit ( ->is_rootdir )'); # spent 2µs making 1 call to Path::FindDev::Object::_debug |
| 208 | 1 | 3µs | return { type => 'stop' }; | ||
| 209 | } | ||||
| 210 | 10 | 16µs | 10 | 16µs | if ( $self->has_uplevel_max and ${$uplevels} > $self->uplevel_max ) { # spent 16µs making 10 calls to Path::FindDev::Object::has_uplevel_max, avg 2µs/call |
| 211 | $self->_debug( 'Stopping search due to uplevels(%s) >= uplevel_max(%s)', ${$uplevels}, $self->uplevel_max ); | ||||
| 212 | return { type => 'stop' }; | ||||
| 213 | } | ||||
| 214 | |||||
| 215 | 10 | 31µs | return { type => 'next' }; | ||
| 216 | } | ||||
| 217 | |||||
| - - | |||||
| 226 | # spent 108ms (196µs+108) within Path::FindDev::Object::find_dev which was called:
# once (196µs+108ms) by Path::FindDev::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Path/FindDev.pm:81] at line 80 of Path/FindDev.pm | ||||
| 227 | 1 | 200ns | my ( $self, $path ) = @_; | ||
| 228 | 1 | 200ns | require Path::Tiny; | ||
| 229 | 1 | 4µs | 3 | 127µs | my $search_root = Path::Tiny::path($path)->absolute->realpath; # spent 87µs making 1 call to Path::Tiny::realpath
# spent 31µs making 1 call to Path::Tiny::absolute
# spent 10µs making 1 call to Path::Tiny::path |
| 230 | 1 | 4µs | 2 | 3µs | $self->_debug( 'Finding dev for ' . $path ); # spent 2µs making 1 call to Path::FindDev::Object::_debug
# spent 2µs making 1 call to Path::Tiny::__ANON__[Path/Tiny.pm:31] |
| 231 | 1 | 200ns | my $dev_levels = 0; | ||
| 232 | 1 | 100ns | my $uplevels = 0 - 1; | ||
| 233 | 11 | 2µs | FLOW: { | ||
| 234 | 1 | 100ns | $uplevels++; | ||
| 235 | 11 | 19µs | 11 | 107ms | my $result = $self->_step( $search_root, \$dev_levels, \$uplevels ); # spent 107ms making 11 calls to Path::FindDev::Object::_step, avg 9.76ms/call |
| 236 | 11 | 6µs | if ( 'next' eq $result->{type} ) { | ||
| 237 | 10 | 68µs | 30 | 318µs | $self->_debug( 'Trying ../ : ' . $search_root->parent ); # spent 279µs making 10 calls to Path::Tiny::parent, avg 28µs/call
# spent 25µs making 10 calls to Path::FindDev::Object::_debug, avg 3µs/call
# spent 14µs making 10 calls to Path::Tiny::__ANON__[Path/Tiny.pm:31], avg 1µs/call |
| 238 | 10 | 20µs | 10 | 227µs | $search_root = $search_root->parent; # spent 227µs making 10 calls to Path::Tiny::parent, avg 23µs/call |
| 239 | 10 | 11µs | redo FLOW; | ||
| 240 | } | ||||
| 241 | 1 | 8µs | if ( 'stop' eq $result->{type} ) { | ||
| 242 | return; | ||||
| 243 | } | ||||
| 244 | if ( 'found' eq $result->{type} ) { | ||||
| 245 | return $result->{path}; | ||||
| 246 | } | ||||
| 247 | $self->_error( 'Unexpected end of flow control with _step response type' . $result->{type} ); | ||||
| 248 | } | ||||
| 249 | return; | ||||
| 250 | } | ||||
| 251 | 1 | 4µs | 1; | ||
| 252 | |||||
| 253 | __END__ |