Profile of Data/OptList.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:25 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Data/OptList.pm
Statements | Executed 4813 statements in 5.64ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 3.99ms | 6.98ms | Data::OptList::::BEGIN@10Data::OptList::BEGIN@10
155 | 5 | 4 | 3.45ms | 4.47ms | Data::OptList::::mkoptData::OptList::mkopt
1 | 1 | 1 | 1.08ms | 1.34ms | Data::OptList::::BEGIN@11Data::OptList::BEGIN@11
120 | 2 | 1 | 476µs | 738µs | Data::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 308µs)
241 | 1 | 1 | 249µs | 249µs | Data::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
30 | 2 | 1 | 237µs | 1.93ms | Data::OptList::::mkopt_hashData::OptList::mkopt_hash
1 | 1 | 1 | 11µs | 24µs | Class::Load::::BEGIN@2 Class::Load::BEGIN@2
1 | 1 | 1 | 10µs | 13µs | Class::Load::::BEGIN@1 Class::Load::BEGIN@1
1 | 1 | 1 | 8µs | 19µs | Data::OptList::::BEGIN@100Data::OptList::BEGIN@100
1 | 1 | 1 | 8µs | 8µs | Data::OptList::::BEGIN@15Data::OptList::BEGIN@15
1 | 1 | 1 | 3µs | 3µs | Data::OptList::::BEGIN@9Data::OptList::BEGIN@9
1 | 1 | 1 | 3µs | 3µs | Data::OptList::::BEGIN@4Data::OptList::BEGIN@4
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 | 3 | 20µs | 2 | 16µs | # spent 13µs (10+3) within Class::Load::BEGIN@1 which was called: # once (10µs+3µs) by Class::Load::BEGIN@8 at line 1 use strict; # spent 13µs making 1 call to Class::Load::BEGIN@1 # spent 3µs making 1 call to strict::import
2 | 3 | 29µs | 2 | 37µs | # spent 24µs (11+13) within Class::Load::BEGIN@2 which was called: # once (11µs+13µs) by Class::Load::BEGIN@8 at line 2 use warnings; # spent 24µs making 1 call to Class::Load::BEGIN@2 # spent 13µ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 Class::Load::BEGIN@8 at line 6 BEGIN {
5 | 1 | 7µs |  |  | $Data::OptList::VERSION = '0.107';
6 | 1 | 12µ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 | 3 | 17µs | 1 | 3µs | # spent 3µs within Data::OptList::BEGIN@9 which was called: # once (3µs+0s) by Class::Load::BEGIN@8 at line 9 use List::Util (); # spent 3µs making 1 call to Data::OptList::BEGIN@9
10 | 3 | 101µs | 1 | 6.98ms | # spent 6.98ms (3.99+2.99) within Data::OptList::BEGIN@10 which was called: # once (3.99ms+2.99ms) by Class::Load::BEGIN@8 at line 10 use Params::Util (); # spent 6.98ms making 1 call to Data::OptList::BEGIN@10
11 | 3 | 153µs | 2 | 1.36ms | # spent 1.34ms (1.08+261µs) within Data::OptList::BEGIN@11 which was called: # once (1.08ms+261µs) by Class::Load::BEGIN@8 at line 11 use Sub::Install 0.921 (); # spent 1.34ms making 1 call to Data::OptList::BEGIN@11 # spent 21µ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 Class::Load::BEGIN@8 at line 22 BEGIN {
16 | 1 | 8µ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 | 350µs | 1 | 8µs | } # spent 8µs making 1 call to Data::OptList::BEGIN@15
23 |  |  |  |  |
24 |  |  |  |  | # spent 738µs (476+262) within Data::OptList::__is_a which was called 120 times, avg 6µs/call: # 64 times (245µs+-245µs) by List::Util::first at line 27, avg 0s/call # 56 times (231µs+507µs) by Data::OptList::mkopt at line 77, avg 13µs/call sub __is_a {
25 | 120 | 48µs |  |  | my ($got, $expected) = @_;
26 |  |  |  |  |
27 | 184 | 399µs | 120 | 507µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 507µs making 56 calls to List::Util::first, avg 9µs/call # spent 308µs making 64 calls to Data::OptList::__is_a, avg 5µs/call, recursion: max depth 1, sum of overlapping time 308µs
28 |  |  |  |  |
29 |  |  |  |  | return defined (
30 | 64 | 314µs | 64 | 63µs | exists($test_for{$expected}) # spent 39µs making 48 calls to Params::Util::_CODELIKE, avg 821ns/call # spent 12µs making 8 calls to Params::Util::_HASHLIKE, avg 1µs/call # spent 11µs making 8 calls to Params::Util::_ARRAYLIKE, avg 1µs/call
31 |  |  |  |  | ? $test_for{$expected}->($got)
32 |  |  |  |  | : Params::Util::_INSTANCE($got, $expected) ## no critic
33 |  |  |  |  | );
34 |  |  |  |  | }
35 |  |  |  |  |
36 |  |  |  |  | # spent 4.47ms (3.45+1.02) within Data::OptList::mkopt which was called 155 times, avg 29µs/call: # 63 times (826µs+0s) by Moose::Meta::Class::superclasses at line 551 of Moose/Meta/Class.pm, avg 13µs/call # 35 times (1.17ms+180µs) by Sub::Exporter::_expand_group at line 505 of Sub/Exporter.pm, avg 39µs/call # 34 times (469µs+10µs) by Sub::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Sub/Exporter.pm:756] at line 735 of Sub/Exporter.pm, avg 14µs/call # 19 times (870µs+822µs) by Data::OptList::mkopt_hash at line 94, avg 89µs/call # 4 times (108µs+11µs) by Moose::Util::_apply_all_roles at line 122 of Moose/Util.pm, avg 30µs/call sub mkopt {
37 | 155 | 71µs |  |  | my ($opt_list) = shift;
38 |  |  |  |  |
39 | 155 | 49µs |  |  | my ($moniker, $require_unique, $must_be); # the old positional args
40 | 155 | 32µs |  |  | my $name_test;
41 |  |  |  |  |
42 | 155 | 245µs | 39 | 34µs | if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) { # spent 34µs making 39 calls to Params::Util::_HASHLIKE, avg 877ns/call
43 | 4 | 2µs |  |  | my $arg = $_[0];
44 | 4 | 16µs |  |  | ($moniker, $require_unique, $must_be, $name_test)
45 |  |  |  |  | = @$arg{ qw(moniker require_unique must_be name_test) };
46 |  |  |  |  | } else {
47 | 151 | 113µs |  |  | ($moniker, $require_unique, $must_be) = @_;
48 |  |  |  |  | }
49 |  |  |  |  |
50 | 155 | 68µs |  |  | $moniker = 'unnamed' unless defined $moniker;
51 |  |  |  |  |
52 | 155 | 36µs |  |  | return [] unless $opt_list;
53 |  |  |  |  |
54 | 396 | 772µs |  |  | # spent 249µs within Data::OptList::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Data/OptList.pm:54] which was called 241 times, avg 1µs/call: # 241 times (249µs+0s) by Data::OptList::mkopt at line 71, avg 1µs/call $name_test ||= sub { ! ref $_[0] };
55 |  |  |  |  |
56 |  |  |  |  | $opt_list = [
57 | 155 | 156µs |  |  | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 |  |  |  |  | ] if ref $opt_list eq 'HASH';
59 |  |  |  |  |
60 | 155 | 32µs |  |  | my @return;
61 | 155 | 40µs |  |  | my %seen;
62 |  |  |  |  |
63 | 155 | 263µs |  |  | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64 | 296 | 136µs |  |  | my $name = $opt_list->[$i];
65 | 296 | 44µs |  |  | my $value;
66 |  |  |  |  |
67 | 296 | 88µs |  |  | if ($require_unique) {
68 |  |  |  |  | Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 |  |  |  |  | }
70 |  |  |  |  |
71 | 296 | 459µs | 241 | 249µs | if ($i == $#$opt_list) { $value = undef; } # spent 249µs making 241 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 | 61 | 22µs |  |  | else { $value = $opt_list->[++$i] }
75 |  |  |  |  |
76 | 296 | 103µs |  |  | if ($must_be and defined $value) {
77 | 56 | 66µs | 56 | 738µs | unless (__is_a($value, $must_be)) { # spent 738µs making 56 calls to Data::OptList::__is_a, avg 13µs/call
78 |  |  |  |  | my $ref = ref $value;
79 |  |  |  |  | Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 |  |  |  |  | }
81 |  |  |  |  | }
82 |  |  |  |  |
83 | 296 | 306µs |  |  | push @return, [ $name => $value ];
84 | 155 | 50µs |  |  | }
85 |  |  |  |  |
86 | 155 | 758µs |  |  | return \@return;
87 |  |  |  |  | }
88 |  |  |  |  |
89 |  |  |  |  |
90 |  |  |  |  | # spent 1.93ms (237µs+1.69) within Data::OptList::mkopt_hash which was called 30 times, avg 64µs/call: # 20 times (184µs+1.33ms) by Sub::Exporter::_rewrite_build_config at line 672 of Sub/Exporter.pm, avg 76µs/call # 10 times (53µs+362µs) by Sub::Exporter::_rewrite_build_config at line 685 of Sub/Exporter.pm, avg 42µs/call sub mkopt_hash {
91 | 30 | 24µs |  |  | my ($opt_list, $moniker, $must_be) = @_;
92 | 30 | 26µs |  |  | return {} unless $opt_list;
93 |  |  |  |  |
94 | 19 | 27µs | 19 | 1.69ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.69ms making 19 calls to Data::OptList::mkopt, avg 89µs/call
95 | 19 | 93µs |  |  | my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96 | 19 | 68µs |  |  | return \%hash;
97 |  |  |  |  | }
98 |  |  |  |  |
99 |  |  |  |  |
100 |  |  |  |  | # spent 19µs (8+12) within Data::OptList::BEGIN@100 which was called: # once (8µs+12µs) by Class::Load::BEGIN@8 at line 104 BEGIN {
101 | 1 | 8µs | 1 | 12µs | *import = Sub::Install::exporter { # spent 12µs making 1 call to Sub::Install::exporter
102 |  |  |  |  | exports => [qw(mkopt mkopt_hash)],
103 |  |  |  |  | };
104 | 1 | 14µs | 1 | 19µs | } # spent 19µs making 1 call to Data::OptList::BEGIN@100
105 |  |  |  |  |
106 | 1 | 2µs |  |  | 1;
107 |  |  |  |  |
108 |  |  |  |  | __END__