← 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/PackageRepository/Installed.pm
StatementsExecuted 88 statements in 2.01ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
221147µs5.45msOpenBSD::PackageRepositoryBase::::parse_url OpenBSD::PackageRepositoryBase::parse_url
311102µs168µsOpenBSD::PackageRepositoryBase::::new_location OpenBSD::PackageRepositoryBase::new_location
64182µs169µsOpenBSD::PackageRepositoryBase::::url OpenBSD::PackageRepositoryBase::url
21152µs12.0sOpenBSD::PackageRepositoryBase::::match_locations OpenBSD::PackageRepositoryBase::match_locations
22148µs56µsOpenBSD::PackageRepositoryBase::::strip_urlscheme OpenBSD::PackageRepositoryBase::strip_urlscheme
11144µs49µsOpenBSD::PackageLocator::::BEGIN@18.13 OpenBSD::PackageLocator::BEGIN@18.13
11136µs3.06msOpenBSD::PackageRepositoryBase::::expand_locations OpenBSD::PackageRepositoryBase::expand_locations
84128µs28µsOpenBSD::PackageRepositoryBase::::CORE:match OpenBSD::PackageRepositoryBase::CORE:match (opcode)
63123µs23µsOpenBSD::PackageRepositoryBase::::CORE:subst OpenBSD::PackageRepositoryBase::CORE:subst (opcode)
31122µs28µsOpenBSD::PackageRepositoryBase::::canonicalize OpenBSD::PackageRepositoryBase::canonicalize
21113µs13µsOpenBSD::PackageRepositoryBase::::CORE:substcont OpenBSD::PackageRepositoryBase::CORE:substcont (opcode)
11112µs242µsOpenBSD::PackageRepository::Installed::::BEGIN@197OpenBSD::PackageRepository::Installed::BEGIN@197
11112µs20µsOpenBSD::PackageLocator::::BEGIN@19.14 OpenBSD::PackageLocator::BEGIN@19.14
3116µs6µsOpenBSD::PackageRepositoryBase::::locationClassName OpenBSD::PackageRepositoryBase::locationClassName
0000s0sOpenBSD::PackageRepository::Installed::::availableOpenBSD::PackageRepository::Installed::available
0000s0sOpenBSD::PackageRepository::Installed::::canonicalizeOpenBSD::PackageRepository::Installed::canonicalize
0000s0sOpenBSD::PackageRepository::Installed::::closeOpenBSD::PackageRepository::Installed::close
0000s0sOpenBSD::PackageRepository::Installed::::findOpenBSD::PackageRepository::Installed::find
0000s0sOpenBSD::PackageRepository::Installed::::grabPlistOpenBSD::PackageRepository::Installed::grabPlist
0000s0sOpenBSD::PackageRepository::Installed::::listOpenBSD::PackageRepository::Installed::list
0000s0sOpenBSD::PackageRepository::Installed::::locationClassNameOpenBSD::PackageRepository::Installed::locationClassName
0000s0sOpenBSD::PackageRepository::Installed::::make_error_fileOpenBSD::PackageRepository::Installed::make_error_file
0000s0sOpenBSD::PackageRepository::Installed::::may_existOpenBSD::PackageRepository::Installed::may_exist
0000s0sOpenBSD::PackageRepository::Installed::::newOpenBSD::PackageRepository::Installed::new
0000s0sOpenBSD::PackageRepository::Installed::::relative_urlOpenBSD::PackageRepository::Installed::relative_url
0000s0sOpenBSD::PackageRepository::Installed::::stemlistOpenBSD::PackageRepository::Installed::stemlist
0000s0sOpenBSD::PackageRepository::Installed::::urlschemeOpenBSD::PackageRepository::Installed::urlscheme
0000s0sOpenBSD::PackageRepository::Installed::::wipe_infoOpenBSD::PackageRepository::Installed::wipe_info
0000s0sOpenBSD::PackageRepositoryBase::::close_after_error OpenBSD::PackageRepositoryBase::close_after_error
0000s0sOpenBSD::PackageRepositoryBase::::close_now OpenBSD::PackageRepositoryBase::close_now
0000s0sOpenBSD::PackageRepositoryBase::::close_with_client_error OpenBSD::PackageRepositoryBase::close_with_client_error
0000s0sOpenBSD::PackageRepositoryBase::::finish_and_close OpenBSD::PackageRepositoryBase::finish_and_close
0000s0sOpenBSD::PackageRepositoryBase::::is_local_file OpenBSD::PackageRepositoryBase::is_local_file
0000s0sOpenBSD::PackageRepositoryBase::::locations_list OpenBSD::PackageRepositoryBase::locations_list
0000s0sOpenBSD::PackageRepositoryBase::::parse_fullurl OpenBSD::PackageRepositoryBase::parse_fullurl
0000s0sOpenBSD::PackageRepositoryBase::::reinitialize OpenBSD::PackageRepositoryBase::reinitialize
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: Installed.pm,v 1.38 2017/03/11 11:25:01 espie Exp $
3#
4# Copyright (c) 2007-2014 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
18258µs254µs
# spent 49µs (44+5) within OpenBSD::PackageLocator::BEGIN@18.13 which was called: # once (44µs+5µs) by OpenBSD::PackageLocator::BEGIN@24.12 at line 18
use strict;
# spent 49µs making 1 call to OpenBSD::PackageLocator::BEGIN@18.13 # spent 5µs making 1 call to strict::import
192887µs228µs
# spent 20µs (12+8) within OpenBSD::PackageLocator::BEGIN@19.14 which was called: # once (12µs+8µs) by OpenBSD::PackageLocator::BEGIN@24.12 at line 19
use warnings;
# spent 20µs making 1 call to OpenBSD::PackageLocator::BEGIN@19.14 # spent 8µs making 1 call to warnings::import
20
21# XXX: we want to be able to load PackageRepository::Installed stand-alone,
22# so we put the only common method into PackageRepositoryBase.
23#
24# later, when we load the base PackageRepository, we tweak the inheritance
25# of PackageRepository::Installed to have full access...
26
27package OpenBSD::PackageRepositoryBase;
28
291700nsmy ($version, $current);
30
31sub is_local_file
32{
33 return 0;
34}
35
36sub expand_locations
37
# spent 3.06ms (36µs+3.02) within OpenBSD::PackageRepositoryBase::expand_locations which was called: # once (36µs+3.02ms) by OpenBSD::PackageRepositoryBase::parse_url at line 67
{
3812µs my ($class, $string, $state) = @_;
3911µs require OpenBSD::Paths;
40130µs13.02ms if ($string eq '%a') {
# spent 3.02ms making 1 call to OpenBSD::Paths::machine_architecture
41 return OpenBSD::Paths->machine_architecture;
42 } elsif ($string eq '%v') {
43 return OpenBSD::Paths->os_version;
44 } elsif ($string eq '%m') {
45 return join('/',
46 'pub/OpenBSD',
47 '%c',
48 'packages',
49 OpenBSD::Paths->machine_architecture);
50 }
51}
52
53sub parse_url
54
# spent 5.45ms (147µs+5.30) within OpenBSD::PackageRepositoryBase::parse_url which was called 2 times, avg 2.72ms/call: # once (122µs+5.30ms) by OpenBSD::PackageRepository::Distant::parse_url at line 586 of OpenBSD/PackageRepository.pm # once (25µs+5µs) by OpenBSD::PackageRepository::Local::parse_fullurl at line 482 of OpenBSD/PackageRepository.pm
{
5522µs my ($class, $r, $state) = @_;
56
5721µs my $path;
58
59210µs23µs if ($$r =~ m/^(.*?)\:(.*)/) {
# spent 3µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:match, avg 1µs/call
6011µs $path = $1;
6112µs $$r = $2;
62 } else {
631900ns $path = $$r;
6411µs $$r = '';
65 }
66
67337µs53.07ms $path =~ s/\%[vam]\b/$class->expand_locations($&, $state)/ge;
# spent 3.06ms making 1 call to OpenBSD::PackageRepositoryBase::expand_locations # spent 13µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:substcont, avg 6µs/call # spent 3µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:subst, avg 2µs/call
68 # make %c magical: if we're on a release, we expand into
69 # stable, and leave the release dir for the full object with
70 # host to push back
7121µs my $release;
72220µs211µs if ($path =~ m/\%c\b/) {
# spent 11µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:match, avg 5µs/call
73136µs22.19ms my $d = $state->defines('snap') ?
# spent 2.15ms making 1 call to OpenBSD::Paths::os_directory # spent 39µs making 1 call to OpenBSD::State::defines
74 'snapshots' : OpenBSD::Paths->os_directory;
7512µs if ($d ne 'snapshots' && $path =~ m,\%c/packages/,) {
76 $release = $path;
77 $release =~ s,\%c\b,$d,;
78 $path =~ s,\%c/packages/,$d/packages-stable/,;
79 } else {
80118µs114µs $path =~ s,\%c\b,$d,;
# spent 14µs making 1 call to OpenBSD::PackageRepositoryBase::CORE:subst
81 }
82 }
83215µs29µs $path .= '/' unless $path =~ m/\/$/;
# spent 9µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:match, avg 5µs/call
84244µs bless { path => $path, release => $release, state => $state }, $class;
85}
86
87sub parse_fullurl
88{
89 my ($class, $r, $state) = @_;
90
91 $class->strip_urlscheme($r) or return undef;
92 return $class->parse_url($r, $state);
93}
94
95sub strip_urlscheme
96
# spent 56µs (48+9) within OpenBSD::PackageRepositoryBase::strip_urlscheme which was called 2 times, avg 28µs/call: # once (30µs+5µs) by OpenBSD::PackageRepository::Local::parse_fullurl at line 481 of OpenBSD/PackageRepository.pm # once (17µs+4µs) by OpenBSD::PackageRepository::parse_fullurl at line 97 of OpenBSD/PackageRepository.pm
{
9722µs my ($class, $r) = @_;
98217µs25µs if ($$r =~ m/^(.*?)\:(.*)$/) {
# spent 5µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:match, avg 2µs/call
99216µs my $scheme = lc($1);
10026µs24µs if ($scheme eq $class->urlscheme) {
# spent 2µs making 1 call to OpenBSD::PackageRepository::Local::urlscheme # spent 2µs making 1 call to OpenBSD::PackageRepository::HTTP::urlscheme
10111µs $$r = $2;
10214µs return 1;
103 }
104 }
10514µs return 0;
106}
107
108sub match_locations
109
# spent 12.0s (52µs+12.0) within OpenBSD::PackageRepositoryBase::match_locations which was called 2 times, avg 5.98s/call: # 2 times (52µs+12.0s) by OpenBSD::PackageRepositoryList::match_locations at line 84 of OpenBSD/PackageRepositoryList.pm, avg 5.98s/call
{
11022µs my ($self, $search, @filters) = @_;
111232µs212.0s my $l = $search->match_locations($self);
# spent 12.0s making 2 calls to OpenBSD::Search::match_locations, avg 5.98s/call
11224µs while (my $filter = (shift @filters)) {
113 last if @$l == 0; # don't bother filtering empty list
114 $l = $filter->filter_locations($l);
115 }
116216µs return $l;
117}
118
119sub url
120
# spent 169µs (82+87) within OpenBSD::PackageRepositoryBase::url which was called 6 times, avg 28µs/call: # 2 times (35µs+34µs) by OpenBSD::PackageRepository::unique at line 75 of OpenBSD/PackageRepository.pm, avg 34µs/call # 2 times (16µs+20µs) by OpenBSD::PackageRepository::unique at line 78 of OpenBSD/PackageRepository.pm, avg 18µs/call # once (22µs+21µs) by OpenBSD::PackageRepository::parse_problems at line 286 of OpenBSD/PackageRepository.pm # once (9µs+13µs) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 909 of OpenBSD/PackageRepository.pm
{
12165µs my ($self, $name) = @_;
122661µs1287µs return $self->urlscheme.':'.$self->relative_url($name);
# spent 72µs making 6 calls to OpenBSD::PackageRepository::relative_url, avg 12µs/call # spent 11µs making 4 calls to OpenBSD::PackageRepository::HTTP::urlscheme, avg 3µs/call # spent 4µs making 2 calls to OpenBSD::PackageRepository::Local::urlscheme, avg 2µs/call
123}
124
125sub finish_and_close
126{
127 my ($self, $object) = @_;
128 $self->close($object);
129}
130
131sub close_now
132{
133 my ($self, $object) = @_;
134 $self->close($object, 0);
135}
136
137sub close_after_error
138{
139 my ($self, $object) = @_;
140 $self->close($object, 1);
141}
142
143sub close_with_client_error
144{
145 my ($self, $object) = @_;
146 $self->close($object, 1);
147}
148
149sub canonicalize
150
# spent 28µs (22+6) within OpenBSD::PackageRepositoryBase::canonicalize which was called 3 times, avg 9µs/call: # 3 times (22µs+6µs) by OpenBSD::PackageLocation::new at line 31 of OpenBSD/PackageLocation.pm, avg 9µs/call
{
15132µs my ($self, $name) = @_;
152
15334µs if (defined $name) {
154316µs36µs $name =~ s/\.tgz$//o;
# spent 6µs making 3 calls to OpenBSD::PackageRepositoryBase::CORE:subst, avg 2µs/call
155 }
156310µs return $name;
157}
158
159sub new_location
160
# spent 168µs (102+66) within OpenBSD::PackageRepositoryBase::new_location which was called 3 times, avg 56µs/call: # 3 times (102µs+66µs) by OpenBSD::Search::match_locations at line 27 of OpenBSD/Search.pm, avg 56µs/call
{
16133µs my ($self, @args) = @_;
162
163332µs666µs return $self->locationClassName->new($self, @args);
# spent 60µs making 3 calls to OpenBSD::PackageLocation::new, avg 20µs/call # spent 6µs making 3 calls to OpenBSD::PackageRepositoryBase::locationClassName, avg 2µs/call
164}
165
166sub locationClassName
167365µs
# spent 6µs within OpenBSD::PackageRepositoryBase::locationClassName which was called 3 times, avg 2µs/call: # 3 times (6µs+0s) by OpenBSD::PackageRepositoryBase::new_location at line 163, avg 2µs/call
{ "OpenBSD::PackageLocation" }
168
169sub locations_list
170{
171 my $self = shift;
172 if (!defined $self->{locations}) {
173 my $l = [];
174 require OpenBSD::PackageLocation;
175
176 for my $name (@{$self->list}) {
177 push @$l, $self->new_location($name);
178 }
179 $self->{locations} = $l;
180 }
181 return $self->{locations};
182}
183
184sub reinitialize
185{
186}
187
188package OpenBSD::PackageRepository::Installed;
189
19018µsour @ISA = (qw(OpenBSD::PackageRepositoryBase));
191
192sub urlscheme
193{
194 return 'inst';
195}
196
19711µs
# spent 242µs (12+229) within OpenBSD::PackageRepository::Installed::BEGIN@197 which was called: # once (12µs+229µs) by OpenBSD::PackageLocator::BEGIN@24.12 at line 198
use OpenBSD::PackageInfo (qw(is_installed installed_info
1981524µs2470µs installed_packages installed_stems installed_name));
# spent 242µs making 1 call to OpenBSD::PackageRepository::Installed::BEGIN@197 # spent 229µs making 1 call to Exporter::import
199
200sub new
201{
202 my ($class, $all, $state) = @_;
203 return bless { all => $all, state => $state }, $class;
204}
205
206sub relative_url
207{
208 my ($self, $name) = @_;
209 $name or '';
210}
211
212sub close
213{
214}
215
216sub make_error_file
217{
218}
219
220sub canonicalize
221{
222 my ($self, $name) = @_;
223 return installed_name($name);
224}
225
226sub find
227{
228 my ($repository, $name, $arch) = @_;
229 my $self;
230
231 if (is_installed($name)) {
232 require OpenBSD::PackageLocation;
233
234 $self = $repository->new_location($name);
235 $self->{dir} = installed_info($name);
236 }
237 return $self;
238}
239
240sub locationClassName
241{ "OpenBSD::PackageLocation::Installed" }
242
243sub grabPlist
244{
245 my ($repository, $name, $arch, $code) = @_;
246 require OpenBSD::PackingList;
247 return OpenBSD::PackingList->from_installation($name, $code);
248}
249
250sub available
251{
252 my $self = shift;
253 return installed_packages($self->{all});
254}
255
256sub list
257{
258 my $self = shift;
259 my @list = installed_packages($self->{all});
260 return \@list;
261}
262
263sub stemlist
264{
265 return installed_stems();
266}
267
268sub wipe_info
269{
270}
271
272sub may_exist
273{
274 my ($self, $name) = @_;
275 return is_installed($name);
276}
277
27815µs1;
 
# spent 28µs within OpenBSD::PackageRepositoryBase::CORE:match which was called 8 times, avg 3µs/call: # 2 times (11µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 72, avg 5µs/call # 2 times (9µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 83, avg 5µs/call # 2 times (5µs+0s) by OpenBSD::PackageRepositoryBase::strip_urlscheme at line 98, avg 2µs/call # 2 times (3µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 59, avg 1µs/call
sub OpenBSD::PackageRepositoryBase::CORE:match; # opcode
# spent 23µs within OpenBSD::PackageRepositoryBase::CORE:subst which was called 6 times, avg 4µs/call: # 3 times (6µs+0s) by OpenBSD::PackageRepositoryBase::canonicalize at line 154, avg 2µs/call # 2 times (3µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 67, avg 2µs/call # once (14µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 80
sub OpenBSD::PackageRepositoryBase::CORE:subst; # opcode
# spent 13µs within OpenBSD::PackageRepositoryBase::CORE:substcont which was called 2 times, avg 6µs/call: # 2 times (13µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 67, avg 6µs/call
sub OpenBSD::PackageRepositoryBase::CORE:substcont; # opcode