← Index
NYTProf Performance Profile   « line view »
For /usr/sbin/pkg_info
  Run on Fri Aug 4 10:12:01 2017
Reported on Fri Aug 4 10:12:17 2017

Filename/usr/libdata/perl5/OpenBSD/Temp.pm
StatementsExecuted 79 statements in 1.15ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111384µs702µsOpenBSD::Temp::::BEGIN@23 OpenBSD::Temp::BEGIN@23
321204µs496µsOpenBSD::Temp::::file OpenBSD::Temp::file
31158µs293µsOpenBSD::Temp::::permanent_file OpenBSD::Temp::permanent_file
31149µs49µsOpenBSD::Temp::::reclaim OpenBSD::Temp::reclaim
11117µs21µsOpenBSD::PackageLocation::::BEGIN@18OpenBSD::PackageLocation::BEGIN@18
11111µs72µsOpenBSD::Temp::::BEGIN@25 OpenBSD::Temp::BEGIN@25
11111µs21µsOpenBSD::Temp::::END OpenBSD::Temp::END
11110µs10µsOpenBSD::Temp::::__ANON__[:39] OpenBSD::Temp::__ANON__[:39]
1119µs16µsOpenBSD::PackageLocation::::BEGIN@19OpenBSD::PackageLocation::BEGIN@19
1116µs6µ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
18227µs225µ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
use strict;
# spent 21µs making 1 call to OpenBSD::PackageLocation::BEGIN@18 # spent 4µs making 1 call to strict::import
19242µs223µ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
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
232148µs2741µ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
use OpenBSD::MkTemp;
# spent 702µs making 1 call to OpenBSD::Temp::BEGIN@23 # spent 40µs making 1 call to Exporter::import
24224µs16µs
# spent 6µs within OpenBSD::Temp::BEGIN@24 which was called: # once (6µs+0s) by OpenBSD::PackageLocation::BEGIN@24 at line 24
use OpenBSD::Paths;
# spent 6µs making 1 call to OpenBSD::Temp::BEGIN@24
252552µs2134µ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
use OpenBSD::Error;
# spent 72µs making 1 call to OpenBSD::Temp::BEGIN@25 # spent 62µs making 1 call to Exporter::import
26
27112µs12µsour $tempbase = $ENV{'PKG_TMPDIR'} || OpenBSD::Paths->vartmp;
# spent 2µs making 1 call to OpenBSD::Paths::vartmp
28
2911µsmy $dirs = {};
301700nsmy $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
my $cleanup = sub {
3316µ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 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
END {
4217µs110µs &$cleanup;
# spent 10µs making 1 call to OpenBSD::Temp::__ANON__[OpenBSD/Temp.pm:39]
43}
4416µs16µsOpenBSD::Handler->register($cleanup);
# spent 6µ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 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
{
6932µs my $caught;
70320µs my $h = sub { $caught = shift; };
7132µs my ($fh, $file);
72
73 {
74635µs local $SIG{'INT'} = $h;
7539µs local $SIG{'QUIT'} = $h;
7638µs local $SIG{'HUP'} = $h;
7739µs local $SIG{'KILL'} = $h;
78310µs local $SIG{'TERM'} = $h;
79320µs3293µs ($fh, $file) = permanent_file($tempbase, "pkgout");
# spent 293µs making 3 calls to OpenBSD::Temp::permanent_file, avg 98µs/call
80354µs if (defined $file) {
81 $files->{$file} = $$;
82 }
83 }
8432µs if (defined $caught) {
85 kill $caught, $$;
86 }
87335µs return $file;
88}
89
90sub 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
{
9233µs my ($class, $name) = @_;
93325µs delete $files->{$name};
94315µs delete $dirs->{$name};
95}
96
97sub 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
{
99313µs my ($dir, $stem) = @_;
10037µs my $template = "$stem.XXXXXXXXXX";
10137µs if (defined $dir) {
102 $template = "$dir/$template";
103 }
104330µs3235µs return OpenBSD::MkTemp::mkstemp($template);
# spent 235µs making 3 calls to OpenBSD::MkTemp::mkstemp, avg 78µs/call
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;