← 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/PackageLocation.pm
StatementsExecuted 215 statements in 2.91ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
6216.26ms464msOpenBSD::PackageLocation::::_opened OpenBSD::PackageLocation::_opened
111800µs1.62msOpenBSD::PackageLocation::::BEGIN@24 OpenBSD::PackageLocation::BEGIN@24
722168µs263µsOpenBSD::PackageLocation::::deref OpenBSD::PackageLocation::deref
31194µs7.46msOpenBSD::PackageLocation::::wipe_info OpenBSD::PackageLocation::wipe_info
81194µs189µsOpenBSD::PackageLocation::::new OpenBSD::PackageLocation::new
31193µs289msOpenBSD::PackageLocation::::close_now OpenBSD::PackageLocation::close_now
21163µs924µsOpenBSD::PackageLocation::::find_contents OpenBSD::PackageLocation::find_contents
41159µs464msOpenBSD::PackageLocation::::contents OpenBSD::PackageLocation::contents
21151µs715µsOpenBSD::PackageLocation::::next OpenBSD::PackageLocation::next
21132µs79µsOpenBSD::PackageLocation::::url OpenBSD::PackageLocation::url
21123µs23µsOpenBSD::PackageLocation::::_set_callback OpenBSD::PackageLocation::_set_callback
52222µs22µsOpenBSD::PackageLocation::::name OpenBSD::PackageLocation::name
11117µs21µsOpenBSD::PackageRepository::::BEGIN@18 OpenBSD::PackageRepository::BEGIN@18
11116µs23µsOpenBSD::PackageRepository::::BEGIN@19 OpenBSD::PackageRepository::BEGIN@19
21115µs658µsOpenBSD::PackageLocation::::getNext OpenBSD::PackageLocation::getNext
11111µs76µsOpenBSD::PackageLocation::::BEGIN@25 OpenBSD::PackageLocation::BEGIN@25
11110µs138µsOpenBSD::PackageLocation::::BEGIN@23 OpenBSD::PackageLocation::BEGIN@23
0000s0sOpenBSD::PackageLocation::Installed::::infoOpenBSD::PackageLocation::Installed::info
0000s0sOpenBSD::PackageLocation::Installed::::plistOpenBSD::PackageLocation::Installed::plist
0000s0sOpenBSD::PackageLocation::::__ANON__[:54] OpenBSD::PackageLocation::__ANON__[:54]
0000s0sOpenBSD::PackageLocation::::__ANON__[:67] OpenBSD::PackageLocation::__ANON__[:67]
0000s0sOpenBSD::PackageLocation::::__ANON__[:68] OpenBSD::PackageLocation::__ANON__[:68]
0000s0sOpenBSD::PackageLocation::::close OpenBSD::PackageLocation::close
0000s0sOpenBSD::PackageLocation::::close_after_error OpenBSD::PackageLocation::close_after_error
0000s0sOpenBSD::PackageLocation::::close_with_client_error OpenBSD::PackageLocation::close_with_client_error
0000s0sOpenBSD::PackageLocation::::finish_and_close OpenBSD::PackageLocation::finish_and_close
0000s0sOpenBSD::PackageLocation::::forget OpenBSD::PackageLocation::forget
0000s0sOpenBSD::PackageLocation::::grabPlist OpenBSD::PackageLocation::grabPlist
0000s0sOpenBSD::PackageLocation::::grab_info OpenBSD::PackageLocation::grab_info
0000s0sOpenBSD::PackageLocation::::info OpenBSD::PackageLocation::info
0000s0sOpenBSD::PackageLocation::::plist OpenBSD::PackageLocation::plist
0000s0sOpenBSD::PackageLocation::::set_callback OpenBSD::PackageLocation::set_callback
0000s0sOpenBSD::PackageLocation::::skip OpenBSD::PackageLocation::skip
0000s0sOpenBSD::PackageLocation::::unput OpenBSD::PackageLocation::unput
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: PackageLocation.pm,v 1.51 2017/03/07 14:15:09 espie Exp $
3#
4# Copyright (c) 2003-2007 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
18228µs225µs
# spent 21µs (17+4) within OpenBSD::PackageRepository::BEGIN@18 which was called: # once (17µs+4µs) by OpenBSD::PackageRepository::BEGIN@30 at line 18
use strict;
# spent 21µs making 1 call to OpenBSD::PackageRepository::BEGIN@18 # spent 4µs making 1 call to strict::import
19243µs231µs
# spent 23µs (16+7) within OpenBSD::PackageRepository::BEGIN@19 which was called: # once (16µs+7µs) by OpenBSD::PackageRepository::BEGIN@30 at line 19
use warnings;
# spent 23µs making 1 call to OpenBSD::PackageRepository::BEGIN@19 # spent 7µs making 1 call to warnings::import
20
21package OpenBSD::PackageLocation;
22
232114µs2266µs
# spent 138µs (10+128) within OpenBSD::PackageLocation::BEGIN@23 which was called: # once (10µs+128µs) by OpenBSD::PackageRepository::BEGIN@30 at line 23
use OpenBSD::PackageInfo;
# spent 138µs making 1 call to OpenBSD::PackageLocation::BEGIN@23 # spent 128µs making 1 call to Exporter::import
242160µs11.62ms
# spent 1.62ms (800µs+824µs) within OpenBSD::PackageLocation::BEGIN@24 which was called: # once (800µs+824µs) by OpenBSD::PackageRepository::BEGIN@30 at line 24
use OpenBSD::Temp;
# spent 1.62ms making 1 call to OpenBSD::PackageLocation::BEGIN@24
2521.48ms2141µs
# spent 76µs (11+65) within OpenBSD::PackageLocation::BEGIN@25 which was called: # once (11µs+65µs) by OpenBSD::PackageRepository::BEGIN@30 at line 25
use OpenBSD::Error;
# spent 76µs making 1 call to OpenBSD::PackageLocation::BEGIN@25 # spent 65µs making 1 call to Exporter::import
26
27sub new
28
# spent 189µs (94+95) within OpenBSD::PackageLocation::new which was called 8 times, avg 24µs/call: # 8 times (94µs+95µs) by OpenBSD::PackageRepositoryBase::new_location at line 163 of OpenBSD/PackageRepository/Installed.pm, avg 24µs/call
{
2987µs my ($class, $repository, $name) = @_;
30
31844µs895µs my $self = { repository => $repository, name => $repository->canonicalize($name) };
# spent 62µs making 7 calls to OpenBSD::PackageRepositoryBase::canonicalize, avg 9µs/call # spent 33µs making 1 call to OpenBSD::PackageRepository::Installed::canonicalize
3288µs bless $self, $class;
33823µs return $self;
34
35}
36
37sub url
38
# spent 79µs (32+47) within OpenBSD::PackageLocation::url which was called 2 times, avg 39µs/call: # 2 times (32µs+47µs) by OpenBSD::PackageRepository::parse_problems at line 288 of OpenBSD/PackageRepository.pm, avg 39µs/call
{
3922µs my $self = shift;
40
41223µs447µs return $self->{repository}->url($self->name);
# spent 39µs making 2 calls to OpenBSD::PackageRepositoryBase::url, avg 19µs/call # spent 8µs making 2 calls to OpenBSD::PackageLocation::name, avg 4µs/call
42}
43
44sub name
45
# spent 22µs within OpenBSD::PackageLocation::name which was called 5 times, avg 4µs/call: # 3 times (14µs+0s) by OpenBSD::PkgInfo::parse_and_run at line 608 of OpenBSD/PkgInfo.pm, avg 5µs/call # 2 times (8µs+0s) by OpenBSD::PackageLocation::url at line 41, avg 4µs/call
{
4654µs my $self = shift;
47529µs return $self->{name};
48}
49
50OpenBSD::Auto::cache(pkgname,
51 sub {
52 my $self = shift;
53 return OpenBSD::PackageName->from_string($self->name);
5415µs113µs });
# spent 13µs making 1 call to OpenBSD::Auto::cache
55
56OpenBSD::Auto::cache(update_info,
57 sub {
58 my $self = shift;
59 if ($self->name =~ /^quirks\-/) {
60 return $self->plist;
61 }
62 return $self->plist(\&OpenBSD::PackingList::UpdateInfoOnly,
63 sub {
64 return 0 if $_[0] =~ m/^\@option\s+always-update\b/m;
65 return 1 if $_[0] =~ m/^\@(?:newgroup|newuser|cwd)\b/m;
66 return 0;
67 });
6814µs17µs });
# spent 7µs making 1 call to OpenBSD::Auto::cache
69
70
71# make sure self is opened and move to the right location if need be.
72sub _opened
73
# spent 464ms (6.26+457) within OpenBSD::PackageLocation::_opened which was called 6 times, avg 77.3ms/call: # 4 times (6.26ms+457ms) by OpenBSD::PackageLocation::contents at line 133, avg 116ms/call # 2 times (7µs+0s) by OpenBSD::PackageLocation::next at line 293, avg 3µs/call
{
7465µs my $self = shift;
75
76616µs if (defined $self->{fh}) {
77 return $self;
78 }
79422µs4454ms my $fh = $self->{repository}->open($self);
# spent 454ms making 4 calls to OpenBSD::PackageRepository::open, avg 113ms/call
8043µs if (!defined $fh) {
81 $self->{repository}->parse_problems($self->{errors}, undef,
8222µs $self) if defined $self->{errors};
8322µs undef $self->{errors};
8428µs return;
85 }
862205µs require OpenBSD::Ustar;
87235µs238µs my $archive = OpenBSD::Ustar->new($fh, $self->{repository}{state});
# spent 38µs making 2 calls to OpenBSD::Ustar::new, avg 19µs/call
88234µs4154µs $archive->set_description($self->{repository}->url($self->{name}));
# spent 143µs making 2 calls to OpenBSD::PackageRepositoryBase::url, avg 72µs/call # spent 10µs making 2 calls to OpenBSD::Ustar::set_description, avg 5µs/call
8923µs $self->{_archive} = $archive;
90224µs223µs $self->_set_callback;
# spent 23µs making 2 calls to OpenBSD::PackageLocation::_set_callback, avg 12µs/call
91
9222µs if (defined $self->{_current_name}) {
93 while (my $e = $self->{_archive}->next) {
94 if ($e->{name} eq $self->{_current_name}) {
95 $self->{_current} = $e;
96 return $self;
97 }
98 }
99 }
100211µs return $self;
101}
102
103sub _set_callback
104
# spent 23µs within OpenBSD::PackageLocation::_set_callback which was called 2 times, avg 12µs/call: # 2 times (23µs+0s) by OpenBSD::PackageLocation::_opened at line 90, avg 12µs/call
{
10522µs my $self = shift;
106211µs if (defined $self->{callback} && defined $self->{_archive}) {
107 $self->{_archive}->set_callback($self->{callback});
108 }
109}
110
111sub find_contents
112
# spent 924µs (63+861) within OpenBSD::PackageLocation::find_contents which was called 2 times, avg 462µs/call: # 2 times (63µs+861µs) by OpenBSD::PackageLocation::contents at line 143, avg 462µs/call
{
11322µs my ($self, $extra) = @_;
114
115215µs2715µs while (my $e = $self->next) {
# spent 715µs making 2 calls to OpenBSD::PackageLocation::next, avg 358µs/call
116224µs421µs if ($e->isFile && is_info_name($e->{name})) {
# spent 19µs making 2 calls to OpenBSD::PackageInfo::is_info_name, avg 10µs/call # spent 2µs making 2 calls to OpenBSD::Ustar::File::isFile, avg 950ns/call
11723µs if ($e->{name} eq CONTENTS ) {
118 my $v =
119216µs2124µs $self->{extra_content}.$e->contents($extra);
# spent 124µs making 2 calls to OpenBSD::Ustar::File::contents, avg 62µs/call
120214µs return $v;
121 }
122 } else {
123 $self->unput;
124 last;
125 }
126 }
127}
128
129sub contents
130
# spent 464ms (59µs+464) within OpenBSD::PackageLocation::contents which was called 4 times, avg 116ms/call: # 4 times (59µs+464ms) by OpenBSD::PackageRepository::find at line 268 of OpenBSD/PackageRepository.pm, avg 116ms/call
{
13144µs my ($self, $extra) = @_;
13246µs if (!defined $self->{contents}) {
133419µs4464ms if (!$self->_opened) {
# spent 464ms making 4 calls to OpenBSD::PackageLocation::_opened, avg 116ms/call
134 return;
135 }
13622µs if (defined $extra) {
137 my $contents = $self->find_contents($extra);
138 if ($contents) {
139 $self->unput;
140 }
141 return $contents;
142 }
14329µs2924µs $self->{contents} = $self->find_contents;
# spent 924µs making 2 calls to OpenBSD::PackageLocation::find_contents, avg 462µs/call
144 }
145
14628µs return $self->{contents};
147}
148
149sub grab_info
150{
151 my $self = shift;
152 my $dir = $self->{dir} = OpenBSD::Temp->dir;
153
154 my $c = $self->contents;
155 if (!defined $c) {
156 return 0;
157 }
158
159 if (! -f $dir.CONTENTS) {
160 open my $fh, '>', $dir.CONTENTS or die "Permission denied";
161 print $fh $self->contents;
162 close $fh;
163 }
164
165 while (my $e = $self->next) {
166 if ($e->isFile && is_info_name($e->{name})) {
167 $e->{name} = $dir.$e->{name};
168 undef $e->{mtime};
169 undef $e->{atime};
170 eval { $e->create; };
171 if ($@) {
172 unlink($e->{name});
173 $@ =~ s/\s+at.*//o;
174 $self->{repository}{state}->errprint('#1', $@);
175 return 0;
176 }
177 } else {
178 $self->unput;
179 last;
180 }
181 }
182 return 1;
183}
184
185sub grabPlist
186{
187 my ($self, $code) = @_;
188
189 my $plist = $self->plist($code);
190 if (defined $plist) {
191 $self->wipe_info;
192 $self->close_now;
193 return $plist;
194 } else {
195 return;
196 }
197}
198
199sub forget
200{
201 my $self = shift;
202 $self->wipe_info;
203 $self->close_now;
204}
205
206sub wipe_info
207
# spent 7.46ms (94µs+7.36) within OpenBSD::PackageLocation::wipe_info which was called 3 times, avg 2.49ms/call: # 3 times (94µs+7.36ms) by OpenBSD::PkgInfo::find_pkg_in at line 226 of OpenBSD/PkgInfo.pm, avg 2.49ms/call
{
20832µs my $self = shift;
209324µs37.30ms $self->{repository}->wipe_info($self);
# spent 7.30ms making 2 calls to OpenBSD::PackageRepository::wipe_info, avg 3.65ms/call # spent 3µs making 1 call to OpenBSD::PackageRepository::Installed::wipe_info
210312µs351µs $self->{repository}->close_now($self);
# spent 51µs making 3 calls to OpenBSD::PackageRepositoryBase::close_now, avg 17µs/call
21134µs delete $self->{contents};
212310µs313µs $self->deref;
# spent 13µs making 3 calls to OpenBSD::PackageLocation::deref, avg 4µs/call
21333µs delete $self->{_current_name};
21433µs delete $self->{update_info};
215316µs delete $self->{_unput};
216}
217
218sub info
219{
220 my $self = shift;
221
222 if (!defined $self->{dir}) {
223 $self->grab_info;
224 }
225 return $self->{dir};
226}
227
228sub plist
229{
230 my ($self, $code, $extra) = @_;
231 require OpenBSD::PackingList;
232
233 if (defined $self->{dir} && -f $self->{dir}.CONTENTS) {
234 my $plist =
235 OpenBSD::PackingList->fromfile($self->{dir}.CONTENTS,
236 $code);
237 $plist->set_infodir($self->{dir});
238 return $plist;
239 }
240 if (my $value = $self->contents($extra)) {
241 return OpenBSD::PackingList->fromfile(\$value, $code);
242 }
243 # hopeless
244 $self->close_with_client_error;
245
246 return;
247}
248
249sub close
250{
251 my ($self, $hint) = @_;
252 $self->{repository}->close($self, $hint);
253}
254
255sub finish_and_close
256{
257 my $self = shift;
258 $self->{repository}->finish_and_close($self);
259}
260
261sub close_now
262
# spent 289ms (93µs+289) within OpenBSD::PackageLocation::close_now which was called 3 times, avg 96.3ms/call: # 3 times (93µs+289ms) by OpenBSD::PkgInfo::find_pkg_in at line 225 of OpenBSD/PkgInfo.pm, avg 96.3ms/call
{
26333µs my $self = shift;
264387µs3289ms $self->{repository}->close_now($self);
# spent 289ms making 3 calls to OpenBSD::PackageRepositoryBase::close_now, avg 96.3ms/call
265}
266
267sub close_after_error
268{
269 my $self = shift;
270 $self->{repository}->close_after_error($self);
271}
272
273sub close_with_client_error
274{
275 my $self = shift;
276 $self->{repository}->close_with_client_error($self);
277}
278
279sub deref
280
# spent 263µs (168+94) within OpenBSD::PackageLocation::deref which was called 7 times, avg 38µs/call: # 4 times (155µs+94µs) by OpenBSD::PackageRepository::close at line 220 of OpenBSD/PackageRepository.pm, avg 62µs/call # 3 times (13µs+0s) by OpenBSD::PackageLocation::wipe_info at line 212, avg 4µs/call
{
28175µs my $self = shift;
28277µs delete $self->{fh};
28376µs delete $self->{pid2};
28476µs delete $self->{_archive};
2857178µs494µs delete $self->{_current};
# spent 70µs making 2 calls to IO::Uncompress::Base::DESTROY, avg 35µs/call # spent 24µs making 2 calls to Compress::Raw::Zlib::inflateStream::DESTROY, avg 12µs/call
286}
287
288# proxy for archive operations
289sub next
290
# spent 715µs (51+664) within OpenBSD::PackageLocation::next which was called 2 times, avg 358µs/call: # 2 times (51µs+664µs) by OpenBSD::PackageLocation::find_contents at line 115, avg 358µs/call
{
29122µs my $self = shift;
292
29326µs27µs if (!$self->_opened) {
# spent 7µs making 2 calls to OpenBSD::PackageLocation::_opened, avg 3µs/call
294 return;
295 }
29624µs if (!$self->{_unput}) {
29728µs2658µs $self->{_current} = $self->getNext;
# spent 658µs making 2 calls to OpenBSD::PackageLocation::getNext, avg 329µs/call
29826µs if (defined $self->{_current}) {
299 $self->{_current_name} = $self->{_current}{name};
300 } else {
301 delete $self->{_current_name};
302 }
303 } else {
304 $self->{_unput} = 0;
305 }
306210µs return $self->{_current};
307}
308
309sub unput
310{
311 my $self = shift;
312 $self->{_unput} = 1;
313}
314
315sub getNext
316
# spent 658µs (15+642) within OpenBSD::PackageLocation::getNext which was called 2 times, avg 329µs/call: # 2 times (15µs+642µs) by OpenBSD::PackageLocation::next at line 297, avg 329µs/call
{
31722µs my $self = shift;
318
319221µs2642µs return $self->{_archive}->next;
# spent 642µs making 2 calls to OpenBSD::Ustar::next, avg 321µs/call
320}
321
322sub skip
323{
324 my $self = shift;
325 return $self->{_archive}->skip;
326}
327
328sub set_callback
329{
330 my ($self, $code) = @_;
331 $self->{callback} = $code;
332 $self->_set_callback;
333}
334
335package OpenBSD::PackageLocation::Installed;
33617µsour @ISA = qw(OpenBSD::PackageLocation);
337
338
339sub info
340{
341 my $self = shift;
342 require OpenBSD::PackageInfo;
343 $self->{dir} = OpenBSD::PackageInfo::installed_info($self->name);
344}
345
346sub plist
347{
348 my ($self, $code) = @_;
349 require OpenBSD::PackingList;
350 return OpenBSD::PackingList->from_installation($self->name, $code);
351}
352
35316µs1;