Profile of Data/OptList.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename | /usr/local/share/perl/5.18.2/Data/OptList.pm
Statements | Executed 21837 statements in 24.3ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
844 | 7 | 4 | 15.8ms | 17.6ms | Data::OptList::::mkoptData::OptList::mkopt
1 | 1 | 1 | 3.47ms | 4.28ms | Data::OptList::::BEGIN@10Data::OptList::BEGIN@10
1 | 1 | 1 | 1.07ms | 1.30ms | Data::OptList::::BEGIN@11Data::OptList::BEGIN@11
1047 | 1 | 1 | 784µs | 784µs | Data::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
136 | 2 | 1 | 489µs | 723µs | Data::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 277µs)
33 | 2 | 1 | 203µs | 1.84ms | Data::OptList::::mkopt_hashData::OptList::mkopt_hash
1 | 1 | 1 | 9µs | 18µs | Class::Load::::BEGIN@1 Class::Load::BEGIN@1
1 | 1 | 1 | 9µs | 16µs | Data::OptList::::BEGIN@100Data::OptList::BEGIN@100
1 | 1 | 1 | 6µs | 9µs | Class::Load::::BEGIN@2.1 Class::Load::BEGIN@2.1
1 | 1 | 1 | 5µs | 5µs | Data::OptList::::BEGIN@15Data::OptList::BEGIN@15
1 | 1 | 1 | 4µs | 4µs | Data::OptList::::BEGIN@9Data::OptList::BEGIN@9
0 | 0 | 0 | 0s | 0s | Data::OptList::::__ANON__[:27]Data::OptList::__ANON__[:27]

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 | 2 | 18µs | 2 | 26µs | # spent 18µs (9+9) within Class::Load::BEGIN@1 which was called: # once (9µs+9µs) by Class::Load::BEGIN@10 at line 1 use strict; # spent 18µs making 1 call to Class::Load::BEGIN@1 # spent 9µs making 1 call to strict::import
2 | 2 | 34µs | 2 | 12µs | # spent 9µs (6+3) within Class::Load::BEGIN@2.1 which was called: # once (6µs+3µs) by Class::Load::BEGIN@10 at line 2 use warnings; # spent 9µs making 1 call to Class::Load::BEGIN@2.1 # spent 3µs making 1 call to warnings::import
3 |  |  |  |  | package Data::OptList;
4 |  |  |  |  | {
5 | 2 | 800ns |  |  | $Data::OptList::VERSION = '0.109';
6 |  |  |  |  | }
7 |  |  |  |  | # ABSTRACT: parse and validate simple name/value option pairs
8 |  |  |  |  |
9 | 2 | 16µs | 1 | 4µs | # spent 4µs within Data::OptList::BEGIN@9 which was called: # once (4µs+0s) by Class::Load::BEGIN@10 at line 9 use List::Util (); # spent 4µs making 1 call to Data::OptList::BEGIN@9
10 | 2 | 102µs | 1 | 4.28ms | # spent 4.28ms (3.47+807µs) within Data::OptList::BEGIN@10 which was called: # once (3.47ms+807µs) by Class::Load::BEGIN@10 at line 10 use Params::Util (); # spent 4.28ms making 1 call to Data::OptList::BEGIN@10
11 | 3 | 100µs | 2 | 1.31ms | # spent 1.30ms (1.07+225µs) within Data::OptList::BEGIN@11 which was called: # once (1.07ms+225µs) by Class::Load::BEGIN@10 at line 11 use Sub::Install 0.921 (); # spent 1.30ms 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 Class::Load::BEGIN@10 at line 22 BEGIN {
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 | 346µs | 1 | 5µs | } # spent 5µs making 1 call to Data::OptList::BEGIN@15
23 |  |  |  |  |
24 |  |  |  |  | # spent 723µs (489+234) within Data::OptList::__is_a which was called 136 times, avg 5µs/call: # 75 times (229µs+-229µs) by List::Util::first at line 27, avg 0s/call # 61 times (260µs+463µs) by Data::OptList::mkopt at line 77, avg 12µs/call sub __is_a {
25 | 136 | 29µs |  |  | my ($got, $expected) = @_;
26 |  |  |  |  |
27 | 211 | 398µs | 136 | 463µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 463µs making 61 calls to List::Util::first, avg 8µs/call # spent 277µs making 75 calls to Data::OptList::__is_a, avg 4µs/call, recursion: max depth 1, sum of overlapping time 277µs
28 |  |  |  |  |
29 |  |  |  |  | return defined (
30 | 75 | 326µs | 75 | 48µs | exists($test_for{$expected}) # spent 32µs making 54 calls to Params::Util::_CODELIKE, avg 594ns/call # spent 8µs making 7 calls to Params::Util::_HASHLIKE, avg 1µs/call # spent 5µs making 7 calls to Params::Util::_ARRAYLIKE, avg 700ns/call # spent 3µs making 7 calls to Params::Util::_SCALAR0, avg 443ns/call
31 |  |  |  |  | ? $test_for{$expected}->($got)
32 |  |  |  |  | : Params::Util::_INSTANCE($got, $expected) ## no critic
33 |  |  |  |  | );
34 |  |  |  |  | }
35 |  |  |  |  |
36 |  |  |  |  | # spent 17.6ms (15.8+1.81) within Data::OptList::mkopt which was called 844 times, avg 21µs/call: # 261 times (1.89ms+8µs) by Moose::Meta::Class::superclasses at line 554 of Moose/Meta/Class.pm, avg 7µs/call # 140 times (7.80ms+632µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 60µs/call # 132 times (1.98ms+113µs) by Moose::Meta::Class::_anon_cache_key at line 105 of Moose/Meta/Class.pm, avg 16µs/call # 132 times (1.43ms+131µs) by Moose::Meta::Class::_anon_cache_key at line 111 of Moose/Meta/Class.pm, avg 12µs/call # 118 times (1.08ms+12µs) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.18.2/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 9µs/call # 42 times (753µs+90µs) by Moose::Util::_apply_all_roles at line 137 of Moose/Util.pm, avg 20µs/call # 19 times (818µs+823µs) by Data::OptList::mkopt_hash at line 94, avg 86µs/call sub mkopt {
37 | 844 | 227µs |  |  | my ($opt_list) = shift;
38 |  |  |  |  |
39 | 844 | 122µs |  |  | my ($moniker, $require_unique, $must_be); # the old positional args
40 |  |  |  |  | my $name_test;
41 |  |  |  |  |
42 | 844 | 1.34ms | 314 | 250µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 250µs making 314 calls to Params::Util::_HASHLIKE, avg 796ns/call
43 | 174 | 41µs |  |  | my $arg = $_[0];
44 | 174 | 361µs |  |  | ($moniker, $require_unique, $must_be, $name_test)
45 |  |  |  |  | = @$arg{ qw(moniker require_unique must_be name_test) };
46 |  |  |  |  | } else {
47 | 670 | 251µs |  |  | ($moniker, $require_unique, $must_be) = @_;
48 |  |  |  |  | }
49 |  |  |  |  |
50 | 844 | 221µs |  |  | $moniker = 'unnamed' unless defined $moniker;
51 |  |  |  |  |
52 | 844 | 98µs |  |  | return [] unless $opt_list;
53 |  |  |  |  |
54 | 1891 | 6.67ms |  |  | # spent 784µs within Data::OptList::__ANON__[/usr/local/share/perl/5.18.2/Data/OptList.pm:54] which was called 1047 times, avg 749ns/call: # 1047 times (784µs+0s) by Data::OptList::mkopt at line 71, avg 749ns/call $name_test ||= sub { ! ref $_[0] };
55 |  |  |  |  |
56 |  |  |  |  | $opt_list = [
57 | 844 | 340µs |  |  | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 |  |  |  |  | ] if ref $opt_list eq 'HASH';
59 |  |  |  |  |
60 | 844 | 93µs |  |  | my @return;
61 | 844 | 97µs |  |  | my %seen;
62 |  |  |  |  |
63 | 844 | 1.06ms |  |  | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64 | 1633 | 575µs |  |  | my $name = $opt_list->[$i];
65 | 1633 | 110µs |  |  | my $value;
66 |  |  |  |  |
67 | 1633 | 188µs |  |  | if ($require_unique) {
68 |  |  |  |  | Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 |  |  |  |  | }
70 |  |  |  |  |
71 | 1633 | 1.62ms | 1097 | 836µs | if ($i == $#$opt_list) { $value = undef; } # spent 784µs making 1047 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 749ns/call # spent 52µs making 50 calls to Moose::Util::__ANON__[Moose/Util.pm:136], 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 | 67 | 21µs |  |  | else { $value = $opt_list->[++$i] }
75 |  |  |  |  |
76 | 1633 | 187µs |  |  | if ($must_be and defined $value) {
77 | 61 | 51µs | 61 | 723µs | unless (__is_a($value, $must_be)) { # spent 723µs making 61 calls to Data::OptList::__is_a, avg 12µs/call
78 |  |  |  |  | my $ref = ref $value;
79 |  |  |  |  | Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 |  |  |  |  | }
81 |  |  |  |  | }
82 |  |  |  |  |
83 | 1633 | 1.24ms |  |  | push @return, [ $name => $value ];
84 |  |  |  |  | }
85 |  |  |  |  |
86 | 844 | 7.80ms |  |  | return \@return;
87 |  |  |  |  | }
88 |  |  |  |  |
89 |  |  |  |  |
90 |  |  |  |  | # spent 1.84ms (203µs+1.64) within Data::OptList::mkopt_hash which was called 33 times, avg 56µs/call: # 22 times (163µs+1.39ms) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 71µs/call # 11 times (40µs+252µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 27µs/call sub mkopt_hash {
91 | 33 | 22µs |  |  | my ($opt_list, $moniker, $must_be) = @_;
92 | 33 | 34µs |  |  | return {} unless $opt_list;
93 |  |  |  |  |
94 | 19 | 20µs | 19 | 1.64ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.64ms making 19 calls to Data::OptList::mkopt, avg 86µs/call
95 | 19 | 84µs |  |  | my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96 | 19 | 53µs |  |  | return \%hash;
97 |  |  |  |  | }
98 |  |  |  |  |
99 |  |  |  |  |
100 |  |  |  |  | # spent 16µs (9+7) within Data::OptList::BEGIN@100 which was called: # once (9µs+7µs) by Class::Load::BEGIN@10 at line 104 BEGIN {
101 | 1 | 5µs | 1 | 7µs | *import = Sub::Install::exporter { # spent 7µs making 1 call to Sub::Install::exporter
102 |  |  |  |  | exports => [qw(mkopt mkopt_hash)],
103 |  |  |  |  | };
104 | 1 | 17µs | 1 | 16µs | } # spent 16µs making 1 call to Data::OptList::BEGIN@100
105 |  |  |  |  |
106 | 1 | 2µs |  |  | 1;
107 |  |  |  |  |
108 |  |  |  |  | __END__