| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Data/OptList.pm |
| Statements | Executed 275 statements in 5.77ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 8.41ms | 9.93ms | Data::OptList::BEGIN@10 |
| 1 | 1 | 1 | 5.82ms | 6.97ms | Data::OptList::BEGIN@11 |
| 7 | 2 | 2 | 929µs | 1.58ms | Data::OptList::mkopt |
| 16 | 2 | 1 | 380µs | 575µs | Data::OptList::__is_a (recurses: max depth 1, inclusive time 251µs) |
| 6 | 2 | 1 | 182µs | 1.62ms | Data::OptList::mkopt_hash |
| 10 | 1 | 1 | 74µs | 74µs | Data::OptList::__ANON__[:54] |
| 1 | 1 | 1 | 57µs | 67µs | Sub::Exporter::BEGIN@1 |
| 1 | 1 | 1 | 53µs | 91µs | Data::OptList::BEGIN@100 |
| 1 | 1 | 1 | 27µs | 47µs | Sub::Exporter::BEGIN@2 |
| 1 | 1 | 1 | 27µs | 27µs | Data::OptList::BEGIN@15 |
| 1 | 1 | 1 | 14µs | 14µs | Data::OptList::BEGIN@9 |
| 1 | 1 | 1 | 14µs | 14µs | Data::OptList::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Data::OptList::__ANON__[:27] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 92µs | 2 | 76µs | # spent 67µs (57+10) within Sub::Exporter::BEGIN@1 which was called:
# once (57µs+10µs) by Sub::Exporter::BEGIN@7 at line 1 # spent 67µs making 1 call to Sub::Exporter::BEGIN@1
# spent 10µs making 1 call to strict::import |
| 2 | 2 | 146µs | 2 | 66µs | # spent 47µs (27+19) within Sub::Exporter::BEGIN@2 which was called:
# once (27µs+19µs) by Sub::Exporter::BEGIN@7 at line 2 # spent 47µs making 1 call to Sub::Exporter::BEGIN@2
# spent 19µs making 1 call to warnings::import |
| 3 | package Data::OptList; | ||||
| 4 | # spent 14µs within Data::OptList::BEGIN@4 which was called:
# once (14µs+0s) by Sub::Exporter::BEGIN@7 at line 6 | ||||
| 5 | 1 | 15µs | $Data::OptList::VERSION = '0.107'; | ||
| 6 | 1 | 71µs | 1 | 14µs | } # spent 14µs making 1 call to Data::OptList::BEGIN@4 |
| 7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
| 8 | |||||
| 9 | 2 | 82µs | 1 | 14µs | # spent 14µs within Data::OptList::BEGIN@9 which was called:
# once (14µs+0s) by Sub::Exporter::BEGIN@7 at line 9 # spent 14µs making 1 call to Data::OptList::BEGIN@9 |
| 10 | 2 | 569µs | 1 | 9.93ms | # spent 9.93ms (8.41+1.52) within Data::OptList::BEGIN@10 which was called:
# once (8.41ms+1.52ms) by Sub::Exporter::BEGIN@7 at line 10 # spent 9.93ms making 1 call to Data::OptList::BEGIN@10 |
| 11 | 3 | 850µs | 2 | 7.04ms | # spent 6.97ms (5.82+1.15) within Data::OptList::BEGIN@11 which was called:
# once (5.82ms+1.15ms) by Sub::Exporter::BEGIN@7 at line 11 # spent 6.97ms making 1 call to Data::OptList::BEGIN@11
# spent 69µs making 1 call to UNIVERSAL::VERSION |
| 12 | |||||
| 13 | |||||
| 14 | 1 | 800ns | my %test_for; | ||
| 15 | # spent 27µs within Data::OptList::BEGIN@15 which was called:
# once (27µs+0s) by Sub::Exporter::BEGIN@7 at line 22 | ||||
| 16 | 1 | 27µ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 | 1.98ms | 1 | 27µs | } # spent 27µs making 1 call to Data::OptList::BEGIN@15 |
| 23 | |||||
| 24 | sub __is_a { | ||||
| 25 | 41 | 416µs | my ($got, $expected) = @_; | ||
| 26 | |||||
| 27 | 9 | 165µs | 16 | 403µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 403µs making 7 calls to List::Util::first, avg 58µs/call
# spent 251µs making 9 calls to Data::OptList::__is_a, avg 28µs/call, recursion: max depth 1, sum of overlapping time 251µs |
| 28 | |||||
| 29 | return defined ( | ||||
| 30 | 9 | 43µs | exists($test_for{$expected}) # spent 21µs making 5 calls to Params::Util::_CODELIKE, avg 4µs/call
# spent 14µs making 2 calls to Params::Util::_HASHLIKE, avg 7µs/call
# spent 8µs making 2 calls to Params::Util::_ARRAYLIKE, avg 4µs/call | ||
| 31 | ? $test_for{$expected}->($got) | ||||
| 32 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
| 33 | ); | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | # spent 1.58ms (929µs+649µs) within Data::OptList::mkopt which was called 7 times, avg 225µs/call:
# 5 times (797µs+642µs) by Data::OptList::mkopt_hash at line 94, avg 288µs/call
# 2 times (133µs+7µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Sub/Exporter.pm:756] at line 735 of Sub/Exporter.pm, avg 70µs/call | ||||
| 37 | 84 | 367µs | my ($opt_list) = shift; | ||
| 38 | |||||
| 39 | my ($moniker, $require_unique, $must_be); # the old positional args | ||||
| 40 | my $name_test; | ||||
| 41 | |||||
| 42 | 7 | 28µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { | ||
| 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 | 10 | 306µs | # spent 74µs within Data::OptList::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Data/OptList.pm:54] which was called 10 times, avg 7µs/call:
# 10 times (74µs+0s) by Data::OptList::mkopt at line 71, avg 7µ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 | 66 | 280µs | 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 | 8 | 16µs | 10 | 74µs | if ($i == $#$opt_list) { $value = undef; } # spent 74µs making 10 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 7µ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 | 7 | 43µs | if ($must_be and defined $value) { | ||
| 77 | 7 | 575µs | unless (__is_a($value, $must_be)) { # spent 575µs making 7 calls to Data::OptList::__is_a, avg 82µ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.62ms (182µs+1.44) within Data::OptList::mkopt_hash which was called 6 times, avg 270µs/call:
# 4 times (126µs+1.05ms) by Sub::Exporter::_rewrite_build_config at line 672 of Sub/Exporter.pm, avg 295µs/call
# 2 times (56µs+386µs) by Sub::Exporter::_rewrite_build_config at line 685 of Sub/Exporter.pm, avg 221µs/call | ||||
| 91 | 27 | 186µs | my ($opt_list, $moniker, $must_be) = @_; | ||
| 92 | return {} unless $opt_list; | ||||
| 93 | |||||
| 94 | 5 | 1.44ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.44ms making 5 calls to Data::OptList::mkopt, avg 288µs/call | ||
| 95 | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||||
| 96 | return \%hash; | ||||
| 97 | } | ||||
| 98 | |||||
| 99 | |||||
| 100 | # spent 91µs (53+37) within Data::OptList::BEGIN@100 which was called:
# once (53µs+37µs) by Sub::Exporter::BEGIN@7 at line 104 | ||||
| 101 | 1 | 32µs | 1 | 37µs | *import = Sub::Install::exporter { # spent 37µs making 1 call to Sub::Install::exporter |
| 102 | exports => [qw(mkopt mkopt_hash)], | ||||
| 103 | }; | ||||
| 104 | 1 | 81µs | 1 | 91µs | } # spent 91µs making 1 call to Data::OptList::BEGIN@100 |
| 105 | |||||
| 106 | 1 | 10µs | 1; | ||
| 107 | |||||
| 108 | __END__ |