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