← Index
NYTProf Performance Profile   « line view »
For index.cgi
  Run on Sat May 9 17:18:47 2020
Reported on Sat May 9 17:19:07 2020

Filename/usr/local/share/perl/5.18.2/Data/OptList.pm
StatementsExecuted 271 statements in 1.46ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.29ms2.72msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
732228µs402µsData::OptList::::mkoptData::OptList::mkopt
1721101µs156µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 66µs)
62162µs420µsData::OptList::::mkopt_hashData::OptList::mkopt_hash
11128µs64µsSub::Exporter::::BEGIN@1Sub::Exporter::BEGIN@1
11120µs26µsSub::Exporter::::BEGIN@2Sub::Exporter::BEGIN@2
111118µs18µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
11114µs25µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
11113µs26µsData::OptList::::BEGIN@11Data::OptList::BEGIN@11
1119µs9µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
1115µs5µsData::OptList::::BEGIN@9Data::OptList::BEGIN@9
0000s0sData::OptList::::__ANON__[:27]Data::OptList::__ANON__[:27]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1233µs2101µs
# spent 64µs (28+36) within Sub::Exporter::BEGIN@1 which was called: # once (28µs+36µs) by Sub::Exporter::BEGIN@11 at line 1
use strict;
# spent 64µs making 1 call to Sub::Exporter::BEGIN@1 # spent 36µs making 1 call to strict::import
2255µs232µs
# spent 26µs (20+6) within Sub::Exporter::BEGIN@2 which was called: # once (20µs+6µs) by Sub::Exporter::BEGIN@11 at line 2
use warnings;
# spent 26µs making 1 call to Sub::Exporter::BEGIN@2 # spent 6µs making 1 call to warnings::import
3package Data::OptList;
4{
521µs $Data::OptList::VERSION = '0.109';
6}
7# ABSTRACT: parse and validate simple name/value option pairs
8
9225µs15µs
# spent 5µs within Data::OptList::BEGIN@9 which was called: # once (5µs+0s) by Sub::Exporter::BEGIN@11 at line 9
use List::Util ();
# spent 5µs making 1 call to Data::OptList::BEGIN@9
102222µs12.72ms
# spent 2.72ms (2.29+425µs) within Data::OptList::BEGIN@10 which was called: # once (2.29ms+425µs) by Sub::Exporter::BEGIN@11 at line 10
use Params::Util ();
# spent 2.72ms making 1 call to Data::OptList::BEGIN@10
11384µs238µs
# spent 26µs (13+12) within Data::OptList::BEGIN@11 which was called: # once (13µs+12µs) by Sub::Exporter::BEGIN@11 at line 11
use Sub::Install 0.921 ();
# spent 26µs making 1 call to Data::OptList::BEGIN@11 # spent 12µs making 1 call to UNIVERSAL::VERSION
12
13
141200nsmy %test_for;
15
# spent 9µs within Data::OptList::BEGIN@15 which was called: # once (9µs+0s) by Sub::Exporter::BEGIN@11 at line 22
BEGIN {
1618µs %test_for = (
17 CODE => \&Params::Util::_CODELIKE, ## no critic
18 HASH => \&Params::Util::_HASHLIKE, ## no critic
19 ARRAY => \&Params::Util::_ARRAYLIKE, ## no critic
20 SCALAR => \&Params::Util::_SCALAR0, ## no critic
21 );
221526µs19µs}
# spent 9µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 156µs (101+54) within Data::OptList::__is_a which was called 17 times, avg 9µs/call: # 9 times (54µs+-54µs) by List::Util::first at line 27, avg 0s/call # 8 times (47µs+108µs) by Data::OptList::mkopt at line 77, avg 19µs/call
sub __is_a {
25177µs my ($got, $expected) = @_;
26
272686µs17108µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 108µs making 8 calls to List::Util::first, avg 14µs/call # spent 66µs making 9 calls to Data::OptList::__is_a, avg 7µs/call, recursion: max depth 1, sum of overlapping time 66µs
28
29 return defined (
30975µs912µs exists($test_for{$expected})
# spent 7µs making 7 calls to Params::Util::_CODELIKE, avg 1µs/call # spent 4µs making 1 call to Params::Util::_HASHLIKE # spent 1µs making 1 call to Params::Util::_ARRAYLIKE
31 ? $test_for{$expected}->($got)
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 402µs (228+175) within Data::OptList::mkopt which was called 7 times, avg 57µs/call: # 4 times (186µs+172µs) by Data::OptList::mkopt_hash at line 94, avg 89µs/call # 2 times (29µs+2µs) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 15µs/call # once (13µs+900ns) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm
sub mkopt {
3773µs my ($opt_list) = shift;
38
3972µs my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
42710µs1900ns if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) {
# spent 900ns making 1 call to Params::Util::_HASHLIKE
43 my $arg = $_[0];
44 ($moniker, $require_unique, $must_be, $name_test)
45 = @$arg{ qw(moniker require_unique must_be name_test) };
46 } else {
4777µs ($moniker, $require_unique, $must_be) = @_;
48 }
49
5072µs $moniker = 'unnamed' unless defined $moniker;
51
5271µs return [] unless $opt_list;
53
541858µs
# spent 18µs within Data::OptList::__ANON__[/usr/local/share/perl/5.18.2/Data/OptList.pm:54] which was called 11 times, avg 2µs/call: # 11 times (18µs+0s) by Data::OptList::mkopt at line 71, avg 2µs/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
57716µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
6072µs my @return;
6172µs my %seen;
62
63716µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64116µs my $name = $opt_list->[$i];
65112µs my $value;
66
671110µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
711128µs1118µs if ($i == $#$opt_list) { $value = undef; }
# spent 18µs making 11 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 2µs/call
72 elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ }
73 elsif ($name_test->($opt_list->[$i+1])) { $value = undef; }
7495µs else { $value = $opt_list->[++$i] }
75
761116µs if ($must_be and defined $value) {
77811µs8156µs unless (__is_a($value, $must_be)) {
# spent 156µs making 8 calls to Data::OptList::__is_a, avg 19µs/call
78 my $ref = ref $value;
79 Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 }
81 }
82
831115µs push @return, [ $name => $value ];
84 }
85
86737µs return \@return;
87}
88
89
90
# spent 420µs (62+358) within Data::OptList::mkopt_hash which was called 6 times, avg 70µs/call: # 4 times (52µs+299µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 88µs/call # 2 times (10µs+59µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 34µs/call
sub mkopt_hash {
9165µs my ($opt_list, $moniker, $must_be) = @_;
9267µs return {} unless $opt_list;
93
9446µs4358µs $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 358µs making 4 calls to Data::OptList::mkopt, avg 89µs/call
95416µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96415µs return \%hash;
97}
98
99
100
# spent 25µs (14+11) within Data::OptList::BEGIN@100 which was called: # once (14µs+11µs) by Sub::Exporter::BEGIN@11 at line 104
BEGIN {
10118µs111µs *import = Sub::Install::exporter {
# spent 11µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104126µs125µs}
# spent 25µs making 1 call to Data::OptList::BEGIN@100
105
10613µs1;
107
108__END__