| Filename | /usr/libdata/perl5/OpenBSD/IdCache.pm |
| Statements | Executed 56 statements in 697µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 51µs | 51µs | OpenBSD::UidCache::CORE:gpwnam (opcode) |
| 4 | 2 | 1 | 47µs | 213µs | OpenBSD::IdCache::lookup |
| 1 | 1 | 1 | 47µs | 47µs | OpenBSD::GidCache::CORE:ggrnam (opcode) |
| 4 | 1 | 1 | 37µs | 161µs | OpenBSD::SimpleIdCache::lookup |
| 1 | 1 | 1 | 16µs | 20µs | OpenBSD::Ustar::BEGIN@17 |
| 1 | 1 | 1 | 14µs | 65µs | OpenBSD::UidCache::convert |
| 1 | 1 | 1 | 13µs | 59µs | OpenBSD::GidCache::convert |
| 1 | 1 | 1 | 12µs | 20µs | OpenBSD::Ustar::BEGIN@18 |
| 4 | 4 | 1 | 12µs | 12µs | OpenBSD::SimpleIdCache::new |
| 4 | 1 | 1 | 4µs | 4µs | OpenBSD::IdCache::CORE:match (opcode) |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::GnameCache::convert |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::UnameCache::convert |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # ex:ts=8 sw=4: | ||||
| 2 | # $OpenBSD: IdCache.pm,v 1.10 2010/12/24 09:04:14 espie Exp $ | ||||
| 3 | # | ||||
| 4 | # Copyright (c) 2002-2005 Marc Espie <espie@openbsd.org> | ||||
| 5 | # | ||||
| 6 | # Permission to use, copy, modify, and distribute this software for any | ||||
| 7 | # purpose with or without fee is hereby granted, provided that the above | ||||
| 8 | # copyright notice and this permission notice appear in all copies. | ||||
| 9 | # | ||||
| 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
| 11 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
| 12 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
| 13 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
| 14 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
| 15 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
| 16 | |||||
| 17 | 2 | 31µs | 2 | 24µs | # spent 20µs (16+4) within OpenBSD::Ustar::BEGIN@17 which was called:
# once (16µs+4µs) by OpenBSD::Ustar::BEGIN@49 at line 17 # spent 20µs making 1 call to OpenBSD::Ustar::BEGIN@17
# spent 4µs making 1 call to strict::import |
| 18 | 2 | 388µs | 2 | 28µs | # spent 20µs (12+8) within OpenBSD::Ustar::BEGIN@18 which was called:
# once (12µs+8µs) by OpenBSD::Ustar::BEGIN@49 at line 18 # spent 20µs making 1 call to OpenBSD::Ustar::BEGIN@18
# spent 8µs making 1 call to warnings::import |
| 19 | |||||
| 20 | package OpenBSD::SimpleIdCache; | ||||
| 21 | sub new | ||||
| 22 | # spent 12µs within OpenBSD::SimpleIdCache::new which was called 4 times, avg 3µs/call:
# once (4µs+0s) by OpenBSD::PackageLocation::_opened at line 52 of OpenBSD/Ustar.pm
# once (3µs+0s) by OpenBSD::PackageLocation::_opened at line 53 of OpenBSD/Ustar.pm
# once (2µs+0s) by OpenBSD::PackageLocation::_opened at line 54 of OpenBSD/Ustar.pm
# once (2µs+0s) by OpenBSD::PackageLocation::_opened at line 55 of OpenBSD/Ustar.pm | ||||
| 23 | 4 | 3µs | my $class = shift; | ||
| 24 | 4 | 20µs | bless {}, $class; | ||
| 25 | } | ||||
| 26 | |||||
| 27 | sub lookup | ||||
| 28 | # spent 161µs (37+125) within OpenBSD::SimpleIdCache::lookup which was called 4 times, avg 40µs/call:
# 4 times (37µs+125µs) by OpenBSD::IdCache::lookup at line 55, avg 40µs/call | ||||
| 29 | 4 | 3µs | my ($self, $name, $default) = @_; | ||
| 30 | 4 | 3µs | my $r; | ||
| 31 | |||||
| 32 | 4 | 9µs | if (defined $self->{$name}) { | ||
| 33 | $r = $self->{$name}; | ||||
| 34 | } else { | ||||
| 35 | 2 | 5µs | 2 | 125µs | $r = $self->convert($name); # spent 65µs making 1 call to OpenBSD::UidCache::convert
# spent 59µs making 1 call to OpenBSD::GidCache::convert |
| 36 | 2 | 1µs | if (!defined $r) { | ||
| 37 | $r = $default; | ||||
| 38 | } | ||||
| 39 | 2 | 3µs | $self->{$name} = $r; | ||
| 40 | } | ||||
| 41 | 4 | 12µs | return $r; | ||
| 42 | } | ||||
| 43 | |||||
| 44 | |||||
| 45 | package OpenBSD::IdCache; | ||||
| 46 | 1 | 17µs | our @ISA=qw(OpenBSD::SimpleIdCache); | ||
| 47 | |||||
| 48 | sub lookup | ||||
| 49 | # spent 213µs (47+166) within OpenBSD::IdCache::lookup which was called 4 times, avg 53µs/call:
# 2 times (32µs+88µs) by OpenBSD::Ustar::next at line 218 of OpenBSD/Ustar.pm, avg 60µs/call
# 2 times (15µs+78µs) by OpenBSD::Ustar::next at line 219 of OpenBSD/Ustar.pm, avg 46µs/call | ||||
| 50 | 4 | 7µs | my ($self, $name, $default) = @_; | ||
| 51 | |||||
| 52 | 4 | 17µs | 4 | 4µs | if ($name =~ m/^\d+$/o) { # spent 4µs making 4 calls to OpenBSD::IdCache::CORE:match, avg 1µs/call |
| 53 | return $name; | ||||
| 54 | } else { | ||||
| 55 | 4 | 25µs | 4 | 161µs | return $self->SUPER::lookup($name, $default); # spent 161µs making 4 calls to OpenBSD::SimpleIdCache::lookup, avg 40µs/call |
| 56 | } | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | package OpenBSD::UidCache; | ||||
| 60 | 1 | 3µs | our @ISA=qw(OpenBSD::IdCache); | ||
| 61 | |||||
| 62 | sub convert | ||||
| 63 | # spent 65µs (14+51) within OpenBSD::UidCache::convert which was called:
# once (14µs+51µs) by OpenBSD::SimpleIdCache::lookup at line 35 | ||||
| 64 | 1 | 62µs | 1 | 51µs | my @entry = getpwnam($_[1]); # spent 51µs making 1 call to OpenBSD::UidCache::CORE:gpwnam |
| 65 | 1 | 6µs | return @entry == 0 ? undef : $entry[2]; | ||
| 66 | } | ||||
| 67 | |||||
| 68 | package OpenBSD::GidCache; | ||||
| 69 | 1 | 3µs | our @ISA=qw(OpenBSD::IdCache); | ||
| 70 | |||||
| 71 | sub convert | ||||
| 72 | # spent 59µs (13+47) within OpenBSD::GidCache::convert which was called:
# once (13µs+47µs) by OpenBSD::SimpleIdCache::lookup at line 35 | ||||
| 73 | 1 | 56µs | 1 | 47µs | my @entry = getgrnam($_[1]); # spent 47µs making 1 call to OpenBSD::GidCache::CORE:ggrnam |
| 74 | 1 | 5µs | return @entry == 0 ? undef : $entry[2]; | ||
| 75 | } | ||||
| 76 | |||||
| 77 | package OpenBSD::UnameCache; | ||||
| 78 | 1 | 2µs | our @ISA=qw(OpenBSD::SimpleIdCache); | ||
| 79 | |||||
| 80 | sub convert | ||||
| 81 | { | ||||
| 82 | return getpwuid($_[1]); | ||||
| 83 | } | ||||
| 84 | |||||
| 85 | package OpenBSD::GnameCache; | ||||
| 86 | 1 | 2µs | our @ISA=qw(OpenBSD::SimpleIdCache); | ||
| 87 | |||||
| 88 | sub convert | ||||
| 89 | { | ||||
| 90 | return getgrgid($_[1]); | ||||
| 91 | } | ||||
| 92 | |||||
| 93 | 1 | 14µs | 1; | ||
# spent 47µs within OpenBSD::GidCache::CORE:ggrnam which was called:
# once (47µs+0s) by OpenBSD::GidCache::convert at line 73 | |||||
# spent 4µs within OpenBSD::IdCache::CORE:match which was called 4 times, avg 1µs/call:
# 4 times (4µs+0s) by OpenBSD::IdCache::lookup at line 52, avg 1µs/call | |||||
# spent 51µs within OpenBSD::UidCache::CORE:gpwnam which was called:
# once (51µs+0s) by OpenBSD::UidCache::convert at line 64 |