Profile of Data/OptList.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For bin/dpath
Run on Tue Jun 5 15:31:33 2012
Reported on Tue Jun 5 15:31:52 2012

Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Data/OptList.pm
Statements | Executed 275 statements in 5.77ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 8.41ms | 9.93ms | Data::OptList::::BEGIN@10Data::OptList::BEGIN@10
1 | 1 | 1 | 5.82ms | 6.97ms | Data::OptList::::BEGIN@11Data::OptList::BEGIN@11
7 | 2 | 2 | 929µs | 1.58ms | Data::OptList::::mkoptData::OptList::mkopt
16 | 2 | 1 | 380µs | 575µs | Data::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 251µs)
6 | 2 | 1 | 182µs | 1.62ms | Data::OptList::::mkopt_hashData::OptList::mkopt_hash
10 | 1 | 1 | 74µs | 74µs | Data::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
1 | 1 | 1 | 57µs | 67µs | Sub::Exporter::::BEGIN@1Sub::Exporter::BEGIN@1
1 | 1 | 1 | 53µs | 91µs | Data::OptList::::BEGIN@100Data::OptList::BEGIN@100
1 | 1 | 1 | 27µs | 47µs | Sub::Exporter::::BEGIN@2Sub::Exporter::BEGIN@2
1 | 1 | 1 | 27µs | 27µs | Data::OptList::::BEGIN@15Data::OptList::BEGIN@15
1 | 1 | 1 | 14µs | 14µs | Data::OptList::::BEGIN@9Data::OptList::BEGIN@9
1 | 1 | 1 | 14µs | 14µ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 | 2 | 92µs | 2 | 76µs | # spent 67µs (57+10) within Sub::Exporter::BEGIN@1 which was called: # once (57µs+10µs) by Sub::Exporter::BEGIN@7 at line 1 use strict; # spent 67µs making 1 call to Sub::Exporter::BEGIN@1 # spent 10µs making 1 call to strict::import
2 | 2 | 146µs | 2 | 66µs | # spent 47µs (27+19) within Sub::Exporter::BEGIN@2 which was called: # once (27µs+19µs) by Sub::Exporter::BEGIN@7 at line 2 use warnings; # spent 47µs making 1 call to Sub::Exporter::BEGIN@2 # spent 19µs making 1 call to warnings::import
3 |  |  |  |  | package Data::OptList;
4 |  |  |  |  | # spent 14µs within Data::OptList::BEGIN@4 which was called: # once (14µs+0s) by Sub::Exporter::BEGIN@7 at line 6 BEGIN {
5 | 1 | 15µs |  |  | $Data::OptList::VERSION = '0.107';
6 | 1 | 71µs | 1 | 14µs | } # spent 14µs making 1 call to Data::OptList::BEGIN@4
7 |  |  |  |  | # ABSTRACT: parse and validate simple name/value option pairs
8 |  |  |  |  |
9 | 2 | 82µs | 1 | 14µs | # spent 14µs within Data::OptList::BEGIN@9 which was called: # once (14µs+0s) by Sub::Exporter::BEGIN@7 at line 9 use List::Util (); # spent 14µs making 1 call to Data::OptList::BEGIN@9
10 | 2 | 569µs | 1 | 9.93ms | # spent 9.93ms (8.41+1.52) within Data::OptList::BEGIN@10 which was called: # once (8.41ms+1.52ms) by Sub::Exporter::BEGIN@7 at line 10 use Params::Util (); # spent 9.93ms making 1 call to Data::OptList::BEGIN@10
11 | 3 | 850µs | 2 | 7.04ms | # spent 6.97ms (5.82+1.15) within Data::OptList::BEGIN@11 which was called: # once (5.82ms+1.15ms) by Sub::Exporter::BEGIN@7 at line 11 use Sub::Install 0.921 (); # spent 6.97ms making 1 call to Data::OptList::BEGIN@11 # spent 69µs making 1 call to UNIVERSAL::VERSION
12 |  |  |  |  |
13 |  |  |  |  |
14 | 1 | 800ns |  |  | my %test_for;
15 |  |  |  |  | # spent 27µs within Data::OptList::BEGIN@15 which was called: # once (27µs+0s) by Sub::Exporter::BEGIN@7 at line 22 BEGIN {
16 | 1 | 27µ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 | 1.98ms | 1 | 27µs | } # spent 27µs making 1 call to Data::OptList::BEGIN@15
23 |  |  |  |  |
24 |  |  |  |  | # spent 575µs (380+195) within Data::OptList::__is_a which was called 16 times, avg 36µs/call: # 9 times (208µs+-208µs) by List::Util::first at line 27, avg 0s/call # 7 times (172µs+403µs) by Data::OptList::mkopt at line 77, avg 82µs/call sub __is_a {
25 | 16 | 35µs |  |  | my ($got, $expected) = @_;
26 |  |  |  |  |
27 | 25 | 303µs | 16 | 403µs | return List::Util::first { __is_a($got, $_) } @$expected if ref $expected; # spent 403µs making 7 calls to List::Util::first, avg 58µs/call # spent 251µs making 9 calls to Data::OptList::__is_a, avg 28µs/call, recursion: max depth 1, sum of overlapping time 251µs
28 |  |  |  |  |
29 |  |  |  |  | return defined (
30 | 9 | 243µs | 9 | 43µs | exists($test_for{$expected}) # spent 21µs making 5 calls to Params::Util::_CODELIKE, avg 4µs/call # spent 14µs making 2 calls to Params::Util::_HASHLIKE, avg 7µs/call # spent 8µs making 2 calls to Params::Util::_ARRAYLIKE, avg 4µs/call
31 |  |  |  |  | ? $test_for{$expected}->($got)
32 |  |  |  |  | : Params::Util::_INSTANCE($got, $expected) ## no critic
33 |  |  |  |  | );
34 |  |  |  |  | }
35 |  |  |  |  |
36 |  |  |  |  | # spent 1.58ms (929µs+649µs) within Data::OptList::mkopt which was called 7 times, avg 225µs/call: # 5 times (797µs+642µs) by Data::OptList::mkopt_hash at line 94, avg 288µs/call # 2 times (133µs+7µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Sub/Exporter.pm:756] at line 735 of Sub/Exporter.pm, avg 70µs/call sub mkopt {
37 | 7 | 13µs |  |  | my ($opt_list) = shift;
38 |  |  |  |  |
39 | 7 | 6µs |  |  | my ($moniker, $require_unique, $must_be); # the old positional args
40 | 7 | 4µs |  |  | my $name_test;
41 |  |  |  |  |
42 | 7 | 23µ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 | 28µs |  |  | ($moniker, $require_unique, $must_be) = @_;
48 |  |  |  |  | }
49 |  |  |  |  |
50 | 7 | 8µs |  |  | $moniker = 'unnamed' unless defined $moniker;
51 |  |  |  |  |
52 | 7 | 5µs |  |  | return [] unless $opt_list;
53 |  |  |  |  |
54 | 17 | 365µs |  |  | # spent 74µs within Data::OptList::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Data/OptList.pm:54] which was called 10 times, avg 7µs/call: # 10 times (74µs+0s) by Data::OptList::mkopt at line 71, avg 7µs/call $name_test ||= sub { ! ref $_[0] };
55 |  |  |  |  |
56 |  |  |  |  | $opt_list = [
57 | 7 | 51µs |  |  | map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 |  |  |  |  | ] if ref $opt_list eq 'HASH';
59 |  |  |  |  |
60 | 7 | 5µs |  |  | my @return;
61 | 7 | 5µs |  |  | my %seen;
62 |  |  |  |  |
63 | 7 | 59µs |  |  | for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64 | 11 | 21µs |  |  | my $name = $opt_list->[$i];
65 | 11 | 6µs |  |  | my $value;
66 |  |  |  |  |
67 | 11 | 29µs |  |  | if ($require_unique) {
68 |  |  |  |  | Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 |  |  |  |  | }
70 |  |  |  |  |
71 | 11 | 114µs | 10 | 74µs | if ($i == $#$opt_list) { $value = undef; } # spent 74µs making 10 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 7µ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 | 16µs |  |  | else { $value = $opt_list->[++$i] }
75 |  |  |  |  |
76 | 11 | 54µs |  |  | if ($must_be and defined $value) {
77 | 7 | 43µs | 7 | 575µs | unless (__is_a($value, $must_be)) { # spent 575µs making 7 calls to Data::OptList::__is_a, avg 82µ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 | 56µs |  |  | push @return, [ $name => $value ];
84 |  |  |  |  | }
85 |  |  |  |  |
86 | 7 | 129µs |  |  | return \@return;
87 |  |  |  |  | }
88 |  |  |  |  |
89 |  |  |  |  |
90 |  |  |  |  | # spent 1.62ms (182µs+1.44) within Data::OptList::mkopt_hash which was called 6 times, avg 270µs/call: # 4 times (126µs+1.05ms) by Sub::Exporter::_rewrite_build_config at line 672 of Sub/Exporter.pm, avg 295µs/call # 2 times (56µs+386µs) by Sub::Exporter::_rewrite_build_config at line 685 of Sub/Exporter.pm, avg 221µs/call sub mkopt_hash {
91 | 6 | 21µs |  |  | my ($opt_list, $moniker, $must_be) = @_;
92 | 6 | 13µs |  |  | return {} unless $opt_list;
93 |  |  |  |  |
94 | 5 | 28µs | 5 | 1.44ms | $opt_list = mkopt($opt_list, $moniker, 1, $must_be); # spent 1.44ms making 5 calls to Data::OptList::mkopt, avg 288µs/call
95 | 5 | 63µs |  |  | my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96 | 5 | 61µs |  |  | return \%hash;
97 |  |  |  |  | }
98 |  |  |  |  |
99 |  |  |  |  |
100 |  |  |  |  | # spent 91µs (53+37) within Data::OptList::BEGIN@100 which was called: # once (53µs+37µs) by Sub::Exporter::BEGIN@7 at line 104 BEGIN {
101 | 1 | 32µs | 1 | 37µs | *import = Sub::Install::exporter { # spent 37µs making 1 call to Sub::Install::exporter
102 |  |  |  |  | exports => [qw(mkopt mkopt_hash)],
103 |  |  |  |  | };
104 | 1 | 81µs | 1 | 91µs | } # spent 91µs making 1 call to Data::OptList::BEGIN@100
105 |  |  |  |  |
106 | 1 | 10µs |  |  | 1;
107 |  |  |  |  |
108 |  |  |  |  | __END__