← 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/PackageRepository/Installed.pm
StatementsExecuted 169 statements in 2.42ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1262202µs436µsOpenBSD::PackageRepositoryBase::::url OpenBSD::PackageRepositoryBase::url
833178µs395µsOpenBSD::PackageRepositoryBase::::new_location OpenBSD::PackageRepositoryBase::new_location
221170µs6.38msOpenBSD::PackageRepositoryBase::::parse_url OpenBSD::PackageRepositoryBase::parse_url
31182µs34.7msOpenBSD::PackageRepository::Installed::::findOpenBSD::PackageRepository::Installed::find
62158µs289msOpenBSD::PackageRepositoryBase::::close_now OpenBSD::PackageRepositoryBase::close_now
71149µs62µsOpenBSD::PackageRepositoryBase::::canonicalize OpenBSD::PackageRepositoryBase::canonicalize
21148µs1.27sOpenBSD::PackageRepositoryBase::::match_locations OpenBSD::PackageRepositoryBase::match_locations
22144µs53µsOpenBSD::PackageRepositoryBase::::strip_urlscheme OpenBSD::PackageRepositoryBase::strip_urlscheme
11142µs3.80msOpenBSD::PackageRepositoryBase::::expand_locations OpenBSD::PackageRepositoryBase::expand_locations
31138µs38µsOpenBSD::PackageRepository::Installed::::newOpenBSD::PackageRepository::Installed::new
103133µs33µsOpenBSD::PackageRepositoryBase::::CORE:subst OpenBSD::PackageRepositoryBase::CORE:subst (opcode)
84129µs29µsOpenBSD::PackageRepositoryBase::::CORE:match OpenBSD::PackageRepositoryBase::CORE:match (opcode)
11124µs28µsOpenBSD::PackageLocator::::BEGIN@18.13 OpenBSD::PackageLocator::BEGIN@18.13
71123µs23µsOpenBSD::PackageRepositoryBase::::locationClassName OpenBSD::PackageRepositoryBase::locationClassName
21118µs18µsOpenBSD::PackageRepositoryBase::::CORE:substcont OpenBSD::PackageRepositoryBase::CORE:substcont (opcode)
11117µs33µsOpenBSD::PackageRepository::Installed::::canonicalizeOpenBSD::PackageRepository::Installed::canonicalize
11116µs247µsOpenBSD::PackageRepository::Installed::::BEGIN@197OpenBSD::PackageRepository::Installed::BEGIN@197
11110µs17µsOpenBSD::PackageLocator::::BEGIN@19.14 OpenBSD::PackageLocator::BEGIN@19.14
1115µs5µsOpenBSD::PackageRepository::Installed::::locationClassNameOpenBSD::PackageRepository::Installed::locationClassName
2115µs5µsOpenBSD::PackageRepository::Installed::::closeOpenBSD::PackageRepository::Installed::close
1113µs3µsOpenBSD::PackageRepository::Installed::::wipe_infoOpenBSD::PackageRepository::Installed::wipe_info
0000s0sOpenBSD::PackageRepository::Installed::::availableOpenBSD::PackageRepository::Installed::available
0000s0sOpenBSD::PackageRepository::Installed::::grabPlistOpenBSD::PackageRepository::Installed::grabPlist
0000s0sOpenBSD::PackageRepository::Installed::::listOpenBSD::PackageRepository::Installed::list
0000s0sOpenBSD::PackageRepository::Installed::::make_error_fileOpenBSD::PackageRepository::Installed::make_error_file
0000s0sOpenBSD::PackageRepository::Installed::::may_existOpenBSD::PackageRepository::Installed::may_exist
0000s0sOpenBSD::PackageRepository::Installed::::relative_urlOpenBSD::PackageRepository::Installed::relative_url
0000s0sOpenBSD::PackageRepository::Installed::::stemlistOpenBSD::PackageRepository::Installed::stemlist
0000s0sOpenBSD::PackageRepository::Installed::::urlschemeOpenBSD::PackageRepository::Installed::urlscheme
0000s0sOpenBSD::PackageRepositoryBase::::close_after_error OpenBSD::PackageRepositoryBase::close_after_error
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
18228µs231µs
# spent 28µs (24+4) within OpenBSD::PackageLocator::BEGIN@18.13 which was called: # once (24µs+4µs) by OpenBSD::PackageLocator::BEGIN@24.12 at line 18
use strict;
# spent 28µs making 1 call to OpenBSD::PackageLocator::BEGIN@18.13 # spent 4µs making 1 call to strict::import
192985µs224µs
# spent 17µs (10+7) within OpenBSD::PackageLocator::BEGIN@19.14 which was called: # once (10µs+7µs) by OpenBSD::PackageLocator::BEGIN@24.12 at line 19
use warnings;
# spent 17µs making 1 call to OpenBSD::PackageLocator::BEGIN@19.14 # spent 7µ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.80ms (42µs+3.75) within OpenBSD::PackageRepositoryBase::expand_locations which was called: # once (42µs+3.75ms) by OpenBSD::PackageRepositoryBase::parse_url at line 67
{
3812µs my ($class, $string, $state) = @_;
3911µs require OpenBSD::Paths;
40135µs13.75ms if ($string eq '%a') {
# spent 3.75ms 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 6.38ms (170µs+6.21) within OpenBSD::PackageRepositoryBase::parse_url which was called 2 times, avg 3.19ms/call: # once (139µs+6.20ms) by OpenBSD::PackageRepository::Distant::parse_url at line 586 of OpenBSD/PackageRepository.pm # once (31µs+6µs) by OpenBSD::PackageRepository::Local::parse_fullurl at line 482 of OpenBSD/PackageRepository.pm
{
5522µs my ($class, $r, $state) = @_;
56
5722µ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 {
631800ns $path = $$r;
641900ns $$r = '';
65 }
66
67346µs53.82ms $path =~ s/\%[vam]\b/$class->expand_locations($&, $state)/ge;
# spent 3.80ms making 1 call to OpenBSD::PackageRepositoryBase::expand_locations # spent 18µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:substcont, avg 9µ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
7122µs my $release;
72222µs213µs if ($path =~ m/\%c\b/) {
# spent 13µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:match, avg 7µs/call
73136µs22.35ms my $d = $state->defines('snap') ?
# spent 2.31ms making 1 call to OpenBSD::Paths::os_directory # spent 38µ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 {
80123µs117µs $path =~ s,\%c\b,$d,;
# spent 17µs making 1 call to OpenBSD::PackageRepositoryBase::CORE:subst
81 }
82 }
83217µs28µs $path .= '/' unless $path =~ m/\/$/;
# spent 8µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:match, avg 4µs/call
84247µ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 53µs (44+9) within OpenBSD::PackageRepositoryBase::strip_urlscheme which was called 2 times, avg 27µs/call: # once (30µs+5µs) by OpenBSD::PackageRepository::Local::parse_fullurl at line 481 of OpenBSD/PackageRepository.pm # once (14µs+4µs) by OpenBSD::PackageRepository::parse_fullurl at line 97 of OpenBSD/PackageRepository.pm
{
9722µs my ($class, $r) = @_;
98215µs25µs if ($$r =~ m/^(.*?)\:(.*)$/) {
# spent 5µs making 2 calls to OpenBSD::PackageRepositoryBase::CORE:match, avg 2µs/call
99214µs my $scheme = lc($1);
10027µs24µs if ($scheme eq $class->urlscheme) {
# spent 2µs making 1 call to OpenBSD::PackageRepository::HTTP::urlscheme # spent 2µs making 1 call to OpenBSD::PackageRepository::Local::urlscheme
10112µs $$r = $2;
10217µs return 1;
103 }
104 }
10515µs return 0;
106}
107
108sub match_locations
109
# spent 1.27s (48µs+1.27) within OpenBSD::PackageRepositoryBase::match_locations which was called 2 times, avg 634ms/call: # 2 times (48µs+1.27s) by OpenBSD::PackageRepositoryList::match_locations at line 84 of OpenBSD/PackageRepositoryList.pm, avg 634ms/call
{
11022µs my ($self, $search, @filters) = @_;
111231µs21.27s my $l = $search->match_locations($self);
# spent 1.27s making 2 calls to OpenBSD::Search::match_locations, avg 634ms/call
11225µs while (my $filter = (shift @filters)) {
113 last if @$l == 0; # don't bother filtering empty list
114 $l = $filter->filter_locations($l);
115 }
11628µs return $l;
117}
118
119sub url
120
# spent 436µs (202+234) within OpenBSD::PackageRepositoryBase::url which was called 12 times, avg 36µs/call: # 3 times (55µs+60µs) by OpenBSD::PackageRepository::parse_problems at line 286 of OpenBSD/PackageRepository.pm, avg 38µs/call # 2 times (66µs+77µs) by OpenBSD::PackageLocation::_opened at line 88 of OpenBSD/PackageLocation.pm, avg 72µs/call # 2 times (39µs+43µs) by OpenBSD::PackageRepository::unique at line 75 of OpenBSD/PackageRepository.pm, avg 41µs/call # 2 times (16µs+23µs) by OpenBSD::PackageLocation::url at line 41 of OpenBSD/PackageLocation.pm, avg 19µs/call # 2 times (16µs+20µs) by OpenBSD::PackageRepository::unique at line 78 of OpenBSD/PackageRepository.pm, avg 18µs/call # once (11µs+12µs) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 909 of OpenBSD/PackageRepository.pm
{
1211219µs my ($self, $name) = @_;
12212153µs24234µs return $self->urlscheme.':'.$self->relative_url($name);
# spent 190µs making 12 calls to OpenBSD::PackageRepository::relative_url, avg 16µs/call # spent 41µs making 10 calls to OpenBSD::PackageRepository::HTTP::urlscheme, avg 4µs/call # spent 3µ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
# spent 289ms (58µs+289) within OpenBSD::PackageRepositoryBase::close_now which was called 6 times, avg 48.1ms/call: # 3 times (39µs+289ms) by OpenBSD::PackageLocation::close_now at line 264 of OpenBSD/PackageLocation.pm, avg 96.3ms/call # 3 times (19µs+32µs) by OpenBSD::PackageLocation::wipe_info at line 210 of OpenBSD/PackageLocation.pm, avg 17µs/call
{
13366µs my ($self, $object) = @_;
134651µs6289ms $self->close($object, 0);
# spent 289ms making 4 calls to OpenBSD::PackageRepository::close, avg 72.2ms/call # spent 5µs making 2 calls to OpenBSD::PackageRepository::Installed::close, avg 2µs/call
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 62µs (49+13) within OpenBSD::PackageRepositoryBase::canonicalize which was called 7 times, avg 9µs/call: # 7 times (49µs+13µs) by OpenBSD::PackageLocation::new at line 31 of OpenBSD/PackageLocation.pm, avg 9µs/call
{
15175µs my ($self, $name) = @_;
152
153710µs if (defined $name) {
154733µs713µs $name =~ s/\.tgz$//o;
# spent 13µs making 7 calls to OpenBSD::PackageRepositoryBase::CORE:subst, avg 2µs/call
155 }
156722µs return $name;
157}
158
159sub new_location
160
# spent 395µs (178+217) within OpenBSD::PackageRepositoryBase::new_location which was called 8 times, avg 49µs/call: # 4 times (45µs+84µs) by OpenBSD::PackageRepository::find at line 266 of OpenBSD/PackageRepository.pm, avg 32µs/call # 3 times (93µs+81µs) by OpenBSD::Search::match_locations at line 27 of OpenBSD/Search.pm, avg 58µs/call # once (40µs+52µs) by OpenBSD::PackageRepository::Installed::find at line 234
{
16189µs my ($self, @args) = @_;
162
1638106µs16217µs return $self->locationClassName->new($self, @args);
# spent 189µs making 8 calls to OpenBSD::PackageLocation::new, avg 24µs/call # spent 23µs making 7 calls to OpenBSD::PackageRepositoryBase::locationClassName, avg 3µs/call # spent 5µs making 1 call to OpenBSD::PackageRepository::Installed::locationClassName
164}
165
166sub locationClassName
167778µs
# spent 23µs within OpenBSD::PackageRepositoryBase::locationClassName which was called 7 times, avg 3µs/call: # 7 times (23µs+0s) by OpenBSD::PackageRepositoryBase::new_location at line 163, avg 3µ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 247µs (16+231) within OpenBSD::PackageRepository::Installed::BEGIN@197 which was called: # once (16µs+231µs) by OpenBSD::PackageLocator::BEGIN@24.12 at line 198
use OpenBSD::PackageInfo (qw(is_installed installed_info
1981397µs2478µs installed_packages installed_stems installed_name));
# spent 247µs making 1 call to OpenBSD::PackageRepository::Installed::BEGIN@197 # spent 231µs making 1 call to Exporter::import
199
200sub new
201
# spent 38µs within OpenBSD::PackageRepository::Installed::new which was called 3 times, avg 13µs/call: # 3 times (38µs+0s) by OpenBSD::PackageRepositoryFactory::installed at line 40 of OpenBSD/State.pm, avg 13µs/call
{
20234µs my ($class, $all, $state) = @_;
203321µs return bless { all => $all, state => $state }, $class;
204}
205
206sub relative_url
207{
208 my ($self, $name) = @_;
209 $name or '';
210}
211
212sub close
21329µs
# spent 5µs within OpenBSD::PackageRepository::Installed::close which was called 2 times, avg 2µs/call: # 2 times (5µs+0s) by OpenBSD::PackageRepositoryBase::close_now at line 134, avg 2µs/call
{
214}
215
216sub make_error_file
217{
218}
219
220sub canonicalize
221
# spent 33µs (17+16) within OpenBSD::PackageRepository::Installed::canonicalize which was called: # once (17µs+16µs) by OpenBSD::PackageLocation::new at line 31 of OpenBSD/PackageLocation.pm
{
22211µs my ($self, $name) = @_;
22319µs116µs return installed_name($name);
# spent 16µs making 1 call to OpenBSD::PackageInfo::installed_name
224}
225
226sub find
227
# spent 34.7ms (82µs+34.6) within OpenBSD::PackageRepository::Installed::find which was called 3 times, avg 11.6ms/call: # 3 times (82µs+34.6ms) by OpenBSD::PkgInfo::find_pkg_in at line 222 of OpenBSD/PkgInfo.pm, avg 11.6ms/call
{
22833µs my ($repository, $name, $arch) = @_;
22932µs my $self;
230
231321µs334.5ms if (is_installed($name)) {
# spent 34.5ms making 3 calls to OpenBSD::PackageInfo::is_installed, avg 11.5ms/call
23211µs require OpenBSD::PackageLocation;
233
234122µs193µs $self = $repository->new_location($name);
# spent 93µs making 1 call to OpenBSD::PackageRepositoryBase::new_location
235116µs155µs $self->{dir} = installed_info($name);
# spent 55µs making 1 call to OpenBSD::PackageInfo::installed_info
236 }
237312µs return $self;
238}
239
240sub locationClassName
241118µs
# spent 5µs within OpenBSD::PackageRepository::Installed::locationClassName which was called: # once (5µs+0s) by OpenBSD::PackageRepositoryBase::new_location at line 163
{ "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
269110µs
# spent 3µs within OpenBSD::PackageRepository::Installed::wipe_info which was called: # once (3µs+0s) by OpenBSD::PackageLocation::wipe_info at line 209 of OpenBSD/PackageLocation.pm
{
270}
271
272sub may_exist
273{
274 my ($self, $name) = @_;
275 return is_installed($name);
276}
277
27815µs1;
 
# spent 29µs within OpenBSD::PackageRepositoryBase::CORE:match which was called 8 times, avg 4µs/call: # 2 times (13µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 72, avg 7µs/call # 2 times (8µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 83, avg 4µ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 33µs within OpenBSD::PackageRepositoryBase::CORE:subst which was called 10 times, avg 3µs/call: # 7 times (13µ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 (17µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 80
sub OpenBSD::PackageRepositoryBase::CORE:subst; # opcode
# spent 18µs within OpenBSD::PackageRepositoryBase::CORE:substcont which was called 2 times, avg 9µs/call: # 2 times (18µs+0s) by OpenBSD::PackageRepositoryBase::parse_url at line 67, avg 9µs/call
sub OpenBSD::PackageRepositoryBase::CORE:substcont; # opcode