Filename | /opt/perl-5.18.1/lib/site_perl/5.18.1/Data/OptList.pm |
Statements | Executed 1385 statements in 2.91ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 5.88ms | 8.13ms | BEGIN@10 | Data::OptList::
1 | 1 | 1 | 1.57ms | 1.87ms | BEGIN@11 | Data::OptList::
32 | 4 | 3 | 1.11ms | 1.78ms | mkopt | Data::OptList::
78 | 2 | 1 | 398µs | 559µs | __is_a (recurses: max depth 1, inclusive time 226µs) | Data::OptList::
12 | 2 | 1 | 123µs | 1.41ms | mkopt_hash | Data::OptList::
81 | 1 | 1 | 106µs | 106µs | __ANON__[:54] | Data::OptList::
1 | 1 | 1 | 17µs | 26µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 14µs | 30µs | BEGIN@1 | Class::Load::
1 | 1 | 1 | 9µs | 14µs | BEGIN@2 | Class::Load::
1 | 1 | 1 | 7µs | 7µs | BEGIN@15 | Data::OptList::
1 | 1 | 1 | 4µs | 4µ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 | 30µs | 2 | 46µs | # spent 30µs (14+16) within Class::Load::BEGIN@1 which was called:
# once (14µs+16µs) by Class::Load::BEGIN@8 at line 1 # spent 30µs making 1 call to Class::Load::BEGIN@1
# spent 16µs making 1 call to strict::import |
2 | 2 | 49µs | 2 | 19µs | # spent 14µs (9+5) within Class::Load::BEGIN@2 which was called:
# once (9µs+5µs) by Class::Load::BEGIN@8 at line 2 # spent 14µs making 1 call to Class::Load::BEGIN@2
# spent 5µs making 1 call to warnings::import |
3 | package Data::OptList; | ||||
4 | { | ||||
5 | 2 | 1µs | $Data::OptList::VERSION = '0.108'; | ||
6 | } | ||||
7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
8 | |||||
9 | 2 | 26µs | 1 | 4µs | # spent 4µs within Data::OptList::BEGIN@9 which was called:
# once (4µs+0s) by Class::Load::BEGIN@8 at line 9 # spent 4µs making 1 call to Data::OptList::BEGIN@9 |
10 | 2 | 178µs | 1 | 8.13ms | # spent 8.13ms (5.88+2.25) within Data::OptList::BEGIN@10 which was called:
# once (5.88ms+2.25ms) by Class::Load::BEGIN@8 at line 10 # spent 8.13ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 167µs | 2 | 1.88ms | # spent 1.87ms (1.57+297µs) within Data::OptList::BEGIN@11 which was called:
# once (1.57ms+297µs) by Class::Load::BEGIN@8 at line 11 # spent 1.87ms 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 7µs within Data::OptList::BEGIN@15 which was called:
# once (7µs+0s) by Class::Load::BEGIN@8 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 | 542µs | 1 | 7µs | } # spent 7µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 78 | 21µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 119 | 292µs | 78 | 350µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 350µs making 37 calls to List::Util::first, avg 9µs/call
# spent 226µs making 41 calls to Data::OptList::__is_a, avg 6µs/call, recursion: max depth 1, sum of overlapping time 226µs |
28 | |||||
29 | return defined ( | ||||
30 | 41 | 234µs | 41 | 37µs | exists($test_for{$expected}) # spent 24µs making 33 calls to Params::Util::_CODELIKE, avg 733ns/call
# spent 8µs making 4 calls to Params::Util::_HASHLIKE, avg 2µs/call
# spent 4µs making 4 calls to Params::Util::_ARRAYLIKE, avg 1µs/call |
31 | ? $test_for{$expected}->($got) | ||||
32 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
33 | ); | ||||
34 | } | ||||
35 | |||||
36 | # spent 1.78ms (1.11+671µs) within Data::OptList::mkopt which was called 32 times, avg 56µs/call:
# 9 times (660µs+631µs) by Data::OptList::mkopt_hash at line 94, avg 143µs/call
# 9 times (109µs+0s) by Sub::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 12µs/call
# 8 times (260µs+40µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 38µs/call
# 6 times (78µs+0s) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 13µs/call | ||||
37 | 32 | 10µs | my ($opt_list) = shift; | ||
38 | |||||
39 | 32 | 3µs | my ($moniker, $require_unique, $must_be); # the old positional args | ||
40 | my $name_test; | ||||
41 | |||||
42 | 32 | 40µs | 8 | 6µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 6µs making 8 calls to Params::Util::_HASHLIKE, avg 688ns/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 | 32 | 19µs | ($moniker, $require_unique, $must_be) = @_; | ||
48 | } | ||||
49 | |||||
50 | 32 | 8µs | $moniker = 'unnamed' unless defined $moniker; | ||
51 | |||||
52 | 32 | 4µs | return [] unless $opt_list; | ||
53 | |||||
54 | 113 | 273µs | # spent 106µs within Data::OptList::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Data/OptList.pm:54] which was called 81 times, avg 1µs/call:
# 81 times (106µs+0s) by Data::OptList::mkopt at line 71, avg 1µs/call | ||
55 | |||||
56 | $opt_list = [ | ||||
57 | 32 | 53µs | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||
58 | ] if ref $opt_list eq 'HASH'; | ||||
59 | |||||
60 | 32 | 4µs | my @return; | ||
61 | 32 | 4µs | my %seen; | ||
62 | |||||
63 | 32 | 56µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
64 | 90 | 27µs | my $name = $opt_list->[$i]; | ||
65 | 90 | 1µs | my $value; | ||
66 | |||||
67 | 90 | 29µs | if ($require_unique) { | ||
68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
69 | } | ||||
70 | |||||
71 | 90 | 160µs | 81 | 106µs | if ($i == $#$opt_list) { $value = undef; } # spent 106µs making 81 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 1µs/call |
72 | elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ } | ||||
73 | elsif ($name_test->($opt_list->[$i+1])) { $value = undef; } | ||||
74 | 37 | 13µs | else { $value = $opt_list->[++$i] } | ||
75 | |||||
76 | 90 | 78µs | if ($must_be and defined $value) { | ||
77 | 37 | 37µs | 37 | 559µs | unless (__is_a($value, $must_be)) { # spent 559µs making 37 calls to Data::OptList::__is_a, avg 15µs/call |
78 | my $ref = ref $value; | ||||
79 | Carp::croak "$ref-ref values are not valid in $moniker opt list"; | ||||
80 | } | ||||
81 | } | ||||
82 | |||||
83 | 90 | 100µs | push @return, [ $name => $value ]; | ||
84 | } | ||||
85 | |||||
86 | 32 | 173µs | return \@return; | ||
87 | } | ||||
88 | |||||
89 | |||||
90 | # spent 1.41ms (123µs+1.29) within Data::OptList::mkopt_hash which was called 12 times, avg 118µs/call:
# 8 times (95µs+1.09ms) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 148µs/call
# 4 times (28µs+205µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 58µs/call | ||||
91 | 12 | 7µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | 12 | 10µs | return {} unless $opt_list; | ||
93 | |||||
94 | 9 | 11µs | 9 | 1.29ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.29ms making 9 calls to Data::OptList::mkopt, avg 143µs/call |
95 | 9 | 50µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
96 | 9 | 41µs | return \%hash; | ||
97 | } | ||||
98 | |||||
99 | |||||
100 | # spent 26µs (17+9) within Data::OptList::BEGIN@100 which was called:
# once (17µs+9µs) by Class::Load::BEGIN@8 at line 104 | ||||
101 | 1 | 105µs | 1 | 9µs | *import = Sub::Install::exporter { # spent 9µs making 1 call to Sub::Install::exporter |
102 | exports => [qw(mkopt mkopt_hash)], | ||||
103 | }; | ||||
104 | 1 | 35µs | 1 | 26µs | } # spent 26µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 4µs | 1; | ||
107 | |||||
108 | __END__ |