| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Data/OptList.pm |
| Statements | Executed 8831 statements in 5.74ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 310 | 8 | 5 | 5.09ms | 6.11ms | Data::OptList::mkopt |
| 1 | 1 | 1 | 2.55ms | 3.26ms | Data::OptList::BEGIN@10 |
| 1 | 1 | 1 | 1.14ms | 1.35ms | Data::OptList::BEGIN@11 |
| 464 | 1 | 1 | 431µs | 431µs | Data::OptList::__ANON__[:54] |
| 112 | 2 | 1 | 370µs | 518µs | Data::OptList::__is_a (recurses: max depth 1, inclusive time 211µs) |
| 18 | 2 | 1 | 116µs | 1.35ms | Data::OptList::mkopt_hash |
| 1 | 1 | 1 | 9µs | 20µs | Class::Load::BEGIN@1 |
| 1 | 1 | 1 | 8µs | 14µs | Data::OptList::BEGIN@100 |
| 1 | 1 | 1 | 6µs | 9µs | Class::Load::BEGIN@2 |
| 1 | 1 | 1 | 4µs | 4µs | Data::OptList::BEGIN@15 |
| 1 | 1 | 1 | 3µs | 3µs | Data::OptList::BEGIN@9 |
| 0 | 0 | 0 | 0s | 0s | Data::OptList::__ANON__[:27] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 19µs | 2 | 30µs | # spent 20µs (9+10) within Class::Load::BEGIN@1 which was called:
# once (9µs+10µs) by Class::Load::BEGIN@8 at line 1 # spent 20µs making 1 call to Class::Load::BEGIN@1
# spent 10µs making 1 call to strict::import |
| 2 | 2 | 34µs | 2 | 12µs | # spent 9µs (6+3) within Class::Load::BEGIN@2 which was called:
# once (6µs+3µs) by Class::Load::BEGIN@8 at line 2 # spent 9µs making 1 call to Class::Load::BEGIN@2
# spent 3µs making 1 call to warnings::import |
| 3 | package Data::OptList; | ||||
| 4 | { | ||||
| 5 | 2 | 600ns | $Data::OptList::VERSION = '0.108'; | ||
| 6 | } | ||||
| 7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
| 8 | |||||
| 9 | 2 | 18µ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 | 117µs | 1 | 3.26ms | # spent 3.26ms (2.55+718µs) within Data::OptList::BEGIN@10 which was called:
# once (2.55ms+718µs) by Class::Load::BEGIN@8 at line 10 # spent 3.26ms making 1 call to Data::OptList::BEGIN@10 |
| 11 | 3 | 120µs | 2 | 1.35ms | # spent 1.35ms (1.14+206µs) within Data::OptList::BEGIN@11 which was called:
# once (1.14ms+206µs) by Class::Load::BEGIN@8 at line 11 # spent 1.35ms making 1 call to Data::OptList::BEGIN@11
# spent 8µs making 1 call to UNIVERSAL::VERSION |
| 12 | |||||
| 13 | |||||
| 14 | 1 | 100ns | my %test_for; | ||
| 15 | # spent 4µs within Data::OptList::BEGIN@15 which was called:
# once (4µs+0s) by Class::Load::BEGIN@8 at line 22 | ||||
| 16 | 1 | 5µ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 | 363µs | 1 | 4µs | } # spent 4µs making 1 call to Data::OptList::BEGIN@15 |
| 23 | |||||
| 24 | sub __is_a { | ||||
| 25 | 112 | 20µs | my ($got, $expected) = @_; | ||
| 26 | |||||
| 27 | 171 | 260µs | 112 | 326µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 326µs making 53 calls to List::Util::first, avg 6µs/call
# spent 211µs making 59 calls to Data::OptList::__is_a, avg 4µs/call, recursion: max depth 1, sum of overlapping time 211µs |
| 28 | |||||
| 29 | return defined ( | ||||
| 30 | 59 | 207µs | 59 | 34µs | exists($test_for{$expected}) # spent 22µs making 48 calls to Params::Util::_CODELIKE, avg 456ns/call
# spent 7µs making 5 calls to Params::Util::_HASHLIKE, avg 1µs/call
# spent 4µs making 5 calls to Params::Util::_ARRAYLIKE, avg 840ns/call
# spent 700ns making 1 call to Params::Util::_SCALAR0 |
| 31 | ? $test_for{$expected}->($got) | ||||
| 32 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
| 33 | ); | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | # spent 6.11ms (5.09+1.02) within Data::OptList::mkopt which was called 310 times, avg 20µs/call:
# 67 times (540µs+8µs) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 8µs/call
# 58 times (1.91ms+311µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 38µs/call
# 56 times (794µs+61µs) by Moose::Meta::Class::_anon_cache_key at line 120 of Moose/Meta/Class.pm, avg 15µs/call
# 56 times (608µs+32µs) by Moose::Meta::Class::_anon_cache_key at line 126 of Moose/Meta/Class.pm, avg 11µs/call
# 38 times (303µs+1µs) by Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 8µs/call
# 21 times (252µs+18µs) by Moose::Util::_apply_all_roles at line 122 of Moose/Util.pm, avg 13µs/call
# 12 times (648µs+590µs) by Data::OptList::mkopt_hash at line 94, avg 103µs/call
# 2 times (30µs+2µs) by Class::Load::load_first_existing_class at line 45 of Class/Load.pm, avg 16µs/call | ||||
| 37 | 310 | 61µs | my ($opt_list) = shift; | ||
| 38 | |||||
| 39 | 310 | 6µs | my ($moniker, $require_unique, $must_be); # the old positional args | ||
| 40 | my $name_test; | ||||
| 41 | |||||
| 42 | 310 | 354µs | 135 | 68µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 68µs making 135 calls to Params::Util::_HASHLIKE, avg 507ns/call |
| 43 | 77 | 9µs | my $arg = $_[0]; | ||
| 44 | 77 | 98µs | ($moniker, $require_unique, $must_be, $name_test) | ||
| 45 | = @$arg{ qw(moniker require_unique must_be name_test) }; | ||||
| 46 | } else { | ||||
| 47 | 233 | 78µs | ($moniker, $require_unique, $must_be) = @_; | ||
| 48 | } | ||||
| 49 | |||||
| 50 | 310 | 50µs | $moniker = 'unnamed' unless defined $moniker; | ||
| 51 | |||||
| 52 | 310 | 8µs | return [] unless $opt_list; | ||
| 53 | |||||
| 54 | 774 | 1.13ms | # spent 431µs within Data::OptList::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Data/OptList.pm:54] which was called 464 times, avg 929ns/call:
# 464 times (431µs+0s) by Data::OptList::mkopt at line 71, avg 929ns/call | ||
| 55 | |||||
| 56 | $opt_list = [ | ||||
| 57 | 310 | 116µs | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||
| 58 | ] if ref $opt_list eq 'HASH'; | ||||
| 59 | |||||
| 60 | 310 | 17µs | my @return; | ||
| 61 | 310 | 14µs | my %seen; | ||
| 62 | |||||
| 63 | 310 | 264µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
| 64 | 672 | 122µs | my $name = $opt_list->[$i]; | ||
| 65 | 672 | 900ns | my $value; | ||
| 66 | |||||
| 67 | 672 | 30µs | if ($require_unique) { | ||
| 68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | 672 | 631µs | 469 | 437µs | if ($i == $#$opt_list) { $value = undef; } # spent 431µs making 464 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 929ns/call
# spent 5µs making 5 calls to Moose::Util::__ANON__[Moose/Util.pm:121], 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 | 54 | 13µs | else { $value = $opt_list->[++$i] } | ||
| 75 | |||||
| 76 | 672 | 68µs | if ($must_be and defined $value) { | ||
| 77 | 53 | 38µs | 53 | 518µs | unless (__is_a($value, $must_be)) { # spent 518µs making 53 calls to Data::OptList::__is_a, avg 10µs/call |
| 78 | my $ref = ref $value; | ||||
| 79 | Carp::croak "$ref-ref values are not valid in $moniker opt list"; | ||||
| 80 | } | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | 672 | 472µs | push @return, [ $name => $value ]; | ||
| 84 | } | ||||
| 85 | |||||
| 86 | 310 | 859µs | return \@return; | ||
| 87 | } | ||||
| 88 | |||||
| 89 | |||||
| 90 | # spent 1.35ms (116µs+1.24) within Data::OptList::mkopt_hash which was called 18 times, avg 75µs/call:
# 12 times (89µs+1.06ms) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 96µs/call
# 6 times (26µs+180µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 34µs/call | ||||
| 91 | 18 | 8µs | my ($opt_list, $moniker, $must_be) = @_; | ||
| 92 | 18 | 11µs | return {} unless $opt_list; | ||
| 93 | |||||
| 94 | 12 | 11µs | 12 | 1.24ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.24ms making 12 calls to Data::OptList::mkopt, avg 103µs/call |
| 95 | 12 | 45µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
| 96 | 12 | 36µs | return \%hash; | ||
| 97 | } | ||||
| 98 | |||||
| 99 | |||||
| 100 | # spent 14µs (8+6) within Data::OptList::BEGIN@100 which was called:
# once (8µs+6µs) by Class::Load::BEGIN@8 at line 104 | ||||
| 101 | 1 | 5µs | 1 | 6µs | *import = Sub::Install::exporter { # spent 6µs making 1 call to Sub::Install::exporter |
| 102 | exports => [qw(mkopt mkopt_hash)], | ||||
| 103 | }; | ||||
| 104 | 1 | 19µs | 1 | 14µs | } # spent 14µs making 1 call to Data::OptList::BEGIN@100 |
| 105 | |||||
| 106 | 1 | 5µs | 1; | ||
| 107 | |||||
| 108 | __END__ |