Filename | /Users/ap13/perl5/lib/perl5/Data/OptList.pm |
Statements | Executed 6326 statements in 6.84ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 7.49ms | 10.5ms | BEGIN@10 | Data::OptList::
222 | 5 | 4 | 4.67ms | 5.77ms | mkopt | Data::OptList::
1 | 1 | 1 | 2.20ms | 2.81ms | BEGIN@11 | Data::OptList::
110 | 2 | 1 | 456µs | 666µs | __is_a (recurses: max depth 1, inclusive time 263µs) | Data::OptList::
330 | 1 | 1 | 388µs | 388µs | __ANON__[:54] | Data::OptList::
18 | 2 | 1 | 188µs | 1.86ms | mkopt_hash | Data::OptList::
1 | 1 | 1 | 18µs | 32µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 14µs | 30µs | BEGIN@1 | Class::Load::
1 | 1 | 1 | 11µs | 11µs | BEGIN@15 | Data::OptList::
1 | 1 | 1 | 8µs | 15µs | BEGIN@2 | Class::Load::
1 | 1 | 1 | 4µs | 4µs | BEGIN@4 | Data::OptList::
1 | 1 | 1 | 3µs | 3µ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 | 24µs | 2 | 47µs | # spent 30µs (14+17) within Class::Load::BEGIN@1 which was called:
# once (14µs+17µs) by Class::Load::BEGIN@8 at line 1 # spent 30µs making 1 call to Class::Load::BEGIN@1
# spent 17µs making 1 call to strict::import |
2 | 2 | 45µs | 2 | 23µs | # spent 15µs (8+7) within Class::Load::BEGIN@2 which was called:
# once (8µs+7µs) by Class::Load::BEGIN@8 at line 2 # spent 15µs making 1 call to Class::Load::BEGIN@2
# spent 7µs making 1 call to warnings::import |
3 | package Data::OptList; | ||||
4 | # spent 4µs within Data::OptList::BEGIN@4 which was called:
# once (4µs+0s) by Class::Load::BEGIN@8 at line 6 | ||||
5 | 1 | 4µs | $Data::OptList::VERSION = '0.107'; | ||
6 | 1 | 17µs | 1 | 4µs | } # spent 4µs making 1 call to Data::OptList::BEGIN@4 |
7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
8 | |||||
9 | 2 | 19µ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 | 2 | 167µs | 1 | 10.5ms | # spent 10.5ms (7.49+2.99) within Data::OptList::BEGIN@10 which was called:
# once (7.49ms+2.99ms) by Class::Load::BEGIN@8 at line 10 # spent 10.5ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 298µs | 2 | 2.83ms | # spent 2.81ms (2.20+611µs) within Data::OptList::BEGIN@11 which was called:
# once (2.20ms+611µs) by Class::Load::BEGIN@8 at line 11 # spent 2.81ms making 1 call to Data::OptList::BEGIN@11
# spent 24µs making 1 call to UNIVERSAL::VERSION |
12 | |||||
13 | |||||
14 | 1 | 200ns | my %test_for; | ||
15 | # spent 11µs within Data::OptList::BEGIN@15 which was called:
# once (11µs+0s) by Class::Load::BEGIN@8 at line 22 | ||||
16 | 1 | 12µ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 | 713µs | 1 | 11µs | } # spent 11µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 278 | 440µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 58 | 204µs | 110 | 431µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 431µs making 52 calls to List::Util::first, avg 8µs/call
# spent 263µs making 58 calls to Data::OptList::__is_a, avg 5µs/call, recursion: max depth 1, sum of overlapping time 263µs |
28 | |||||
29 | return defined ( | ||||
30 | 58 | 41µs | exists($test_for{$expected}) # spent 23µs making 46 calls to Params::Util::_CODELIKE, avg 498ns/call
# spent 11µs making 6 calls to Params::Util::_HASHLIKE, avg 2µs/call
# spent 7µs making 6 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 5.77ms (4.67+1.10) within Data::OptList::mkopt which was called 222 times, avg 26µs/call:
# 97 times (1.01ms+0s) by Moose::Meta::Class::superclasses at line 554 of Moose/Meta/Class.pm, avg 10µs/call
# 58 times (745µs+2µs) by Sub::Exporter::__ANON__[/Users/ap13/perl5/lib/perl5/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 13µs/call
# 50 times (1.94ms+319µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 45µs/call
# 13 times (895µs+774µs) by Data::OptList::mkopt_hash at line 94, avg 128µs/call
# 4 times (77µs+5µs) by Moose::Util::_apply_all_roles at line 137 of Moose/Util.pm, avg 21µs/call | ||||
37 | 5569 | 4.02ms | my ($opt_list) = shift; | ||
38 | |||||
39 | my ($moniker, $require_unique, $must_be); # the old positional args | ||||
40 | my $name_test; | ||||
41 | |||||
42 | 54 | 46µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 46µs making 54 calls to Params::Util::_HASHLIKE, avg 856ns/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 | 330 | 625µs | # spent 388µs within Data::OptList::__ANON__[/Users/ap13/perl5/lib/perl5/Data/OptList.pm:54] which was called 330 times, avg 1µs/call:
# 330 times (388µ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 | 330 | 388µs | if ($i == $#$opt_list) { $value = undef; } # spent 388µs making 330 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 | 52 | 666µs | unless (__is_a($value, $must_be)) { # spent 666µs making 52 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.86ms (188µs+1.67) within Data::OptList::mkopt_hash which was called 18 times, avg 103µs/call:
# 12 times (145µs+1.37ms) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 126µs/call
# 6 times (42µs+297µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 57µs/call | ||||
91 | 75 | 183µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | return {} unless $opt_list; | ||||
93 | |||||
94 | 13 | 1.67ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.67ms making 13 calls to Data::OptList::mkopt, avg 128µs/call | ||
95 | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||||
96 | return \%hash; | ||||
97 | } | ||||
98 | |||||
99 | |||||
100 | # spent 32µs (18+14) within Data::OptList::BEGIN@100 which was called:
# once (18µs+14µs) by Class::Load::BEGIN@8 at line 104 | ||||
101 | 1 | 11µs | 1 | 14µs | *import = Sub::Install::exporter { # spent 14µs making 1 call to Sub::Install::exporter |
102 | exports => [qw(mkopt mkopt_hash)], | ||||
103 | }; | ||||
104 | 1 | 51µs | 1 | 32µs | } # spent 32µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 5µs | 1; | ||
107 | |||||
108 | __END__ |