| Filename | /usr/libdata/perl5/OpenBSD/IdCache.pm |
| Statements | Executed 1699 statements in 10.3ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 238 | 2 | 1 | 8.21ms | 9.94ms | OpenBSD::IdCache::lookup |
| 238 | 1 | 1 | 1.30ms | 1.45ms | OpenBSD::SimpleIdCache::lookup |
| 238 | 1 | 1 | 285µs | 285µs | OpenBSD::IdCache::CORE:match (opcode) |
| 2 | 1 | 1 | 63µs | 63µs | OpenBSD::GidCache::CORE:ggrnam (opcode) |
| 1 | 1 | 1 | 51µs | 51µs | OpenBSD::UidCache::CORE:gpwnam (opcode) |
| 2 | 1 | 1 | 20µs | 83µs | OpenBSD::GidCache::convert |
| 1 | 1 | 1 | 16µs | 19µs | OpenBSD::Ustar::BEGIN@17 |
| 1 | 1 | 1 | 14µs | 65µs | OpenBSD::UidCache::convert |
| 4 | 4 | 1 | 12µs | 12µs | OpenBSD::SimpleIdCache::new |
| 1 | 1 | 1 | 11µs | 18µs | OpenBSD::Ustar::BEGIN@18 |
| 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 | 26µs | 2 | 23µs | # spent 19µ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 19µs making 1 call to OpenBSD::Ustar::BEGIN@17
# spent 4µs making 1 call to strict::import |
| 18 | 2 | 347µs | 2 | 25µs | # spent 18µs (11+7) within OpenBSD::Ustar::BEGIN@18 which was called:
# once (11µs+7µs) by OpenBSD::Ustar::BEGIN@49 at line 18 # spent 18µs making 1 call to OpenBSD::Ustar::BEGIN@18
# spent 7µ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 (5µ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 55 of OpenBSD/Ustar.pm
# once (2µs+0s) by OpenBSD::PackageLocation::_opened at line 54 of OpenBSD/Ustar.pm | ||||
| 23 | 4 | 3µs | my $class = shift; | ||
| 24 | 4 | 20µs | bless {}, $class; | ||
| 25 | } | ||||
| 26 | |||||
| 27 | sub lookup | ||||
| 28 | # spent 1.45ms (1.30+148µs) within OpenBSD::SimpleIdCache::lookup which was called 238 times, avg 6µs/call:
# 238 times (1.30ms+148µs) by OpenBSD::IdCache::lookup at line 55, avg 6µs/call | ||||
| 29 | 238 | 214µs | my ($self, $name, $default) = @_; | ||
| 30 | 238 | 173µs | my $r; | ||
| 31 | |||||
| 32 | 238 | 321µs | if (defined $self->{$name}) { | ||
| 33 | $r = $self->{$name}; | ||||
| 34 | } else { | ||||
| 35 | 3 | 8µs | 3 | 148µs | $r = $self->convert($name); # spent 83µs making 2 calls to OpenBSD::GidCache::convert, avg 42µs/call
# spent 65µs making 1 call to OpenBSD::UidCache::convert |
| 36 | 3 | 2µs | if (!defined $r) { | ||
| 37 | $r = $default; | ||||
| 38 | } | ||||
| 39 | 3 | 4µs | $self->{$name} = $r; | ||
| 40 | } | ||||
| 41 | 238 | 800µs | return $r; | ||
| 42 | } | ||||
| 43 | |||||
| 44 | |||||
| 45 | package OpenBSD::IdCache; | ||||
| 46 | 1 | 6µs | our @ISA=qw(OpenBSD::SimpleIdCache); | ||
| 47 | |||||
| 48 | sub lookup | ||||
| 49 | # spent 9.94ms (8.21+1.74) within OpenBSD::IdCache::lookup which was called 238 times, avg 42µs/call:
# 119 times (6.44ms+747µs) by OpenBSD::Ustar::next at line 219 of OpenBSD/Ustar.pm, avg 60µs/call
# 119 times (1.77ms+990µs) by OpenBSD::Ustar::next at line 218 of OpenBSD/Ustar.pm, avg 23µs/call | ||||
| 50 | 238 | 258µs | my ($self, $name, $default) = @_; | ||
| 51 | |||||
| 52 | 238 | 6.43ms | 238 | 285µs | if ($name =~ m/^\d+$/o) { # spent 285µs making 238 calls to OpenBSD::IdCache::CORE:match, avg 1µs/call |
| 53 | return $name; | ||||
| 54 | } else { | ||||
| 55 | 238 | 1.56ms | 238 | 1.45ms | return $self->SUPER::lookup($name, $default); # spent 1.45ms making 238 calls to OpenBSD::SimpleIdCache::lookup, avg 6µ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 | 61µ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 83µs (20+63) within OpenBSD::GidCache::convert which was called 2 times, avg 42µs/call:
# 2 times (20µs+63µs) by OpenBSD::SimpleIdCache::lookup at line 35, avg 42µs/call | ||||
| 73 | 2 | 77µs | 2 | 63µs | my @entry = getgrnam($_[1]); # spent 63µs making 2 calls to OpenBSD::GidCache::CORE:ggrnam, avg 32µs/call |
| 74 | 2 | 8µ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 | 5µs | 1; | ||
# spent 63µs within OpenBSD::GidCache::CORE:ggrnam which was called 2 times, avg 32µs/call:
# 2 times (63µs+0s) by OpenBSD::GidCache::convert at line 73, avg 32µs/call | |||||
# spent 285µs within OpenBSD::IdCache::CORE:match which was called 238 times, avg 1µs/call:
# 238 times (285µ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 |