| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Data/OptList.pm |
| Statements | Executed 58036 statements in 357ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2292 | 6 | 5 | 233ms | 334ms | Data::OptList::mkopt |
| 2793 | 2 | 1 | 68.2ms | 101ms | Data::OptList::__is_a (recurses: max depth 1, inclusive time 40.0ms) |
| 1 | 1 | 1 | 16.6ms | 28.8ms | Data::OptList::BEGIN@7 |
| 135 | 2 | 1 | 8.90ms | 180ms | Data::OptList::mkopt_hash |
| 1 | 1 | 1 | 4.87ms | 6.17ms | Data::OptList::BEGIN@8 |
| 1 | 1 | 1 | 67µs | 86µs | Data::OptList::BEGIN@3 |
| 1 | 1 | 1 | 62µs | 97µs | Data::OptList::BEGIN@214 |
| 1 | 1 | 1 | 43µs | 186µs | Data::OptList::BEGIN@4 |
| 1 | 1 | 1 | 34µs | 34µs | Data::OptList::BEGIN@131 |
| 1 | 1 | 1 | 19µs | 19µs | Data::OptList::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | Data::OptList::__ANON__[:143] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Data::OptList; | ||||
| 3 | 3 | 97µs | 2 | 104µs | # spent 86µs (67+18) within Data::OptList::BEGIN@3 which was called:
# once (67µs+18µs) by Class::MOP::BEGIN@13 at line 3 # spent 86µs making 1 call to Data::OptList::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 104µs | 2 | 329µs | # spent 186µs (43+143) within Data::OptList::BEGIN@4 which was called:
# once (43µs+143µs) by Class::MOP::BEGIN@13 at line 4 # spent 186µs making 1 call to Data::OptList::BEGIN@4
# spent 143µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 76µs | 1 | 19µs | # spent 19µs within Data::OptList::BEGIN@6 which was called:
# once (19µs+0s) by Class::MOP::BEGIN@13 at line 6 # spent 19µs making 1 call to Data::OptList::BEGIN@6 |
| 7 | 3 | 468µs | 1 | 28.8ms | # spent 28.8ms (16.6+12.2) within Data::OptList::BEGIN@7 which was called:
# once (16.6ms+12.2ms) by Class::MOP::BEGIN@13 at line 7 # spent 28.8ms making 1 call to Data::OptList::BEGIN@7 |
| 8 | 3 | 773µs | 2 | 6.23ms | # spent 6.17ms (4.87+1.31) within Data::OptList::BEGIN@8 which was called:
# once (4.87ms+1.31ms) by Class::MOP::BEGIN@13 at line 8 # spent 6.17ms making 1 call to Data::OptList::BEGIN@8
# spent 56µs making 1 call to UNIVERSAL::VERSION |
| 9 | |||||
| 10 | =head1 NAME | ||||
| 11 | |||||
| - - | |||||
| 20 | 1 | 4µs | our $VERSION = '0.106'; | ||
| 21 | |||||
| 22 | =head1 SYNOPSIS | ||||
| 23 | |||||
| - - | |||||
| 130 | 1 | 2µs | my %test_for; | ||
| 131 | # spent 34µs within Data::OptList::BEGIN@131 which was called:
# once (34µs+0s) by Class::MOP::BEGIN@13 at line 138 | ||||
| 132 | 1 | 33µs | %test_for = ( | ||
| 133 | CODE => \&Params::Util::_CODELIKE, ## no critic | ||||
| 134 | HASH => \&Params::Util::_HASHLIKE, ## no critic | ||||
| 135 | ARRAY => \&Params::Util::_ARRAYLIKE, ## no critic | ||||
| 136 | SCALAR => \&Params::Util::_SCALAR0, ## no critic | ||||
| 137 | ); | ||||
| 138 | 1 | 1.24ms | 1 | 34µs | } # spent 34µs making 1 call to Data::OptList::BEGIN@131 |
| 139 | |||||
| 140 | sub __is_a { | ||||
| 141 | 6989 | 64.7ms | my ($got, $expected) = @_; | ||
| 142 | |||||
| 143 | 1403 | 37.5ms | 2793 | 66.0ms | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 66.0ms making 1390 calls to List::Util::first, avg 48µs/call
# spent 40.0ms making 1403 calls to Data::OptList::__is_a, avg 28µs/call, recursion: max depth 1, sum of overlapping time 40.0ms |
| 144 | |||||
| 145 | return defined ( | ||||
| 146 | 1403 | 6.78ms | exists($test_for{$expected}) # spent 6.63ms making 1377 calls to Params::Util::_CODELIKE, avg 5µs/call
# spent 81µs making 13 calls to Params::Util::_HASHLIKE, avg 6µs/call
# spent 64µs making 13 calls to Params::Util::_ARRAYLIKE, avg 5µs/call | ||
| 147 | ? $test_for{$expected}->($got) | ||||
| 148 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
| 149 | ); | ||||
| 150 | } | ||||
| 151 | |||||
| 152 | # spent 334ms (233+101) within Data::OptList::mkopt which was called 2292 times, avg 146µs/call:
# 785 times (29.6ms+0s) by Moose::Meta::Class::superclasses at line 285 of Moose/Meta/Class.pm, avg 38µs/call
# 709 times (43.5ms+0s) by Class::MOP::load_first_existing_class at line 82 of Class/MOP.pm, avg 61µs/call
# 365 times (66.9ms+0s) by Sub::Exporter::_expand_group at line 505 of Sub/Exporter.pm, avg 183µs/call
# 233 times (12.5ms+0s) by Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:756] at line 735 of Sub/Exporter.pm, avg 53µs/call
# 142 times (10.1ms+0s) by Moose::Util::_apply_all_roles at line 103 of Moose/Util.pm, avg 71µs/call
# 58 times (70.1ms+101ms) by Data::OptList::mkopt_hash at line 203, avg 2.95ms/call | ||||
| 153 | 49180 | 243ms | my ($opt_list, $moniker, $require_unique, $must_be) = @_; | ||
| 154 | |||||
| 155 | return [] unless $opt_list; | ||||
| 156 | |||||
| 157 | $opt_list = [ | ||||
| 158 | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||||
| 159 | ] if ref $opt_list eq 'HASH'; | ||||
| 160 | |||||
| 161 | my @return; | ||||
| 162 | my %seen; | ||||
| 163 | |||||
| 164 | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||||
| 165 | my $name = $opt_list->[$i]; | ||||
| 166 | my $value; | ||||
| 167 | |||||
| 168 | if ($require_unique) { | ||||
| 169 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
| 170 | } | ||||
| 171 | |||||
| 172 | if ($i == $#$opt_list) { $value = undef; } | ||||
| 173 | elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ } | ||||
| 174 | elsif (ref $opt_list->[$i+1]) { $value = $opt_list->[++$i] } | ||||
| 175 | else { $value = undef; } | ||||
| 176 | |||||
| 177 | if ($must_be and defined $value) { | ||||
| 178 | 1390 | 101ms | unless (__is_a($value, $must_be)) { # spent 101ms making 1390 calls to Data::OptList::__is_a, avg 73µs/call | ||
| 179 | my $ref = ref $value; | ||||
| 180 | Carp::croak "$ref-ref values are not valid in $moniker opt list"; | ||||
| 181 | } | ||||
| 182 | } | ||||
| 183 | |||||
| 184 | push @return, [ $name => $value ]; | ||||
| 185 | } | ||||
| 186 | |||||
| 187 | return \@return; | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | =head2 mkopt_hash | ||||
| 191 | |||||
| - - | |||||
| 199 | # spent 180ms (8.90+171) within Data::OptList::mkopt_hash which was called 135 times, avg 1.33ms/call:
# 90 times (7.96ms+168ms) by Sub::Exporter::_rewrite_build_config at line 672 of Sub/Exporter.pm, avg 1.96ms/call
# 45 times (933µs+2.72ms) by Sub::Exporter::_rewrite_build_config at line 685 of Sub/Exporter.pm, avg 81µs/call | ||||
| 200 | 444 | 9.07ms | my ($opt_list, $moniker, $must_be) = @_; | ||
| 201 | return {} unless $opt_list; | ||||
| 202 | |||||
| 203 | 58 | 171ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 171ms making 58 calls to Data::OptList::mkopt, avg 2.95ms/call | ||
| 204 | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||||
| 205 | return \%hash; | ||||
| 206 | } | ||||
| 207 | |||||
| 208 | =head1 EXPORTS | ||||
| 209 | |||||
| - - | |||||
| 214 | # spent 97µs (62+35) within Data::OptList::BEGIN@214 which was called:
# once (62µs+35µs) by Class::MOP::BEGIN@13 at line 218 | ||||
| 215 | 1 | 35µs | 1 | 35µs | *import = Sub::Install::exporter { # spent 35µs making 1 call to Sub::Install::exporter |
| 216 | exports => [qw(mkopt mkopt_hash)], | ||||
| 217 | }; | ||||
| 218 | 1 | 73µs | 1 | 97µs | } # spent 97µs making 1 call to Data::OptList::BEGIN@214 |
| 219 | |||||
| 220 | =head1 AUTHOR | ||||
| 221 | |||||
| - - | |||||
| 237 | 1 | 11µs | 1; |