Filename | /usr/local/share/perl/5.14.2/Data/OptList.pm |
Statements | Executed 4136 statements in 4.98ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 3.76ms | 4.36ms | BEGIN@10 | Data::OptList::
1 | 1 | 1 | 2.66ms | 3.20ms | BEGIN@11 | Data::OptList::
118 | 4 | 3 | 2.25ms | 2.90ms | mkopt | Data::OptList::
78 | 2 | 1 | 297µs | 420µs | __is_a (recurses: max depth 1, inclusive time 170µs) | Data::OptList::
227 | 1 | 1 | 211µs | 211µs | __ANON__[:54] | Data::OptList::
12 | 2 | 1 | 102µs | 1.10ms | mkopt_hash | Data::OptList::
1 | 1 | 1 | 30µs | 37µs | BEGIN@1 | Class::Load::
1 | 1 | 1 | 24µs | 44µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 16µs | 16µs | BEGIN@15 | Data::OptList::
1 | 1 | 1 | 14µs | 24µs | BEGIN@2 | Class::Load::
1 | 1 | 1 | 10µs | 10µ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 | 49µs | 2 | 44µs | # spent 37µs (30+7) within Class::Load::BEGIN@1 which was called:
# once (30µs+7µs) by Class::Load::BEGIN@8 at line 1 # spent 37µs making 1 call to Class::Load::BEGIN@1
# spent 7µs making 1 call to strict::import |
2 | 2 | 122µs | 2 | 34µs | # spent 24µs (14+10) within Class::Load::BEGIN@2 which was called:
# once (14µs+10µs) by Class::Load::BEGIN@8 at line 2 # spent 24µs making 1 call to Class::Load::BEGIN@2
# spent 10µs making 1 call to warnings::import |
3 | package Data::OptList; | ||||
4 | { | ||||
5 | 2 | 2µs | $Data::OptList::VERSION = '0.108'; | ||
6 | } | ||||
7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
8 | |||||
9 | 2 | 55µs | 1 | 10µs | # spent 10µs within Data::OptList::BEGIN@9 which was called:
# once (10µs+0s) by Class::Load::BEGIN@8 at line 9 # spent 10µs making 1 call to Data::OptList::BEGIN@9 |
10 | 2 | 261µs | 1 | 4.36ms | # spent 4.36ms (3.76+606µs) within Data::OptList::BEGIN@10 which was called:
# once (3.76ms+606µs) by Class::Load::BEGIN@8 at line 10 # spent 4.36ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 358µs | 2 | 3.23ms | # spent 3.20ms (2.66+539µs) within Data::OptList::BEGIN@11 which was called:
# once (2.66ms+539µs) by Class::Load::BEGIN@8 at line 11 # spent 3.20ms making 1 call to Data::OptList::BEGIN@11
# spent 29µs making 1 call to UNIVERSAL::VERSION |
12 | |||||
13 | |||||
14 | 1 | 300ns | my %test_for; | ||
15 | # spent 16µs within Data::OptList::BEGIN@15 which was called:
# once (16µs+0s) by Class::Load::BEGIN@8 at line 22 | ||||
16 | 1 | 15µ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 | 932µs | 1 | 16µs | } # spent 16µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 197 | 304µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 41 | 131µs | 78 | 261µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 261µs making 37 calls to List::Util::first, avg 7µs/call
# spent 170µs making 41 calls to Data::OptList::__is_a, avg 4µs/call, recursion: max depth 1, sum of overlapping time 170µs |
28 | |||||
29 | return defined ( | ||||
30 | 41 | 32µs | exists($test_for{$expected}) # spent 23µs making 33 calls to Params::Util::_CODELIKE, avg 703ns/call
# spent 6µs making 4 calls to Params::Util::_HASHLIKE, avg 2µs/call
# spent 2µs making 4 calls to Params::Util::_ARRAYLIKE, avg 625ns/call | ||
31 | ? $test_for{$expected}->($got) | ||||
32 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
33 | ); | ||||
34 | } | ||||
35 | |||||
36 | # spent 2.90ms (2.25+647µs) within Data::OptList::mkopt which was called 118 times, avg 25µs/call:
# 56 times (481µs+0s) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 9µs/call
# 32 times (1.06ms+172µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 39µs/call
# 21 times (186µs+0s) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.14.2/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 9µs/call
# 9 times (521µs+475µs) by Data::OptList::mkopt_hash at line 94, avg 111µs/call | ||||
37 | 1416 | 1.19ms | my ($opt_list) = shift; | ||
38 | |||||
39 | my ($moniker, $require_unique, $must_be); # the old positional args | ||||
40 | my $name_test; | ||||
41 | |||||
42 | 118 | 68µs | 32 | 17µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 17µs making 32 calls to Params::Util::_HASHLIKE, avg 519ns/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 | ($moniker, $require_unique, $must_be) = @_; | ||||
48 | } | ||||
49 | |||||
50 | $moniker = 'unnamed' unless defined $moniker; | ||||
51 | |||||
52 | return [] unless $opt_list; | ||||
53 | |||||
54 | 227 | 386µs | # spent 211µs within Data::OptList::__ANON__[/usr/local/share/perl/5.14.2/Data/OptList.pm:54] which was called 227 times, avg 928ns/call:
# 227 times (211µs+0s) by Data::OptList::mkopt at line 71, avg 928ns/call | ||
55 | |||||
56 | $opt_list = [ | ||||
57 | 36 | 20µs | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||
58 | ] if ref $opt_list eq 'HASH'; | ||||
59 | |||||
60 | my @return; | ||||
61 | my %seen; | ||||
62 | |||||
63 | 1620 | 801µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
64 | my $name = $opt_list->[$i]; | ||||
65 | my $value; | ||||
66 | |||||
67 | 53 | 29µs | if ($require_unique) { | ||
68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
69 | } | ||||
70 | |||||
71 | 270 | 55µs | 227 | 211µs | if ($i == $#$opt_list) { $value = undef; } # spent 211µs making 227 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 928ns/call |
72 | elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ } | ||||
73 | elsif ($name_test->($opt_list->[$i+1])) { $value = undef; } | ||||
74 | else { $value = $opt_list->[++$i] } | ||||
75 | |||||
76 | 37 | 35µs | if ($must_be and defined $value) { | ||
77 | 37 | 420µs | unless (__is_a($value, $must_be)) { # spent 420µs making 37 calls to Data::OptList::__is_a, avg 11µs/call | ||
78 | my $ref = ref $value; | ||||
79 | Carp::croak "$ref-ref values are not valid in $moniker opt list"; | ||||
80 | } | ||||
81 | } | ||||
82 | |||||
83 | push @return, [ $name => $value ]; | ||||
84 | } | ||||
85 | |||||
86 | return \@return; | ||||
87 | } | ||||
88 | |||||
89 | |||||
90 | # spent 1.10ms (102µs+997µs) within Data::OptList::mkopt_hash which was called 12 times, avg 92µs/call:
# 8 times (78µs+838µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 115µs/call
# 4 times (24µs+158µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 46µs/call | ||||
91 | 51 | 83µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | return {} unless $opt_list; | ||||
93 | |||||
94 | 9 | 997µs | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 997µs making 9 calls to Data::OptList::mkopt, avg 111µs/call | ||
95 | 53 | 20µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
96 | return \%hash; | ||||
97 | } | ||||
98 | |||||
99 | |||||
100 | # spent 44µs (24+20) within Data::OptList::BEGIN@100 which was called:
# once (24µs+20µs) by Class::Load::BEGIN@8 at line 104 | ||||
101 | 1 | 14µs | 1 | 20µs | *import = Sub::Install::exporter { # spent 20µs making 1 call to Sub::Install::exporter |
102 | exports => [qw(mkopt mkopt_hash)], | ||||
103 | }; | ||||
104 | 1 | 41µs | 1 | 44µs | } # spent 44µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 6µs | 1; | ||
107 | |||||
108 | __END__ |