| Filename | /usr/libdata/perl5/OpenBSD/Temp.pm |
| Statements | Executed 79 statements in 1.15ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 384µs | 702µs | OpenBSD::Temp::BEGIN@23 |
| 3 | 2 | 1 | 204µs | 496µs | OpenBSD::Temp::file |
| 3 | 1 | 1 | 58µs | 293µs | OpenBSD::Temp::permanent_file |
| 3 | 1 | 1 | 49µs | 49µs | OpenBSD::Temp::reclaim |
| 1 | 1 | 1 | 17µs | 21µs | OpenBSD::PackageLocation::BEGIN@18 |
| 1 | 1 | 1 | 11µs | 72µs | OpenBSD::Temp::BEGIN@25 |
| 1 | 1 | 1 | 11µs | 21µs | OpenBSD::Temp::END |
| 1 | 1 | 1 | 10µs | 10µs | OpenBSD::Temp::__ANON__[:39] |
| 1 | 1 | 1 | 9µs | 16µs | OpenBSD::PackageLocation::BEGIN@19 |
| 1 | 1 | 1 | 6µs | 6µs | OpenBSD::Temp::BEGIN@24 |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::__ANON__[:49] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::__ANON__[:70] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::dir |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::permanent_dir |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # ex:ts=8 sw=4: | ||||
| 2 | # $OpenBSD: Temp.pm,v 1.27 2015/03/04 13:55:32 espie Exp $ | ||||
| 3 | # | ||||
| 4 | # Copyright (c) 2003-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 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| 17 | |||||
| 18 | 2 | 27µs | 2 | 25µs | # spent 21µs (17+4) within OpenBSD::PackageLocation::BEGIN@18 which was called:
# once (17µs+4µs) by OpenBSD::PackageLocation::BEGIN@24 at line 18 # spent 21µs making 1 call to OpenBSD::PackageLocation::BEGIN@18
# spent 4µs making 1 call to strict::import |
| 19 | 2 | 42µs | 2 | 23µs | # spent 16µs (9+7) within OpenBSD::PackageLocation::BEGIN@19 which was called:
# once (9µs+7µs) by OpenBSD::PackageLocation::BEGIN@24 at line 19 # spent 16µs making 1 call to OpenBSD::PackageLocation::BEGIN@19
# spent 7µs making 1 call to warnings::import |
| 20 | |||||
| 21 | package OpenBSD::Temp; | ||||
| 22 | |||||
| 23 | 2 | 148µs | 2 | 741µs | # spent 702µs (384+317) within OpenBSD::Temp::BEGIN@23 which was called:
# once (384µs+317µs) by OpenBSD::PackageLocation::BEGIN@24 at line 23 # spent 702µs making 1 call to OpenBSD::Temp::BEGIN@23
# spent 40µs making 1 call to Exporter::import |
| 24 | 2 | 24µs | 1 | 6µs | # spent 6µs within OpenBSD::Temp::BEGIN@24 which was called:
# once (6µs+0s) by OpenBSD::PackageLocation::BEGIN@24 at line 24 # spent 6µs making 1 call to OpenBSD::Temp::BEGIN@24 |
| 25 | 2 | 552µs | 2 | 134µs | # spent 72µs (11+62) within OpenBSD::Temp::BEGIN@25 which was called:
# once (11µs+62µs) by OpenBSD::PackageLocation::BEGIN@24 at line 25 # spent 72µs making 1 call to OpenBSD::Temp::BEGIN@25
# spent 62µs making 1 call to Exporter::import |
| 26 | |||||
| 27 | 1 | 12µs | 1 | 2µs | our $tempbase = $ENV{'PKG_TMPDIR'} || OpenBSD::Paths->vartmp; # spent 2µs making 1 call to OpenBSD::Paths::vartmp |
| 28 | |||||
| 29 | 1 | 1µs | my $dirs = {}; | ||
| 30 | 1 | 700ns | my $files = {}; | ||
| 31 | |||||
| 32 | # spent 10µs within OpenBSD::Temp::__ANON__[/usr/libdata/perl5/OpenBSD/Temp.pm:39] which was called:
# once (10µs+0s) by OpenBSD::Temp::END at line 42 | ||||
| 33 | 1 | 6µs | while (my ($name, $pid) = each %$files) { | ||
| 34 | unlink($name) if $pid == $$; | ||||
| 35 | } | ||||
| 36 | 1 | 9µs | while (my ($dir, $pid) = each %$dirs) { | ||
| 37 | OpenBSD::Error->rmtree([$dir]) if $pid == $$; | ||||
| 38 | } | ||||
| 39 | 1 | 3µs | }; | ||
| 40 | |||||
| 41 | # spent 21µs (11+10) within OpenBSD::Temp::END which was called:
# once (11µs+10µs) by main::RUNTIME at line 0 of /usr/sbin/pkg_info | ||||
| 42 | 1 | 7µs | 1 | 10µs | &$cleanup; # spent 10µs making 1 call to OpenBSD::Temp::__ANON__[OpenBSD/Temp.pm:39] |
| 43 | } | ||||
| 44 | 1 | 6µs | 1 | 6µs | OpenBSD::Handler->register($cleanup); # spent 6µs making 1 call to OpenBSD::Handler::register |
| 45 | |||||
| 46 | sub dir | ||||
| 47 | { | ||||
| 48 | my $caught; | ||||
| 49 | my $h = sub { $caught = shift; }; | ||||
| 50 | my $dir; | ||||
| 51 | |||||
| 52 | { | ||||
| 53 | local $SIG{'INT'} = $h; | ||||
| 54 | local $SIG{'QUIT'} = $h; | ||||
| 55 | local $SIG{'HUP'} = $h; | ||||
| 56 | local $SIG{'KILL'} = $h; | ||||
| 57 | local $SIG{'TERM'} = $h; | ||||
| 58 | $dir = permanent_dir($tempbase, "pkginfo"); | ||||
| 59 | $dirs->{$dir} = $$; | ||||
| 60 | } | ||||
| 61 | if (defined $caught) { | ||||
| 62 | kill $caught, $$; | ||||
| 63 | } | ||||
| 64 | return "$dir/"; | ||||
| 65 | } | ||||
| 66 | |||||
| 67 | sub file | ||||
| 68 | # spent 496µs (204+293) within OpenBSD::Temp::file which was called 3 times, avg 165µs/call:
# 2 times (98µs+143µs) by OpenBSD::PackageRepository::make_error_file at line 38 of OpenBSD/PackageRepository.pm, avg 121µs/call
# once (106µs+150µs) by OpenBSD::PackageRepository::HTTPorFTP::list at line 894 of OpenBSD/PackageRepository.pm | ||||
| 69 | 3 | 2µs | my $caught; | ||
| 70 | 3 | 20µs | my $h = sub { $caught = shift; }; | ||
| 71 | 3 | 2µs | my ($fh, $file); | ||
| 72 | |||||
| 73 | { | ||||
| 74 | 6 | 35µs | local $SIG{'INT'} = $h; | ||
| 75 | 3 | 9µs | local $SIG{'QUIT'} = $h; | ||
| 76 | 3 | 8µs | local $SIG{'HUP'} = $h; | ||
| 77 | 3 | 9µs | local $SIG{'KILL'} = $h; | ||
| 78 | 3 | 10µs | local $SIG{'TERM'} = $h; | ||
| 79 | 3 | 20µs | 3 | 293µs | ($fh, $file) = permanent_file($tempbase, "pkgout"); # spent 293µs making 3 calls to OpenBSD::Temp::permanent_file, avg 98µs/call |
| 80 | 3 | 54µs | if (defined $file) { | ||
| 81 | $files->{$file} = $$; | ||||
| 82 | } | ||||
| 83 | } | ||||
| 84 | 3 | 2µs | if (defined $caught) { | ||
| 85 | kill $caught, $$; | ||||
| 86 | } | ||||
| 87 | 3 | 35µs | return $file; | ||
| 88 | } | ||||
| 89 | |||||
| 90 | sub reclaim | ||||
| 91 | # spent 49µs within OpenBSD::Temp::reclaim which was called 3 times, avg 16µs/call:
# 3 times (49µs+0s) by OpenBSD::PackageRepository::parse_problems at line 359 of OpenBSD/PackageRepository.pm, avg 16µs/call | ||||
| 92 | 3 | 3µs | my ($class, $name) = @_; | ||
| 93 | 3 | 25µs | delete $files->{$name}; | ||
| 94 | 3 | 15µs | delete $dirs->{$name}; | ||
| 95 | } | ||||
| 96 | |||||
| 97 | sub permanent_file | ||||
| 98 | # spent 293µs (58+235) within OpenBSD::Temp::permanent_file which was called 3 times, avg 98µs/call:
# 3 times (58µs+235µs) by OpenBSD::Temp::file at line 79, avg 98µs/call | ||||
| 99 | 3 | 13µs | my ($dir, $stem) = @_; | ||
| 100 | 3 | 7µs | my $template = "$stem.XXXXXXXXXX"; | ||
| 101 | 3 | 7µs | if (defined $dir) { | ||
| 102 | $template = "$dir/$template"; | ||||
| 103 | } | ||||
| 104 | 3 | 30µs | 3 | 235µs | return OpenBSD::MkTemp::mkstemp($template); # spent 235µs making 3 calls to OpenBSD::MkTemp::mkstemp, avg 78µs/call |
| 105 | } | ||||
| 106 | |||||
| 107 | sub permanent_dir | ||||
| 108 | { | ||||
| 109 | my ($dir, $stem) = @_; | ||||
| 110 | my $template = "$stem.XXXXXXXXXX"; | ||||
| 111 | if (defined $dir) { | ||||
| 112 | $template = "$dir/$template"; | ||||
| 113 | } | ||||
| 114 | return OpenBSD::MkTemp::mkdtemp($template); | ||||
| 115 | } | ||||
| 116 | |||||
| 117 | 1 | 6µs | 1; |