← Index
NYTProf Performance Profile   « line view »
For /usr/sbin/pkg_info
  Run on Fri Aug 4 10:15:59 2017
Reported on Fri Aug 4 10:16:18 2017

Filename/usr/libdata/perl5/OpenBSD/Temp.pm
StatementsExecuted 39 statements in 952µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111373µs679µsOpenBSD::Temp::::BEGIN@23 OpenBSD::Temp::BEGIN@23
11194µs234µsOpenBSD::Temp::::file OpenBSD::Temp::file
11121µs140µsOpenBSD::Temp::::permanent_file OpenBSD::Temp::permanent_file
11119µs19µsOpenBSD::Temp::::reclaim OpenBSD::Temp::reclaim
11116µs19µsOpenBSD::PackageLocation::::BEGIN@18OpenBSD::PackageLocation::BEGIN@18
11115µs15µsOpenBSD::Temp::::__ANON__[:39] OpenBSD::Temp::__ANON__[:39]
11112µs26µsOpenBSD::Temp::::END OpenBSD::Temp::END
11111µs76µsOpenBSD::Temp::::BEGIN@25 OpenBSD::Temp::BEGIN@25
1118µs16µsOpenBSD::PackageLocation::::BEGIN@19OpenBSD::PackageLocation::BEGIN@19
1117µs7µsOpenBSD::Temp::::BEGIN@24 OpenBSD::Temp::BEGIN@24
0000s0sOpenBSD::Temp::::__ANON__[:49] OpenBSD::Temp::__ANON__[:49]
0000s0sOpenBSD::Temp::::__ANON__[:70] OpenBSD::Temp::__ANON__[:70]
0000s0sOpenBSD::Temp::::dir OpenBSD::Temp::dir
0000s0sOpenBSD::Temp::::permanent_dir OpenBSD::Temp::permanent_dir
Call graph for these subroutines as a Graphviz dot language file.
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
18225µs223µs
# spent 19µs (16+4) within OpenBSD::PackageLocation::BEGIN@18 which was called: # once (16µs+4µs) by OpenBSD::PackageLocation::BEGIN@24 at line 18
use strict;
# spent 19µs making 1 call to OpenBSD::PackageLocation::BEGIN@18 # spent 4µs making 1 call to strict::import
19231µs223µs
# spent 16µs (8+7) within OpenBSD::PackageLocation::BEGIN@19 which was called: # once (8µs+7µs) by OpenBSD::PackageLocation::BEGIN@24 at line 19
use warnings;
# spent 16µs making 1 call to OpenBSD::PackageLocation::BEGIN@19 # spent 7µs making 1 call to warnings::import
20
21package OpenBSD::Temp;
22
232144µs2718µs
# spent 679µs (373+306) within OpenBSD::Temp::BEGIN@23 which was called: # once (373µs+306µs) by OpenBSD::PackageLocation::BEGIN@24 at line 23
use OpenBSD::MkTemp;
# spent 679µs making 1 call to OpenBSD::Temp::BEGIN@23 # spent 40µs making 1 call to Exporter::import
24225µs17µs
# spent 7µs within OpenBSD::Temp::BEGIN@24 which was called: # once (7µs+0s) by OpenBSD::PackageLocation::BEGIN@24 at line 24
use OpenBSD::Paths;
# spent 7µs making 1 call to OpenBSD::Temp::BEGIN@24
252541µs2141µs
# spent 76µs (11+65) within OpenBSD::Temp::BEGIN@25 which was called: # once (11µs+65µs) by OpenBSD::PackageLocation::BEGIN@24 at line 25
use OpenBSD::Error;
# spent 76µs making 1 call to OpenBSD::Temp::BEGIN@25 # spent 65µs making 1 call to Exporter::import
26
27111µs12µsour $tempbase = $ENV{'PKG_TMPDIR'} || OpenBSD::Paths->vartmp;
# spent 2µs making 1 call to OpenBSD::Paths::vartmp
28
2911µsmy $dirs = {};
301800nsmy $files = {};
31
32
# spent 15µs within OpenBSD::Temp::__ANON__[/usr/libdata/perl5/OpenBSD/Temp.pm:39] which was called: # once (15µs+0s) by OpenBSD::Temp::END at line 42
my $cleanup = sub {
3319µs while (my ($name, $pid) = each %$files) {
34 unlink($name) if $pid == $$;
35 }
3619µs while (my ($dir, $pid) = each %$dirs) {
37 OpenBSD::Error->rmtree([$dir]) if $pid == $$;
38 }
3913µs};
40
41
# spent 26µs (12+15) within OpenBSD::Temp::END which was called: # once (12µs+15µs) by main::RUNTIME at line 0 of /usr/sbin/pkg_info
END {
4219µs115µs &$cleanup;
# spent 15µs making 1 call to OpenBSD::Temp::__ANON__[OpenBSD/Temp.pm:39]
43}
4415µs15µsOpenBSD::Handler->register($cleanup);
# spent 5µs making 1 call to OpenBSD::Handler::register
45
46sub 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
67sub file
68
# spent 234µs (94+140) within OpenBSD::Temp::file which was called: # once (94µs+140µs) by OpenBSD::PackageRepository::HTTPorFTP::list at line 894 of OpenBSD/PackageRepository.pm
{
691900ns my $caught;
70111µs my $h = sub { $caught = shift; };
711900ns my ($fh, $file);
72
73 {
74225µs local $SIG{'INT'} = $h;
7513µs local $SIG{'QUIT'} = $h;
7613µs local $SIG{'HUP'} = $h;
7713µs local $SIG{'KILL'} = $h;
7814µs local $SIG{'TERM'} = $h;
7918µs1140µs ($fh, $file) = permanent_file($tempbase, "pkgout");
# spent 140µs making 1 call to OpenBSD::Temp::permanent_file
80122µs if (defined $file) {
81 $files->{$file} = $$;
82 }
83 }
841900ns if (defined $caught) {
85 kill $caught, $$;
86 }
87117µs return $file;
88}
89
90sub reclaim
91
# spent 19µs within OpenBSD::Temp::reclaim which was called: # once (19µs+0s) by OpenBSD::PackageRepository::parse_problems at line 359 of OpenBSD/PackageRepository.pm
{
9212µs my ($class, $name) = @_;
9317µs delete $files->{$name};
9417µs delete $dirs->{$name};
95}
96
97sub permanent_file
98
# spent 140µs (21+120) within OpenBSD::Temp::permanent_file which was called: # once (21µs+120µs) by OpenBSD::Temp::file at line 79
{
9913µs my ($dir, $stem) = @_;
10012µs my $template = "$stem.XXXXXXXXXX";
10112µs if (defined $dir) {
102 $template = "$dir/$template";
103 }
104111µs1120µs return OpenBSD::MkTemp::mkstemp($template);
# spent 120µs making 1 call to OpenBSD::MkTemp::mkstemp
105}
106
107sub 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
11716µs1;