Filename | /usr/local/share/perl/5.14.2/Data/OptList.pm |
Statements | Executed 4136 statements in 4.04ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
118 | 4 | 3 | 2.34ms | 3.00ms | mkopt | Data::OptList::
1 | 1 | 1 | 1.66ms | 1.95ms | BEGIN@10 | Data::OptList::
1 | 1 | 1 | 1.16ms | 1.41ms | BEGIN@11 | Data::OptList::
78 | 2 | 1 | 307µs | 437µs | __is_a (recurses: max depth 1, inclusive time 177µs) | Data::OptList::
227 | 1 | 1 | 207µs | 207µs | __ANON__[:54] | Data::OptList::
12 | 2 | 1 | 108µs | 1.14ms | mkopt_hash | Data::OptList::
1 | 1 | 1 | 13µs | 22µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 11µs | 14µs | BEGIN@1 | Class::Load::
1 | 1 | 1 | 7µs | 7µs | BEGIN@15 | Data::OptList::
1 | 1 | 1 | 6µs | 10µs | BEGIN@2 | Class::Load::
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 | 20µs | 2 | 16µs | # spent 14µs (11+3) within Class::Load::BEGIN@1 which was called:
# once (11µs+3µs) by Class::Load::BEGIN@8 at line 1 # spent 14µs making 1 call to Class::Load::BEGIN@1
# spent 3µs making 1 call to strict::import |
2 | 2 | 41µs | 2 | 15µs | # spent 10µs (6+4) within Class::Load::BEGIN@2 which was called:
# once (6µs+4µs) by Class::Load::BEGIN@8 at line 2 # spent 10µ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 | 900ns | $Data::OptList::VERSION = '0.108'; | ||
6 | } | ||||
7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
8 | |||||
9 | 2 | 18µ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 | 116µs | 1 | 1.95ms | # spent 1.95ms (1.66+282µs) within Data::OptList::BEGIN@10 which was called:
# once (1.66ms+282µs) by Class::Load::BEGIN@8 at line 10 # spent 1.95ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 152µs | 2 | 1.42ms | # spent 1.41ms (1.16+244µs) within Data::OptList::BEGIN@11 which was called:
# once (1.16ms+244µs) by Class::Load::BEGIN@8 at line 11 # spent 1.41ms making 1 call to Data::OptList::BEGIN@11
# spent 13µs making 1 call to UNIVERSAL::VERSION |
12 | |||||
13 | |||||
14 | 1 | 200ns | 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 | 6µ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 | 406µs | 1 | 7µs | } # spent 7µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 197 | 317µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 41 | 137µs | 78 | 272µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 272µs making 37 calls to List::Util::first, avg 7µs/call
# spent 177µs making 41 calls to Data::OptList::__is_a, avg 4µs/call, recursion: max depth 1, sum of overlapping time 177µs |
28 | |||||
29 | return defined ( | ||||
30 | 41 | 35µs | exists($test_for{$expected}) # spent 22µs making 33 calls to Params::Util::_CODELIKE, avg 682ns/call
# spent 7µs making 4 calls to Params::Util::_HASHLIKE, avg 2µs/call
# spent 5µ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 3.00ms (2.34+662µs) within Data::OptList::mkopt which was called 118 times, avg 25µs/call:
# 56 times (506µs+0s) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 9µs/call
# 32 times (1.11ms+167µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 40µs/call
# 21 times (189µ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 (539µs+495µs) by Data::OptList::mkopt_hash at line 94, avg 115µs/call | ||||
37 | 1416 | 1.25ms | my ($opt_list) = shift; | ||
38 | |||||
39 | my ($moniker, $require_unique, $must_be); # the old positional args | ||||
40 | my $name_test; | ||||
41 | |||||
42 | 118 | 66µs | 32 | 18µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 18µs making 32 calls to Params::Util::_HASHLIKE, avg 572ns/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 | 408µs | # spent 207µs within Data::OptList::__ANON__[/usr/local/share/perl/5.14.2/Data/OptList.pm:54] which was called 227 times, avg 912ns/call:
# 227 times (207µs+0s) by Data::OptList::mkopt at line 71, avg 912ns/call | ||
55 | |||||
56 | $opt_list = [ | ||||
57 | 36 | 21µ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 | 829µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
64 | my $name = $opt_list->[$i]; | ||||
65 | my $value; | ||||
66 | |||||
67 | 53 | 30µs | if ($require_unique) { | ||
68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
69 | } | ||||
70 | |||||
71 | 270 | 56µs | 227 | 207µs | if ($i == $#$opt_list) { $value = undef; } # spent 207µs making 227 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 912ns/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 | 437µs | unless (__is_a($value, $must_be)) { # spent 437µs making 37 calls to Data::OptList::__is_a, avg 12µ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.14ms (108µs+1.03) within Data::OptList::mkopt_hash which was called 12 times, avg 95µs/call:
# 8 times (83µs+869µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 119µs/call
# 4 times (24µs+165µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 47µs/call | ||||
91 | 51 | 87µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | return {} unless $opt_list; | ||||
93 | |||||
94 | 9 | 1.03ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.03ms making 9 calls to Data::OptList::mkopt, avg 115µs/call | ||
95 | 53 | 21µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
96 | return \%hash; | ||||
97 | } | ||||
98 | |||||
99 | |||||
100 | # spent 22µs (13+9) within Data::OptList::BEGIN@100 which was called:
# once (13µs+9µs) by Class::Load::BEGIN@8 at line 104 | ||||
101 | 1 | 7µ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 | 18µs | 1 | 22µs | } # spent 22µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 3µs | 1; | ||
107 | |||||
108 | __END__ |