← 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/Getopt.pm
StatementsExecuted 34 statements in 542µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11165µs181µsOpenBSD::Getopt::::getopts OpenBSD::Getopt::getopts
11117µs21µsOpenBSD::PkgInfo::::BEGIN@21OpenBSD::PkgInfo::BEGIN@21
11116µs25µsOpenBSD::PkgInfo::::BEGIN@22OpenBSD::PkgInfo::BEGIN@22
11112µs12µsOpenBSD::Getopt::::handle_option OpenBSD::Getopt::handle_option
11110µs10µsOpenBSD::Getopt::::CORE:regcomp OpenBSD::Getopt::CORE:regcomp (opcode)
1119µs28µsOpenBSD::Getopt::::BEGIN@37 OpenBSD::Getopt::BEGIN@37
1118µs25µsOpenBSD::Getopt::::BEGIN@38 OpenBSD::Getopt::BEGIN@38
3316µs6µsOpenBSD::Getopt::::CORE:match OpenBSD::Getopt::CORE:match (opcode)
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
21230µs225µs
# spent 21µs (17+4) within OpenBSD::PkgInfo::BEGIN@21 which was called: # once (17µs+4µs) by OpenBSD::PkgInfo::BEGIN@179 at line 21
use strict;
# spent 21µs making 1 call to OpenBSD::PkgInfo::BEGIN@21 # spent 4µs making 1 call to strict::import
22281µs234µs
# spent 25µs (16+9) within OpenBSD::PkgInfo::BEGIN@22 which was called: # once (16µs+9µs) by OpenBSD::PkgInfo::BEGIN@179 at line 22
use warnings;
# spent 25µs making 1 call to OpenBSD::PkgInfo::BEGIN@22 # spent 9µs making 1 call to warnings::import
23
24package OpenBSD::Getopt;
2511µsrequire Exporter;
26
2716µsour @ISA = qw(Exporter);
2811µsour @EXPORT = qw(getopts);
29
30sub handle_option
31
# spent 12µs within OpenBSD::Getopt::handle_option which was called: # once (12µs+0s) by OpenBSD::Getopt::getopts at line 71
{
3211µs my ($opt, $hash, $params) = @_;
33
3418µs if (defined $hash->{$opt} and ref($hash->{$opt}) eq 'CODE') {
35 &{$hash->{$opt}}($params);
36 } else {
37235µs248µs
# spent 28µs (9+19) within OpenBSD::Getopt::BEGIN@37 which was called: # once (9µs+19µs) by OpenBSD::PkgInfo::BEGIN@179 at line 37
no strict "refs";
# spent 28µs making 1 call to OpenBSD::Getopt::BEGIN@37 # spent 19µs making 1 call to strict::unimport
382292µs241µs
# spent 25µs (8+16) within OpenBSD::Getopt::BEGIN@38 which was called: # once (8µs+16µs) by OpenBSD::PkgInfo::BEGIN@179 at line 38
no strict "vars";
# spent 25µs making 1 call to OpenBSD::Getopt::BEGIN@38 # spent 16µs making 1 call to strict::unimport
39
4011µs if (defined $params) {
4113µs ${"opt_$opt"} = $params;
4211µs $hash->{$opt} = $params;
43 } else {
44 ${"opt_$opt"}++;
45 $hash->{$opt}++;
46 }
4711µs push(@EXPORT, "\$opt_$opt");
48 }
49}
50
51sub getopts($;$)
52
# spent 181µs (65+116) within OpenBSD::Getopt::getopts which was called: # once (65µs+116µs) by OpenBSD::State::__ANON__[/usr/libdata/perl5/OpenBSD/State.pm:287] at line 286 of OpenBSD/State.pm
{
531700ns my ($args, $hash) = @_;
54
551800ns $hash = {} unless defined $hash;
5619µs local @EXPORT;
57
5812µs while ($_ = shift @ARGV) {
5917µs11µs last if /^--$/o;
# spent 1µs making 1 call to OpenBSD::Getopt::CORE:match
6016µs12µs unless (m/^-(.)(.*)/so) {
# spent 2µs making 1 call to OpenBSD::Getopt::CORE:match
61 unshift @ARGV, $_;
62 last;
63 }
6412µs my ($opt, $other) = ($1, $2);
65123µs212µs if ($args =~ m/\Q$opt\E(\:?)/) {
# spent 10µs making 1 call to OpenBSD::Getopt::CORE:regcomp # spent 2µs making 1 call to OpenBSD::Getopt::CORE:match
6612µs if ($1 eq ':') {
6712µs if ($other eq '') {
681800ns die "no argument for option -$opt" unless @ARGV;
6911µs $other = shift @ARGV;
70 }
7113µs112µs handle_option($opt, $hash, $other);
# spent 12µ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 }
8419µs local $Exporter::ExportLevel = 1;
8513µs189µs import OpenBSD::Getopt;
# spent 89µs making 1 call to Exporter::import
8614µs return $hash;
87}
88
8915µs1;
 
# spent 6µs within OpenBSD::Getopt::CORE:match which was called 3 times, avg 2µs/call: # once (2µs+0s) by OpenBSD::Getopt::getopts at line 60 # once (2µs+0s) by OpenBSD::Getopt::getopts at line 65 # once (1µs+0s) by OpenBSD::Getopt::getopts at line 59
sub OpenBSD::Getopt::CORE:match; # opcode
# spent 10µs within OpenBSD::Getopt::CORE:regcomp which was called: # once (10µs+0s) by OpenBSD::Getopt::getopts at line 65
sub OpenBSD::Getopt::CORE:regcomp; # opcode