← Index
NYTProf Performance Profile   « line view »
For /usr/sbin/pkg_info
  Run on Mon Aug 7 09:39:31 2017
Reported on Mon Aug 7 09:40:21 2017

Filename/usr/libdata/perl5/OpenBSD/Error.pm
StatementsExecuted 450 statements in 6.85ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
80221.16ms44.3msOpenBSD::Error::::rmtree OpenBSD::Error::rmtree
111136µs136µsOpenBSD::Handler::::reset OpenBSD::Handler::reset
44278µs78µsOpenBSD::Auto::::cache OpenBSD::Auto::cache
11159µs70µsOpenBSD::State::::BEGIN@17 OpenBSD::State::BEGIN@17
11142µs64µsOpenBSD::State::::BEGIN@18.5 OpenBSD::State::BEGIN@18.5
11134µs202µsOpenBSD::Error::::BEGIN@72 OpenBSD::Error::BEGIN@72
11129µs80µsOpenBSD::Auto::::BEGIN@29 OpenBSD::Auto::BEGIN@29
11121µs395µsOpenBSD::Error::::try OpenBSD::Error::try
22213µs13µsOpenBSD::Handler::::register OpenBSD::Handler::register
11111µs121µsOpenBSD::Auto::::__ANON__[:28] OpenBSD::Auto::__ANON__[:28]
1116µs6µsOpenBSD::Error::::dienow OpenBSD::Error::dienow
1116µs6µsOpenBSD::Error::::catchall OpenBSD::Error::catchall
0000s0sOpenBSD::Error::::Copy OpenBSD::Error::Copy
0000s0sOpenBSD::Error::::Unlink OpenBSD::Error::Unlink
0000s0sOpenBSD::Error::::catch OpenBSD::Error::catch
0000s0sOpenBSD::Error::catch::::exec OpenBSD::Error::catch::exec
0000s0sOpenBSD::Error::catchall::::execOpenBSD::Error::catchall::exec
0000s0sOpenBSD::Error::::child_error OpenBSD::Error::child_error
0000s0sOpenBSD::Error::::fillup_names OpenBSD::Error::fillup_names
0000s0sOpenBSD::Error::::find_signal OpenBSD::Error::find_signal
0000s0sOpenBSD::Error::::rethrow OpenBSD::Error::rethrow
0000s0sOpenBSD::Error::::throw OpenBSD::Error::throw
0000s0sOpenBSD::Handler::::__ANON__[:50] OpenBSD::Handler::__ANON__[:50]
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: Error.pm,v 1.32 2017/04/18 15:12:00 espie Exp $
3#
4# Copyright (c) 2004-2010 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
172124µs281µs
# spent 70µs (59+11) within OpenBSD::State::BEGIN@17 which was called: # once (59µs+11µs) by OpenBSD::State::BEGIN@88 at line 17
use strict;
# spent 70µs making 1 call to OpenBSD::State::BEGIN@17 # spent 11µs making 1 call to strict::import
182349µs286µs
# spent 64µs (42+22) within OpenBSD::State::BEGIN@18.5 which was called: # once (42µs+22µs) by OpenBSD::State::BEGIN@88 at line 18
use warnings;
# spent 64µs making 1 call to OpenBSD::State::BEGIN@18.5 # spent 22µs making 1 call to warnings::import
19
20package OpenBSD::Auto;
21sub cache(*&)
22
# spent 78µs within OpenBSD::Auto::cache which was called 4 times, avg 20µs/call: # once (35µs+0s) by main::BEGIN@22 at line 137 of OpenBSD/State.pm # once (21µs+0s) by main::BEGIN@22 at line 366 of OpenBSD/State.pm # once (15µs+0s) by OpenBSD::PackageRepository::BEGIN@30 at line 54 of OpenBSD/PackageLocation.pm # once (7µs+0s) by OpenBSD::PackageRepository::BEGIN@30 at line 68 of OpenBSD/PackageLocation.pm
{
2348µs my ($sym, $code) = @_;
24410µs my $callpkg = caller;
25
# spent 121µs (11+110) within OpenBSD::Auto::__ANON__[/usr/libdata/perl5/OpenBSD/Error.pm:28] which was called: # once (11µs+110µs) by OpenBSD::PackageRepository::parse at line 118 of OpenBSD/PackageRepository.pm
my $actual = sub {
261800ns my $self = shift;
2718µs1110µs return $self->{$sym} //= &$code($self);
# spent 110µs making 1 call to OpenBSD::State::__ANON__[OpenBSD/State.pm:137]
28419µs };
292968µs2130µs
# spent 80µs (29+50) within OpenBSD::Auto::BEGIN@29 which was called: # once (29µs+50µs) by OpenBSD::State::BEGIN@88 at line 29
no strict 'refs';
# spent 80µs making 1 call to OpenBSD::Auto::BEGIN@29 # spent 50µs making 1 call to strict::unimport
30467µs *{$callpkg."::$sym"} = $actual;
31}
32
33package OpenBSD::Handler;
34
35161µsmy $list = [];
36
37sub register
38
# spent 13µs within OpenBSD::Handler::register which was called 2 times, avg 7µs/call: # once (8µs+0s) by OpenBSD::PackageLocation::BEGIN@24 at line 44 of OpenBSD/Temp.pm # once (5µs+0s) by OpenBSD::PackageLocator::BEGIN@24 at line 91 of OpenBSD/PackageRepository.pm
{
3923µs my ($class, $code) = @_;
40217µs push(@$list, $code);
41}
42
43my $handler = sub {
44 my $sig = shift;
45 for my $c (@$list) {
46 &$c($sig);
47 }
48 $SIG{$sig} = 'DEFAULT';
49 kill $sig, $$;
50112µs};
51
52sub reset
53
# spent 136µs within OpenBSD::Handler::reset which was called: # once (136µs+0s) by OpenBSD::State::BEGIN@88 at line 61
{
54196µs $SIG{'INT'} = $handler;
55110µs $SIG{'QUIT'} = $handler;
5618µs $SIG{'HUP'} = $handler;
5719µs $SIG{'KILL'} = $handler;
58137µs $SIG{'TERM'} = $handler;
59}
60
61110µs1136µs__PACKAGE__->reset;
# spent 136µs making 1 call to OpenBSD::Handler::reset
62
63package OpenBSD::Error;
6414µsrequire Exporter;
65129µsour @ISA=qw(Exporter);
6618µsour @EXPORT=qw(Copy Unlink try throw catch catchall rethrow);
67
68our ($FileName, $Line, $FullMessage);
69
7012µsmy @signal_name = ();
71
7222.84ms2370µs
# spent 202µs (34+168) within OpenBSD::Error::BEGIN@72 which was called: # once (34µs+168µs) by OpenBSD::State::BEGIN@88 at line 72
use Carp;
# spent 202µs making 1 call to OpenBSD::Error::BEGIN@72 # spent 168µs making 1 call to Exporter::import
73
74sub fillup_names
75{
76 {
77 # XXX force autoload
78 package verylocal;
79
80 require POSIX;
81 POSIX->import(qw(signal_h));
82 }
83
84 for my $sym (keys %POSIX::) {
85 next unless $sym =~ /^SIG([A-Z].*)/;
86 my $i = eval "&POSIX::$sym()";
87 next unless defined $i;
88 $signal_name[$i] = $1;
89 }
90 # extra BSD signals
91 $signal_name[5] = 'TRAP';
92 $signal_name[7] = 'IOT';
93 $signal_name[10] = 'BUS';
94 $signal_name[12] = 'SYS';
95 $signal_name[16] = 'URG';
96 $signal_name[23] = 'IO';
97 $signal_name[24] = 'XCPU';
98 $signal_name[25] = 'XFSZ';
99 $signal_name[26] = 'VTALRM';
100 $signal_name[27] = 'PROF';
101 $signal_name[28] = 'WINCH';
102 $signal_name[29] = 'INFO';
103}
104
105sub find_signal
106{
107 my $number = shift;
108
109 if (@signal_name == 0) {
110 fillup_names();
111 }
112
113 return $signal_name[$number] || $number;
114}
115
116sub child_error
117{
118 my $error = shift // $?;
119
120 my $extra = "";
121
122 if ($error & 128) {
123 $extra = " (core dumped)";
124 }
125 if ($error & 127) {
126 return "killed by signal ". find_signal($error & 127).$extra;
127 } else {
128 return "exit(". ($error >> 8) . ")$extra";
129 }
130}
131
132sub Copy
133{
134 require File::Copy;
135
136 my $r = File::Copy::copy(@_);
137 if (!$r) {
138 print "copy(", join(',', @_),") failed: $!\n";
139 }
140 return $r;
141}
142
143sub Unlink
144{
145 my $verbose = shift;
146 my $r = unlink @_;
147 if ($r != @_) {
148 print "rm @_ failed: removed only $r targets, $!\n";
149 } elsif ($verbose) {
150 print "rm @_\n";
151 }
152 return $r;
153}
154
155sub dienow
156
# spent 6µs within OpenBSD::Error::dienow which was called: # once (6µs+0s) by OpenBSD::Error::try at line 176
{
15712µs my ($error, $handler) = @_;
15816µs if ($error) {
159 if ($error =~ m/^(.*?)(?:\s+at\s+(.*)\s+line\s+(\d+)\.?)?$/o) {
160 local $_ = $1;
161 $FileName = $2;
162 $Line = $3;
163 $FullMessage = $error;
164
165 $handler->exec($error, '', $1, $2, $3);
166 } else {
167 die "Fatal error: can't parse $error";
168 }
169 }
170}
171
172sub try(&@)
173
# spent 395µs (21+374) within OpenBSD::Error::try which was called: # once (21µs+374µs) by OpenBSD::State::do_options at line 271 of OpenBSD/State.pm
{
17412µs my ($try, $catch) = @_;
17526µs1368µs eval { &$try };
# spent 368µs making 1 call to OpenBSD::State::__ANON__[OpenBSD/State.pm:269]
17619µs16µs dienow($@, $catch);
# spent 6µs making 1 call to OpenBSD::Error::dienow
177}
178
179sub throw
180{
181 croak @_;
182
183}
184
185sub rethrow
186{
187 my $e = shift;
188 die $e if $e;
189}
190
191sub catch(&)
192{
193 bless $_[0], "OpenBSD::Error::catch";
194}
195
196sub catchall(&)
197
# spent 6µs within OpenBSD::Error::catchall which was called: # once (6µs+0s) by OpenBSD::State::do_options at line 271 of OpenBSD/State.pm
{
19818µs bless $_[0], "OpenBSD::Error::catchall";
199}
200
201sub rmtree
202
# spent 44.3ms (1.16+43.1) within OpenBSD::Error::rmtree which was called 80 times, avg 553µs/call: # 40 times (800µs+38.4ms) by OpenBSD::PackageRepository::wipe_info at line 184 of OpenBSD/PackageRepository.pm, avg 981µs/call # 40 times (357µs+4.65ms) by OpenBSD::Temp::__ANON__[/usr/libdata/perl5/OpenBSD/Temp.pm:39] at line 36 of OpenBSD/Temp.pm, avg 125µs/call
{
2038078µs my $class = shift;
2048080µs require File::Path;
2058074µs require Cwd;
206
207 # XXX make sure we live somewhere
20880855µs80527µs Cwd::getcwd() || chdir('/');
# spent 527µs making 80 calls to Cwd::getcwd, avg 7µs/call
209
21080998µs8042.6ms File::Path::rmtree(@_);
# spent 42.6ms making 80 calls to File::Path::rmtree, avg 532µs/call
211}
212
213package OpenBSD::Error::catch;
214sub exec
215{
216 my ($self, $full, $e) = @_;
217 if ($e) {
218 &$self;
219 } else {
220 die $full;
221 }
222}
223
224package OpenBSD::Error::catchall;
225sub exec
226{
227 my ($self, $full, $e) = @_;
228 &$self;
229}
230
231136µs1;