← 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:39 2012

Filename/home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/Data/OptList.pm
StatementsExecuted 275 statements in 5.77ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1118.41ms9.93msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
1115.82ms6.97msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
722929µs1.58msData::OptList::::mkoptData::OptList::mkopt
1621380µs575µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 251µs)
621182µs1.62msData::OptList::::mkopt_hashData::OptList::mkopt_hash
101174µs74µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
11157µs67µsSub::Exporter::::BEGIN@1Sub::Exporter::BEGIN@1
11153µs91µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
11127µs47µsSub::Exporter::::BEGIN@2Sub::Exporter::BEGIN@2
11127µs27µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
11114µs14µsData::OptList::::BEGIN@9Data::OptList::BEGIN@9
11114µs14µsData::OptList::::BEGIN@4Data::OptList::BEGIN@4
0000s0sData::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
1292µs276µ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
22146µs266µ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
3package 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 {
5115µs $Data::OptList::VERSION = '0.107';
6171µs114µs}
# spent 14µs making 1 call to Data::OptList::BEGIN@4
7# ABSTRACT: parse and validate simple name/value option pairs
8
9282µs114µ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
102569µs19.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
113850µs27.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
141800nsmy %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 {
16127µ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 );
2211.98ms127µ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 {
2541416µs my ($got, $expected) = @_;
26
279165µs16403µ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 (
30943µ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 {
37172735µs my ($opt_list) = shift;
38
39 my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
42 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 ($moniker, $require_unique, $must_be) = @_;
48 }
49
50 $moniker = 'unnamed' unless defined $moniker;
51
52 return [] unless $opt_list;
53
5410306µ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 map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
60 my @return;
61 my %seen;
62
63 for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64 my $name = $opt_list->[$i];
65 my $value;
66
67 if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
711074µ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 else { $value = $opt_list->[++$i] }
75
76 if ($must_be and defined $value) {
777575µ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 push @return, [ $name => $value ];
84 }
85
86 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 {
9127186µs my ($opt_list, $moniker, $must_be) = @_;
92 return {} unless $opt_list;
93
9451.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 my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96 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 {
101132µs137µs *import = Sub::Install::exporter {
# spent 37µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104181µs191µs}
# spent 91µs making 1 call to Data::OptList::BEGIN@100
105
106110µs1;
107
108__END__