Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Data/OptList.pm |
Statements | Executed 2250 statements in 2.17ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.05ms | 2.81ms | BEGIN@10 | Data::OptList::
77 | 4 | 3 | 1.08ms | 1.43ms | mkopt | Data::OptList::
1 | 1 | 1 | 960µs | 1.15ms | BEGIN@11 | Data::OptList::
79 | 2 | 1 | 197µs | 294µs | __is_a (recurses: max depth 1, inclusive time 109µs) | Data::OptList::
18 | 2 | 1 | 86µs | 767µs | mkopt_hash | Data::OptList::
99 | 1 | 1 | 60µs | 60µs | __ANON__[:54] | Data::OptList::
1 | 1 | 1 | 8µs | 10µs | BEGIN@1.23 | Class::Load::
1 | 1 | 1 | 7µs | 12µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 5µs | 5µs | BEGIN@15 | Data::OptList::
1 | 1 | 1 | 4µs | 8µs | BEGIN@2 | Class::Load::
1 | 1 | 1 | 2µs | 2µ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 | 28µs | 2 | 11µs | # spent 10µs (8+2) within Class::Load::BEGIN@1.23 which was called:
# once (8µs+2µs) by Class::Load::BEGIN@10 at line 1 # spent 10µs making 1 call to Class::Load::BEGIN@1.23
# spent 2µs making 1 call to strict::import |
2 | 2 | 27µs | 2 | 12µs | # spent 8µs (4+4) within Class::Load::BEGIN@2 which was called:
# once (4µs+4µs) by Class::Load::BEGIN@10 at line 2 # spent 8µs making 1 call to Class::Load::BEGIN@2
# spent 4µs making 1 call to warnings::import |
3 | package Data::OptList; | ||||
4 | { | ||||
5 | 2 | 700ns | $Data::OptList::VERSION = '0.109'; | ||
6 | } | ||||
7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
8 | |||||
9 | 2 | 15µs | 1 | 2µs | # spent 2µs within Data::OptList::BEGIN@9 which was called:
# once (2µs+0s) by Class::Load::BEGIN@10 at line 9 # spent 2µs making 1 call to Data::OptList::BEGIN@9 |
10 | 2 | 83µs | 1 | 2.81ms | # spent 2.81ms (2.05+762µs) within Data::OptList::BEGIN@10 which was called:
# once (2.05ms+762µs) by Class::Load::BEGIN@10 at line 10 # spent 2.81ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 104µs | 2 | 1.16ms | # spent 1.15ms (960µs+192µs) within Data::OptList::BEGIN@11 which was called:
# once (960µs+192µs) by Class::Load::BEGIN@10 at line 11 # spent 1.15ms making 1 call to Data::OptList::BEGIN@11
# spent 12µs making 1 call to UNIVERSAL::VERSION |
12 | |||||
13 | |||||
14 | 1 | 100ns | my %test_for; | ||
15 | # spent 5µs within Data::OptList::BEGIN@15 which was called:
# once (5µs+0s) by Class::Load::BEGIN@10 at line 22 | ||||
16 | 1 | 5µ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 | 282µs | 1 | 5µs | } # spent 5µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 79 | 13µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 121 | 175µs | 79 | 186µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 186µs making 37 calls to List::Util::first, avg 5µs/call
# spent 109µs making 42 calls to Data::OptList::__is_a, avg 3µs/call, recursion: max depth 1, sum of overlapping time 109µs |
28 | |||||
29 | return defined ( | ||||
30 | exists($test_for{$expected}) | ||||
31 | 42 | 120µs | 42 | 19µs | ? $test_for{$expected}->($got) # spent 10µs making 33 calls to Params::Util::_CODELIKE, avg 312ns/call
# spent 5µs making 4 calls to Params::Util::_HASHLIKE, avg 1µs/call
# spent 3µs making 4 calls to Params::Util::_ARRAYLIKE, avg 825ns/call
# spent 400ns making 1 call to Params::Util::_SCALAR0 |
32 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
33 | ); | ||||
34 | } | ||||
35 | |||||
36 | # spent 1.43ms (1.08+356µs) within Data::OptList::mkopt which was called 77 times, avg 19µs/call:
# 52 times (566µs+11µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 11µs/call
# 11 times (351µs+330µs) by Data::OptList::mkopt_hash at line 94, avg 62µs/call
# 8 times (114µs+15µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 16µs/call
# 6 times (48µs+0s) by Moose::Meta::Class::superclasses at line 554 of Moose/Meta/Class.pm, avg 8µs/call | ||||
37 | 77 | 22µs | my ($opt_list) = shift; | ||
38 | |||||
39 | 77 | 15µs | my ($moniker, $require_unique, $must_be); # the old positional args | ||
40 | my $name_test; | ||||
41 | |||||
42 | 77 | 60µs | 8 | 3µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 3µs making 8 calls to Params::Util::_HASHLIKE, avg 362ns/call |
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 | 77 | 33µs | ($moniker, $require_unique, $must_be) = @_; | ||
48 | } | ||||
49 | |||||
50 | 77 | 27µs | $moniker = 'unnamed' unless defined $moniker; | ||
51 | |||||
52 | 77 | 11µs | return [] unless $opt_list; | ||
53 | |||||
54 | 176 | 224µs | # spent 60µs within Data::OptList::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Data/OptList.pm:54] which was called 99 times, avg 602ns/call:
# 99 times (60µs+0s) by Data::OptList::mkopt at line 71, avg 602ns/call | ||
55 | |||||
56 | $opt_list = [ | ||||
57 | 77 | 55µs | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||
58 | ] if ref $opt_list eq 'HASH'; | ||||
59 | |||||
60 | 77 | 11µs | my @return; | ||
61 | my %seen; | ||||
62 | |||||
63 | 77 | 115µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
64 | 150 | 35µs | my $name = $opt_list->[$i]; | ||
65 | 150 | 12µs | my $value; | ||
66 | |||||
67 | 150 | 32µs | if ($require_unique) { | ||
68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
69 | } | ||||
70 | |||||
71 | 150 | 135µs | 99 | 60µs | if ($i == $#$opt_list) { $value = undef; } # spent 60µs making 99 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 602ns/call |
72 | elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ } | ||||
73 | elsif ($name_test->($opt_list->[$i+1])) { $value = undef; } | ||||
74 | 39 | 10µs | else { $value = $opt_list->[++$i] } | ||
75 | |||||
76 | 150 | 49µs | if ($must_be and defined $value) { | ||
77 | 37 | 22µs | 37 | 294µs | unless (__is_a($value, $must_be)) { # spent 294µs making 37 calls to Data::OptList::__is_a, avg 8µs/call |
78 | my $ref = ref $value; | ||||
79 | Carp::croak "$ref-ref values are not valid in $moniker opt list"; | ||||
80 | } | ||||
81 | } | ||||
82 | |||||
83 | 150 | 97µs | push @return, [ $name => $value ]; | ||
84 | } | ||||
85 | |||||
86 | 77 | 241µs | return \@return; | ||
87 | } | ||||
88 | |||||
89 | |||||
90 | # spent 767µs (86+680) within Data::OptList::mkopt_hash which was called 18 times, avg 43µs/call:
# 12 times (72µs+570µs) by Sub::Exporter::_rewrite_build_config at line 254 of Sub/Exporter.pm, avg 53µs/call
# 6 times (14µs+111µs) by Sub::Exporter::_rewrite_build_config at line 268 of Sub/Exporter.pm, avg 21µs/call | ||||
91 | 18 | 9µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | 18 | 11µs | return {} unless $opt_list; | ||
93 | |||||
94 | 11 | 10µs | 11 | 680µs | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 680µs making 11 calls to Data::OptList::mkopt, avg 62µs/call |
95 | 11 | 34µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
96 | 11 | 22µs | return \%hash; | ||
97 | } | ||||
98 | |||||
99 | |||||
100 | # spent 12µs (7+5) within Data::OptList::BEGIN@100 which was called:
# once (7µs+5µs) by Class::Load::BEGIN@10 at line 104 | ||||
101 | 1 | 5µs | 1 | 5µs | *import = Sub::Install::exporter { # spent 5µs making 1 call to Sub::Install::exporter |
102 | exports => [qw(mkopt mkopt_hash)], | ||||
103 | }; | ||||
104 | 1 | 16µs | 1 | 12µs | } # spent 12µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 2µs | 1; | ||
107 | |||||
108 | __END__ |