| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Data/OptList.pm |
| Statements | Executed 431 statements in 1.02ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.00ms | 1.22ms | Data::OptList::BEGIN@11 |
| 13 | 2 | 2 | 239µs | 405µs | Data::OptList::mkopt |
| 21 | 2 | 1 | 93µs | 144µs | Data::OptList::__is_a (recurses: max depth 1, inclusive time 68µs) |
| 12 | 2 | 1 | 64µs | 398µs | Data::OptList::mkopt_hash |
| 15 | 1 | 1 | 22µs | 22µs | Data::OptList::__ANON__[:54] |
| 1 | 1 | 1 | 11µs | 17µs | Data::OptList::BEGIN@100 |
| 1 | 1 | 1 | 11µs | 22µs | Sub::Exporter::BEGIN@1 |
| 1 | 1 | 1 | 7µs | 10µs | Sub::Exporter::BEGIN@2 |
| 1 | 1 | 1 | 6µs | 6µs | Data::OptList::BEGIN@15 |
| 1 | 1 | 1 | 4µs | 4µs | Data::OptList::BEGIN@10 |
| 1 | 1 | 1 | 4µs | 4µ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 | 22µs | 2 | 34µs | # spent 22µs (11+11) within Sub::Exporter::BEGIN@1 which was called:
# once (11µs+11µs) by Sub::Exporter::BEGIN@11 at line 1 # spent 22µs making 1 call to Sub::Exporter::BEGIN@1
# spent 11µs making 1 call to strict::import |
| 2 | 2 | 32µs | 2 | 14µs | # spent 10µs (7+4) within Sub::Exporter::BEGIN@2 which was called:
# once (7µs+4µs) by Sub::Exporter::BEGIN@11 at line 2 # spent 10µs making 1 call to Sub::Exporter::BEGIN@2
# spent 4µs making 1 call to warnings::import |
| 3 | package Data::OptList; | ||||
| 4 | { | ||||
| 5 | 2 | 900ns | $Data::OptList::VERSION = '0.109'; | ||
| 6 | } | ||||
| 7 | # ABSTRACT: parse and validate simple name/value option pairs | ||||
| 8 | |||||
| 9 | 2 | 17µs | 1 | 4µs | # spent 4µs within Data::OptList::BEGIN@9 which was called:
# once (4µs+0s) by Sub::Exporter::BEGIN@11 at line 9 # spent 4µs making 1 call to Data::OptList::BEGIN@9 |
| 10 | 2 | 17µs | 1 | 4µs | # spent 4µs within Data::OptList::BEGIN@10 which was called:
# once (4µs+0s) by Sub::Exporter::BEGIN@11 at line 10 # spent 4µs making 1 call to Data::OptList::BEGIN@10 |
| 11 | 3 | 107µs | 2 | 1.23ms | # spent 1.22ms (1.00+214µs) within Data::OptList::BEGIN@11 which was called:
# once (1.00ms+214µs) by Sub::Exporter::BEGIN@11 at line 11 # spent 1.22ms making 1 call to Data::OptList::BEGIN@11
# spent 9µs making 1 call to UNIVERSAL::VERSION |
| 12 | |||||
| 13 | |||||
| 14 | 1 | 100ns | my %test_for; | ||
| 15 | # spent 6µs within Data::OptList::BEGIN@15 which was called:
# once (6µs+0s) by Sub::Exporter::BEGIN@11 at line 22 | ||||
| 16 | 1 | 6µ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 | 345µs | 1 | 6µs | } # spent 6µs making 1 call to Data::OptList::BEGIN@15 |
| 23 | |||||
| 24 | sub __is_a { | ||||
| 25 | 21 | 5µs | my ($got, $expected) = @_; | ||
| 26 | |||||
| 27 | 33 | 65µs | 21 | 105µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 105µs making 9 calls to List::Util::first, avg 12µs/call
# spent 68µs making 12 calls to Data::OptList::__is_a, avg 6µs/call, recursion: max depth 1, sum of overlapping time 68µs |
| 28 | |||||
| 29 | return defined ( | ||||
| 30 | 12 | 72µs | 12 | 14µs | exists($test_for{$expected}) # spent 7µs making 3 calls to Params::Util::_HASHLIKE, avg 2µs/call
# spent 5µs making 6 calls to Params::Util::_CODELIKE, avg 817ns/call
# spent 2µs making 3 calls to Params::Util::_ARRAYLIKE, avg 767ns/call |
| 31 | ? $test_for{$expected}->($got) | ||||
| 32 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
| 33 | ); | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | # spent 405µs (239+165) within Data::OptList::mkopt which was called 13 times, avg 31µs/call:
# 8 times (174µs+160µs) by Data::OptList::mkopt_hash at line 94, avg 42µs/call
# 5 times (65µs+6µs) by Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 14µs/call | ||||
| 37 | 13 | 3µs | my ($opt_list) = shift; | ||
| 38 | |||||
| 39 | 13 | 1µs | my ($moniker, $require_unique, $must_be); # the old positional args | ||
| 40 | my $name_test; | ||||
| 41 | |||||
| 42 | 13 | 6µ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 | 13 | 8µs | ($moniker, $require_unique, $must_be) = @_; | ||
| 48 | } | ||||
| 49 | |||||
| 50 | 13 | 2µs | $moniker = 'unnamed' unless defined $moniker; | ||
| 51 | |||||
| 52 | 13 | 800ns | return [] unless $opt_list; | ||
| 53 | |||||
| 54 | 28 | 59µs | # spent 22µs within Data::OptList::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Data/OptList.pm:54] which was called 15 times, avg 1µs/call:
# 15 times (22µs+0s) by Data::OptList::mkopt at line 71, avg 1µs/call | ||
| 55 | |||||
| 56 | $opt_list = [ | ||||
| 57 | 13 | 12µs | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||
| 58 | ] if ref $opt_list eq 'HASH'; | ||||
| 59 | |||||
| 60 | 13 | 1µs | my @return; | ||
| 61 | 13 | 1µs | my %seen; | ||
| 62 | |||||
| 63 | 13 | 13µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
| 64 | 18 | 5µs | my $name = $opt_list->[$i]; | ||
| 65 | 18 | 400ns | my $value; | ||
| 66 | |||||
| 67 | 18 | 7µs | if ($require_unique) { | ||
| 68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | 18 | 30µs | 15 | 22µs | if ($i == $#$opt_list) { $value = undef; } # spent 22µs making 15 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 | 12 | 4µs | else { $value = $opt_list->[++$i] } | ||
| 75 | |||||
| 76 | 18 | 14µs | if ($must_be and defined $value) { | ||
| 77 | 9 | 10µs | 9 | 144µs | unless (__is_a($value, $must_be)) { # spent 144µs making 9 calls to Data::OptList::__is_a, avg 16µs/call |
| 78 | my $ref = ref $value; | ||||
| 79 | Carp::croak "$ref-ref values are not valid in $moniker opt list"; | ||||
| 80 | } | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | 18 | 18µs | push @return, [ $name => $value ]; | ||
| 84 | } | ||||
| 85 | |||||
| 86 | 13 | 47µs | return \@return; | ||
| 87 | } | ||||
| 88 | |||||
| 89 | |||||
| 90 | # spent 398µs (64+333) within Data::OptList::mkopt_hash which was called 12 times, avg 33µs/call:
# 8 times (49µs+222µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 34µs/call
# 4 times (16µs+111µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 32µs/call | ||||
| 91 | 12 | 6µs | my ($opt_list, $moniker, $must_be) = @_; | ||
| 92 | 12 | 9µs | return {} unless $opt_list; | ||
| 93 | |||||
| 94 | 8 | 8µs | 8 | 333µs | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 333µs making 8 calls to Data::OptList::mkopt, avg 42µs/call |
| 95 | 8 | 18µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
| 96 | 8 | 22µs | return \%hash; | ||
| 97 | } | ||||
| 98 | |||||
| 99 | |||||
| 100 | # spent 17µs (11+6) within Data::OptList::BEGIN@100 which was called:
# once (11µs+6µs) by Sub::Exporter::BEGIN@11 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 | 18µs | 1 | 17µs | } # spent 17µs making 1 call to Data::OptList::BEGIN@100 |
| 105 | |||||
| 106 | 1 | 2µs | 1; | ||
| 107 | |||||
| 108 | __END__ |