Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Data/OptList.pm |
Statements | Executed 4813 statements in 5.64ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 3.99ms | 6.98ms | BEGIN@10 | Data::OptList::
155 | 5 | 4 | 3.45ms | 4.47ms | mkopt | Data::OptList::
1 | 1 | 1 | 1.08ms | 1.34ms | BEGIN@11 | Data::OptList::
120 | 2 | 1 | 476µs | 738µs | __is_a (recurses: max depth 1, inclusive time 308µs) | Data::OptList::
241 | 1 | 1 | 249µs | 249µs | __ANON__[:54] | Data::OptList::
30 | 2 | 1 | 237µs | 1.93ms | mkopt_hash | Data::OptList::
1 | 1 | 1 | 11µs | 24µs | BEGIN@2 | Class::Load::
1 | 1 | 1 | 10µs | 13µs | BEGIN@1 | Class::Load::
1 | 1 | 1 | 8µs | 19µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 8µs | 8µs | BEGIN@15 | Data::OptList::
1 | 1 | 1 | 3µs | 3µs | BEGIN@9 | Data::OptList::
1 | 1 | 1 | 3µs | 3µs | BEGIN@4 | Data::OptList::
0 | 0 | 0 | 0s | 0s | __ANON__[:27] | Data::OptList::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 3 | 20µs | 2 | 16µs | # spent 13µs (10+3) within Class::Load::BEGIN@1 which was called:
# once (10µs+3µs) by Class::Load::BEGIN@8 at line 1 # spent 13µs making 1 call to Class::Load::BEGIN@1
# spent 3µs making 1 call to strict::import |
2 | 3 | 29µs | 2 | 37µs | # spent 24µs (11+13) within Class::Load::BEGIN@2 which was called:
# once (11µs+13µs) by Class::Load::BEGIN@8 at line 2 # spent 24µs making 1 call to Class::Load::BEGIN@2
# spent 13µs making 1 call to warnings::import |
3 | package Data::OptList; | ||||
4 | # spent 3µs within Data::OptList::BEGIN@4 which was called:
# once (3µs+0s) by Class::Load::BEGIN@8 at line 6 | ||||
5 | 1 | 7µs | $Data::OptList::VERSION = '0.107'; | ||
6 | 1 | 12µs | 1 | 3µs | } # spent 3µs making 1 call to Data::OptList::BEGIN@4 |
7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
8 | |||||
9 | 3 | 17µs | 1 | 3µs | # spent 3µs within Data::OptList::BEGIN@9 which was called:
# once (3µs+0s) by Class::Load::BEGIN@8 at line 9 # spent 3µs making 1 call to Data::OptList::BEGIN@9 |
10 | 3 | 101µs | 1 | 6.98ms | # spent 6.98ms (3.99+2.99) within Data::OptList::BEGIN@10 which was called:
# once (3.99ms+2.99ms) by Class::Load::BEGIN@8 at line 10 # spent 6.98ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 153µs | 2 | 1.36ms | # spent 1.34ms (1.08+261µs) within Data::OptList::BEGIN@11 which was called:
# once (1.08ms+261µs) by Class::Load::BEGIN@8 at line 11 # spent 1.34ms making 1 call to Data::OptList::BEGIN@11
# spent 21µs making 1 call to UNIVERSAL::VERSION |
12 | |||||
13 | |||||
14 | 1 | 200ns | my %test_for; | ||
15 | # spent 8µs within Data::OptList::BEGIN@15 which was called:
# once (8µ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 | 350µs | 1 | 8µs | } # spent 8µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 304 | 525µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 64 | 236µs | 120 | 507µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 507µs making 56 calls to List::Util::first, avg 9µs/call
# spent 308µs making 64 calls to Data::OptList::__is_a, avg 5µs/call, recursion: max depth 1, sum of overlapping time 308µs |
28 | |||||
29 | return defined ( | ||||
30 | 64 | 63µs | exists($test_for{$expected}) # spent 39µs making 48 calls to Params::Util::_CODELIKE, avg 821ns/call
# spent 12µs making 8 calls to Params::Util::_HASHLIKE, avg 1µs/call
# spent 11µs making 8 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 4.47ms (3.45+1.02) within Data::OptList::mkopt which was called 155 times, avg 29µs/call:
# 63 times (826µs+0s) by Moose::Meta::Class::superclasses at line 551 of Moose/Meta/Class.pm, avg 13µs/call
# 35 times (1.17ms+180µs) by Sub::Exporter::_expand_group at line 505 of Sub/Exporter.pm, avg 39µs/call
# 34 times (469µs+10µs) by Sub::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Sub/Exporter.pm:756] at line 735 of Sub/Exporter.pm, avg 14µs/call
# 19 times (870µs+822µs) by Data::OptList::mkopt_hash at line 94, avg 89µs/call
# 4 times (108µs+11µs) by Moose::Util::_apply_all_roles at line 122 of Moose/Util.pm, avg 30µs/call | ||||
37 | 4067 | 3.46ms | my ($opt_list) = shift; | ||
38 | |||||
39 | my ($moniker, $require_unique, $must_be); # the old positional args | ||||
40 | my $name_test; | ||||
41 | |||||
42 | 39 | 34µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 34µs making 39 calls to Params::Util::_HASHLIKE, avg 877ns/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 | 241 | 468µs | # spent 249µs within Data::OptList::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Data/OptList.pm:54] which was called 241 times, avg 1µs/call:
# 241 times (249µs+0s) by Data::OptList::mkopt at line 71, avg 1µs/call | ||
55 | |||||
56 | $opt_list = [ | ||||
57 | 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 | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||||
64 | my $name = $opt_list->[$i]; | ||||
65 | my $value; | ||||
66 | |||||
67 | if ($require_unique) { | ||||
68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
69 | } | ||||
70 | |||||
71 | 241 | 249µs | if ($i == $#$opt_list) { $value = undef; } # spent 249µs making 241 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 | else { $value = $opt_list->[++$i] } | ||||
75 | |||||
76 | if ($must_be and defined $value) { | ||||
77 | 56 | 738µs | unless (__is_a($value, $must_be)) { # spent 738µs making 56 calls to Data::OptList::__is_a, avg 13µ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.93ms (237µs+1.69) within Data::OptList::mkopt_hash which was called 30 times, avg 64µs/call:
# 20 times (184µs+1.33ms) by Sub::Exporter::_rewrite_build_config at line 672 of Sub/Exporter.pm, avg 76µs/call
# 10 times (53µs+362µs) by Sub::Exporter::_rewrite_build_config at line 685 of Sub/Exporter.pm, avg 42µs/call | ||||
91 | 117 | 238µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | return {} unless $opt_list; | ||||
93 | |||||
94 | 19 | 1.69ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.69ms making 19 calls to Data::OptList::mkopt, avg 89µs/call | ||
95 | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||||
96 | return \%hash; | ||||
97 | } | ||||
98 | |||||
99 | |||||
100 | # spent 19µs (8+12) within Data::OptList::BEGIN@100 which was called:
# once (8µs+12µs) by Class::Load::BEGIN@8 at line 104 | ||||
101 | 1 | 8µs | 1 | 12µs | *import = Sub::Install::exporter { # spent 12µs making 1 call to Sub::Install::exporter |
102 | exports => [qw(mkopt mkopt_hash)], | ||||
103 | }; | ||||
104 | 1 | 14µs | 1 | 19µs | } # spent 19µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 2µs | 1; | ||
107 | |||||
108 | __END__ |