Filename | /usr/local/share/perl/5.18.2/Data/OptList.pm |
Statements | Executed 271 statements in 1.46ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.29ms | 2.72ms | BEGIN@10 | Data::OptList::
7 | 3 | 2 | 228µs | 402µs | mkopt | Data::OptList::
17 | 2 | 1 | 101µs | 156µs | __is_a (recurses: max depth 1, inclusive time 66µs) | Data::OptList::
6 | 2 | 1 | 62µs | 420µs | mkopt_hash | Data::OptList::
1 | 1 | 1 | 28µs | 64µs | BEGIN@1 | Sub::Exporter::
1 | 1 | 1 | 20µs | 26µs | BEGIN@2 | Sub::Exporter::
11 | 1 | 1 | 18µs | 18µs | __ANON__[:54] | Data::OptList::
1 | 1 | 1 | 14µs | 25µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 13µs | 26µs | BEGIN@11 | Data::OptList::
1 | 1 | 1 | 9µs | 9µs | BEGIN@15 | Data::OptList::
1 | 1 | 1 | 5µs | 5µs | BEGIN@9 | Data::OptList::
0 | 0 | 0 | 0s | 0s | __ANON__[:27] | Data::OptList::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 33µs | 2 | 101µ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 # spent 64µs making 1 call to Sub::Exporter::BEGIN@1
# spent 36µs making 1 call to strict::import |
2 | 2 | 55µs | 2 | 32µ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 # spent 26µs making 1 call to Sub::Exporter::BEGIN@2
# spent 6µs making 1 call to warnings::import |
3 | package Data::OptList; | ||||
4 | { | ||||
5 | 2 | 1µs | $Data::OptList::VERSION = '0.109'; | ||
6 | } | ||||
7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
8 | |||||
9 | 2 | 25µs | 1 | 5µs | # spent 5µs within Data::OptList::BEGIN@9 which was called:
# once (5µs+0s) by Sub::Exporter::BEGIN@11 at line 9 # spent 5µs making 1 call to Data::OptList::BEGIN@9 |
10 | 2 | 222µs | 1 | 2.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 # spent 2.72ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 84µs | 2 | 38µ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 # spent 26µs making 1 call to Data::OptList::BEGIN@11
# spent 12µs making 1 call to UNIVERSAL::VERSION |
12 | |||||
13 | |||||
14 | 1 | 200ns | my %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 | ||||
16 | 1 | 8µ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 | ); | ||||
22 | 1 | 526µs | 1 | 9µs | } # spent 9µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 17 | 7µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 26 | 86µs | 17 | 108µ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 ( | ||||
30 | 9 | 75µs | 9 | 12µ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 | ||||
37 | 7 | 3µs | my ($opt_list) = shift; | ||
38 | |||||
39 | 7 | 2µs | my ($moniker, $require_unique, $must_be); # the old positional args | ||
40 | my $name_test; | ||||
41 | |||||
42 | 7 | 10µs | 1 | 900ns | 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 { | ||||
47 | 7 | 7µs | ($moniker, $require_unique, $must_be) = @_; | ||
48 | } | ||||
49 | |||||
50 | 7 | 2µs | $moniker = 'unnamed' unless defined $moniker; | ||
51 | |||||
52 | 7 | 1µs | return [] unless $opt_list; | ||
53 | |||||
54 | 18 | 58µ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 | ||
55 | |||||
56 | $opt_list = [ | ||||
57 | 7 | 16µs | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||
58 | ] if ref $opt_list eq 'HASH'; | ||||
59 | |||||
60 | 7 | 2µs | my @return; | ||
61 | 7 | 2µs | my %seen; | ||
62 | |||||
63 | 7 | 16µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
64 | 11 | 6µs | my $name = $opt_list->[$i]; | ||
65 | 11 | 2µs | my $value; | ||
66 | |||||
67 | 11 | 10µs | if ($require_unique) { | ||
68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
69 | } | ||||
70 | |||||
71 | 11 | 28µs | 11 | 18µ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; } | ||||
74 | 9 | 5µs | else { $value = $opt_list->[++$i] } | ||
75 | |||||
76 | 11 | 16µs | if ($must_be and defined $value) { | ||
77 | 8 | 11µs | 8 | 156µ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 | |||||
83 | 11 | 15µs | push @return, [ $name => $value ]; | ||
84 | } | ||||
85 | |||||
86 | 7 | 37µ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 | ||||
91 | 6 | 5µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | 6 | 7µs | return {} unless $opt_list; | ||
93 | |||||
94 | 4 | 6µs | 4 | 358µs | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 358µs making 4 calls to Data::OptList::mkopt, avg 89µs/call |
95 | 4 | 16µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
96 | 4 | 15µ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 | ||||
101 | 1 | 8µs | 1 | 11µs | *import = Sub::Install::exporter { # spent 11µs making 1 call to Sub::Install::exporter |
102 | exports => [qw(mkopt mkopt_hash)], | ||||
103 | }; | ||||
104 | 1 | 26µs | 1 | 25µs | } # spent 25µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 3µs | 1; | ||
107 | |||||
108 | __END__ |