← 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/Getopt.pm
StatementsExecuted 34 statements in 1.79ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111456µs471µsOpenBSD::PkgInfo::::BEGIN@22OpenBSD::PkgInfo::BEGIN@22
111208µs241µsOpenBSD::Getopt::::BEGIN@37 OpenBSD::Getopt::BEGIN@37
111110µs349µsOpenBSD::Getopt::::getopts OpenBSD::Getopt::getopts
11197µs103µsOpenBSD::PkgInfo::::BEGIN@21OpenBSD::PkgInfo::BEGIN@21
11127µs27µsOpenBSD::Getopt::::CORE:regcomp OpenBSD::Getopt::CORE:regcomp (opcode)
11122µs22µsOpenBSD::Getopt::::handle_option OpenBSD::Getopt::handle_option
33114µs14µsOpenBSD::Getopt::::CORE:match OpenBSD::Getopt::CORE:match (opcode)
11112µs32µsOpenBSD::Getopt::::BEGIN@38 OpenBSD::Getopt::BEGIN@38
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: Getopt.pm,v 1.12 2012/04/10 16:57:12 espie Exp $
3#
4# Copyright (c) 2006 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#
18# This is inspired by Getopt::Std, except for the ability to invoke subs
19# on options.
20
212380µs2110µs
# spent 103µs (97+6) within OpenBSD::PkgInfo::BEGIN@21 which was called: # once (97µs+6µs) by OpenBSD::PkgInfo::BEGIN@179 at line 21
use strict;
# spent 103µs making 1 call to OpenBSD::PkgInfo::BEGIN@21 # spent 6µs making 1 call to strict::import
222467µs2486µs
# spent 471µs (456+15) within OpenBSD::PkgInfo::BEGIN@22 which was called: # once (456µs+15µs) by OpenBSD::PkgInfo::BEGIN@179 at line 22
use warnings;
# spent 471µs making 1 call to OpenBSD::PkgInfo::BEGIN@22 # spent 15µs making 1 call to warnings::import
23
24package OpenBSD::Getopt;
2511µsrequire Exporter;
26
27110µsour @ISA = qw(Exporter);
2811µsour @EXPORT = qw(getopts);
29
30sub handle_option
31
# spent 22µs within OpenBSD::Getopt::handle_option which was called: # once (22µs+0s) by OpenBSD::Getopt::getopts at line 71
{
3212µs my ($opt, $hash, $params) = @_;
33
34114µs if (defined $hash->{$opt} and ref($hash->{$opt}) eq 'CODE') {
35 &{$hash->{$opt}}($params);
36 } else {
37260µs2274µs
# spent 241µs (208+33) within OpenBSD::Getopt::BEGIN@37 which was called: # once (208µs+33µs) by OpenBSD::PkgInfo::BEGIN@179 at line 37
no strict "refs";
# spent 241µs making 1 call to OpenBSD::Getopt::BEGIN@37 # spent 33µs making 1 call to strict::unimport
382693µs251µs
# spent 32µs (12+20) within OpenBSD::Getopt::BEGIN@38 which was called: # once (12µs+20µs) by OpenBSD::PkgInfo::BEGIN@179 at line 38
no strict "vars";
# spent 32µs making 1 call to OpenBSD::Getopt::BEGIN@38 # spent 20µs making 1 call to strict::unimport
39
4013µs if (defined $params) {
4117µs ${"opt_$opt"} = $params;
4212µs $hash->{$opt} = $params;
43 } else {
44 ${"opt_$opt"}++;
45 $hash->{$opt}++;
46 }
4713µs push(@EXPORT, "\$opt_$opt");
48 }
49}
50
51sub getopts($;$)
52
# spent 349µs (110+239) within OpenBSD::Getopt::getopts which was called: # once (110µs+239µs) by OpenBSD::State::__ANON__[/usr/libdata/perl5/OpenBSD/State.pm:287] at line 286 of OpenBSD/State.pm
{
5312µs my ($args, $hash) = @_;
54
5511µs $hash = {} unless defined $hash;
56115µs local @EXPORT;
57
5813µs while ($_ = shift @ARGV) {
59113µs12µs last if /^--$/o;
# spent 2µs making 1 call to OpenBSD::Getopt::CORE:match
60114µs18µs unless (m/^-(.)(.*)/so) {
# spent 8µs making 1 call to OpenBSD::Getopt::CORE:match
61 unshift @ARGV, $_;
62 last;
63 }
6416µs my ($opt, $other) = ($1, $2);
65150µs231µs if ($args =~ m/\Q$opt\E(\:?)/) {
# spent 27µs making 1 call to OpenBSD::Getopt::CORE:regcomp # spent 4µs making 1 call to OpenBSD::Getopt::CORE:match
6613µs if ($1 eq ':') {
6713µs if ($other eq '') {
6811µs die "no argument for option -$opt" unless @ARGV;
6912µs $other = shift @ARGV;
70 }
7115µs122µs handle_option($opt, $hash, $other);
# spent 22µs making 1 call to OpenBSD::Getopt::handle_option
72 } else {
73 handle_option($opt, $hash);
74 if ($other ne '') {
75 $_ = "-$other";
76 redo;
77 }
78 }
79 } else {
80 delete $SIG{__DIE__};
81 die "Unknown option -$opt";
82 }
83 }
84112µs local $Exporter::ExportLevel = 1;
8516µs1177µs import OpenBSD::Getopt;
# spent 177µs making 1 call to Exporter::import
8617µs return $hash;
87}
88
8917µs1;
 
# spent 14µs within OpenBSD::Getopt::CORE:match which was called 3 times, avg 5µs/call: # once (8µs+0s) by OpenBSD::Getopt::getopts at line 60 # once (4µs+0s) by OpenBSD::Getopt::getopts at line 65 # once (2µs+0s) by OpenBSD::Getopt::getopts at line 59
sub OpenBSD::Getopt::CORE:match; # opcode
# spent 27µs within OpenBSD::Getopt::CORE:regcomp which was called: # once (27µs+0s) by OpenBSD::Getopt::getopts at line 65
sub OpenBSD::Getopt::CORE:regcomp; # opcode