Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/OptList.pm |
Statements | Executed 301 statements in 1.31ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.73ms | 2.11ms | BEGIN@10 | Data::OptList::
1 | 1 | 1 | 1.37ms | 1.70ms | BEGIN@11 | Data::OptList::
9 | 3 | 2 | 205µs | 362µs | mkopt | Data::OptList::
16 | 2 | 1 | 88µs | 140µs | __is_a (recurses: max depth 1, inclusive time 60µs) | Data::OptList::
6 | 2 | 1 | 49µs | 358µs | mkopt_hash | Data::OptList::
10 | 1 | 1 | 16µs | 16µs | __ANON__[:54] | Data::OptList::
1 | 1 | 1 | 13µs | 28µs | BEGIN@1 | Sub::Exporter::
1 | 1 | 1 | 12µs | 20µs | BEGIN@100 | Data::OptList::
1 | 1 | 1 | 12µs | 16µs | BEGIN@2 | Sub::Exporter::
1 | 1 | 1 | 8µs | 8µs | BEGIN@15 | Data::OptList::
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 | 27µs | 2 | 42µs | # spent 28µs (13+14) within Sub::Exporter::BEGIN@1 which was called:
# once (13µs+14µs) by Sub::Exporter::BEGIN@11 at line 1 # spent 28µs making 1 call to Sub::Exporter::BEGIN@1
# spent 14µs making 1 call to strict::import |
2 | 2 | 37µs | 2 | 21µs | # spent 16µs (12+5) within Sub::Exporter::BEGIN@2 which was called:
# once (12µs+5µs) by Sub::Exporter::BEGIN@11 at line 2 # spent 16µs making 1 call to Sub::Exporter::BEGIN@2
# spent 5µ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 Sub::Exporter::BEGIN@11 at line 6 | ||||
5 | 1 | 5µs | $Data::OptList::VERSION = '0.107'; | ||
6 | 1 | 16µ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 | 23µs | 1 | 3µs | # spent 3µs within Data::OptList::BEGIN@9 which was called:
# once (3µs+0s) by Sub::Exporter::BEGIN@11 at line 9 # spent 3µs making 1 call to Data::OptList::BEGIN@9 |
10 | 2 | 118µs | 1 | 2.11ms | # spent 2.11ms (1.73+388µs) within Data::OptList::BEGIN@10 which was called:
# once (1.73ms+388µs) by Sub::Exporter::BEGIN@11 at line 10 # spent 2.11ms making 1 call to Data::OptList::BEGIN@10 |
11 | 3 | 159µs | 2 | 1.72ms | # spent 1.70ms (1.37+333µs) within Data::OptList::BEGIN@11 which was called:
# once (1.37ms+333µs) by Sub::Exporter::BEGIN@11 at line 11 # spent 1.70ms making 1 call to Data::OptList::BEGIN@11
# spent 14µs making 1 call to UNIVERSAL::VERSION |
12 | |||||
13 | |||||
14 | 1 | 200ns | my %test_for; | ||
15 | # spent 8µs within Data::OptList::BEGIN@15 which was called:
# once (8µs+0s) by Sub::Exporter::BEGIN@11 at line 22 | ||||
16 | 1 | 13µ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 | 445µs | 1 | 8µs | } # spent 8µs making 1 call to Data::OptList::BEGIN@15 |
23 | |||||
24 | sub __is_a { | ||||
25 | 16 | 7µs | my ($got, $expected) = @_; | ||
26 | |||||
27 | 25 | 73µs | 16 | 103µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 103µs making 7 calls to List::Util::first, avg 15µs/call
# spent 60µs making 9 calls to Data::OptList::__is_a, avg 7µs/call, recursion: max depth 1, sum of overlapping time 60µs |
28 | |||||
29 | return defined ( | ||||
30 | 9 | 64µs | 9 | 9µs | exists($test_for{$expected}) # spent 4µs making 5 calls to Params::Util::_CODELIKE, avg 780ns/call
# spent 3µs making 2 calls to Params::Util::_HASHLIKE, avg 2µs/call
# spent 1µs making 2 calls to Params::Util::_ARRAYLIKE, avg 700ns/call |
31 | ? $test_for{$expected}->($got) | ||||
32 | : Params::Util::_INSTANCE($got, $expected) ## no critic | ||||
33 | ); | ||||
34 | } | ||||
35 | |||||
36 | # spent 362µs (205+157) within Data::OptList::mkopt which was called 9 times, avg 40µs/call:
# 5 times (154µs+154µs) by Data::OptList::mkopt_hash at line 94, avg 62µs/call
# 3 times (40µs+2µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 14µs/call
# once (11µs+700ns) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm | ||||
37 | 9 | 4µs | my ($opt_list) = shift; | ||
38 | |||||
39 | 9 | 2µs | my ($moniker, $require_unique, $must_be); # the old positional args | ||
40 | 9 | 1µs | my $name_test; | ||
41 | |||||
42 | 9 | 10µs | 1 | 700ns | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 700ns making 1 call to Params::Util::_HASHLIKE |
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 | 9 | 8µs | ($moniker, $require_unique, $must_be) = @_; | ||
48 | } | ||||
49 | |||||
50 | 9 | 3µs | $moniker = 'unnamed' unless defined $moniker; | ||
51 | |||||
52 | 9 | 1µs | return [] unless $opt_list; | ||
53 | |||||
54 | 19 | 50µs | # spent 16µs within Data::OptList::__ANON__[/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/OptList.pm:54] which was called 10 times, avg 2µs/call:
# 10 times (16µs+0s) by Data::OptList::mkopt at line 71, avg 2µs/call | ||
55 | |||||
56 | $opt_list = [ | ||||
57 | 9 | 14µs | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list | ||
58 | ] if ref $opt_list eq 'HASH'; | ||||
59 | |||||
60 | 9 | 2µs | my @return; | ||
61 | 9 | 2µs | my %seen; | ||
62 | |||||
63 | 9 | 15µs | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic | ||
64 | 11 | 5µs | my $name = $opt_list->[$i]; | ||
65 | 11 | 2µs | my $value; | ||
66 | |||||
67 | 11 | 8µs | if ($require_unique) { | ||
68 | Carp::croak "multiple definitions provided for $name" if $seen{$name}++; | ||||
69 | } | ||||
70 | |||||
71 | 11 | 25µs | 10 | 16µs | if ($i == $#$opt_list) { $value = undef; } # spent 16µs making 10 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 2µs/call |
72 | elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ } | ||||
73 | elsif ($name_test->($opt_list->[$i+1])) { $value = undef; } | ||||
74 | 8 | 4µs | else { $value = $opt_list->[++$i] } | ||
75 | |||||
76 | 11 | 13µs | if ($must_be and defined $value) { | ||
77 | 7 | 10µs | 7 | 140µs | unless (__is_a($value, $must_be)) { # spent 140µs making 7 calls to Data::OptList::__is_a, avg 20µs/call |
78 | my $ref = ref $value; | ||||
79 | Carp::croak "$ref-ref values are not valid in $moniker opt list"; | ||||
80 | } | ||||
81 | } | ||||
82 | |||||
83 | 11 | 14µs | push @return, [ $name => $value ]; | ||
84 | } | ||||
85 | |||||
86 | 9 | 45µs | return \@return; | ||
87 | } | ||||
88 | |||||
89 | |||||
90 | # spent 358µs (49+308) within Data::OptList::mkopt_hash which was called 6 times, avg 60µs/call:
# 4 times (34µs+212µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 62µs/call
# 2 times (15µs+97µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 56µs/call | ||||
91 | 6 | 5µs | my ($opt_list, $moniker, $must_be) = @_; | ||
92 | 6 | 4µs | return {} unless $opt_list; | ||
93 | |||||
94 | 5 | 6µs | 5 | 308µs | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 308µs making 5 calls to Data::OptList::mkopt, avg 62µs/call |
95 | 5 | 17µs | my %hash = map { $_->[0] => $_->[1] } @$opt_list; | ||
96 | 5 | 18µs | return \%hash; | ||
97 | } | ||||
98 | |||||
99 | |||||
100 | # spent 20µs (12+8) within Data::OptList::BEGIN@100 which was called:
# once (12µs+8µs) by Sub::Exporter::BEGIN@11 at line 104 | ||||
101 | 1 | 7µs | 1 | 8µs | *import = Sub::Install::exporter { # spent 8µs making 1 call to Sub::Install::exporter |
102 | exports => [qw(mkopt mkopt_hash)], | ||||
103 | }; | ||||
104 | 1 | 20µs | 1 | 20µs | } # spent 20µs making 1 call to Data::OptList::BEGIN@100 |
105 | |||||
106 | 1 | 2µs | 1; | ||
107 | |||||
108 | __END__ |