← Index
NYTProf Performance Profile   « line view »
For t/optimization.t
  Run on Thu Jan 8 22:47:42 2015
Reported on Thu Jan 8 22:48:06 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/OptList.pm
StatementsExecuted 301 statements in 1.31ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.73ms2.11msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
1111.37ms1.70msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
932205µs362µsData::OptList::::mkoptData::OptList::mkopt
162188µs140µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 60µs)
62149µs358µsData::OptList::::mkopt_hashData::OptList::mkopt_hash
101116µs16µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
11113µs28µsSub::Exporter::::BEGIN@1Sub::Exporter::BEGIN@1
11112µs20µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
11112µs16µsSub::Exporter::::BEGIN@2Sub::Exporter::BEGIN@2
1118µs8µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
1114µs4µsData::OptList::::BEGIN@4Data::OptList::BEGIN@4
1113µs3µsData::OptList::::BEGIN@9Data::OptList::BEGIN@9
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
1227µs242µs
# spent 28µs (13+14) within Sub::Exporter::BEGIN@1 which was called: # once (13µs+14µs) by Sub::Exporter::BEGIN@11 at line 1
use strict;
# spent 28µs making 1 call to Sub::Exporter::BEGIN@1 # spent 14µs making 1 call to strict::import
2237µs221µs
# spent 16µs (12+5) within Sub::Exporter::BEGIN@2 which was called: # once (12µs+5µs) by Sub::Exporter::BEGIN@11 at line 2
use warnings;
# spent 16µs making 1 call to Sub::Exporter::BEGIN@2 # spent 5µs making 1 call to warnings::import
3package Data::OptList;
4
# spent 4µs within Data::OptList::BEGIN@4 which was called: # once (4µs+0s) by Sub::Exporter::BEGIN@11 at line 6
BEGIN {
515µs $Data::OptList::VERSION = '0.107';
6116µs14µs}
# spent 4µs making 1 call to Data::OptList::BEGIN@4
7# ABSTRACT: parse and validate simple name/value option pairs
8
9223µs13µs
# spent 3µs within Data::OptList::BEGIN@9 which was called: # once (3µs+0s) by Sub::Exporter::BEGIN@11 at line 9
use List::Util ();
# spent 3µs making 1 call to Data::OptList::BEGIN@9
102118µs12.11ms
# spent 2.11ms (1.73+388µs) within Data::OptList::BEGIN@10 which was called: # once (1.73ms+388µs) by Sub::Exporter::BEGIN@11 at line 10
use Params::Util ();
# spent 2.11ms making 1 call to Data::OptList::BEGIN@10
113159µs21.72ms
# spent 1.70ms (1.37+333µs) within Data::OptList::BEGIN@11 which was called: # once (1.37ms+333µs) by Sub::Exporter::BEGIN@11 at line 11
use Sub::Install 0.921 ();
# spent 1.70ms making 1 call to Data::OptList::BEGIN@11 # spent 14µs making 1 call to UNIVERSAL::VERSION
12
13
141200nsmy %test_for;
15
# spent 8µs within Data::OptList::BEGIN@15 which was called: # once (8µs+0s) by Sub::Exporter::BEGIN@11 at line 22
BEGIN {
16113µ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 );
221445µs18µs}
# spent 8µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 140µs (88+52) within Data::OptList::__is_a which was called 16 times, avg 9µs/call: # 9 times (51µs+-51µs) by List::Util::first at line 27, avg 0s/call # 7 times (36µs+103µs) by Data::OptList::mkopt at line 77, avg 20µs/call
sub __is_a {
25167µs my ($got, $expected) = @_;
26
272573µs16103µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 103µs making 7 calls to List::Util::first, avg 15µs/call # spent 60µs making 9 calls to Data::OptList::__is_a, avg 7µs/call, recursion: max depth 1, sum of overlapping time 60µs
28
29 return defined (
30964µs99µs exists($test_for{$expected})
# spent 4µs making 5 calls to Params::Util::_CODELIKE, avg 780ns/call # spent 3µs making 2 calls to Params::Util::_HASHLIKE, avg 2µs/call # spent 1µs making 2 calls to Params::Util::_ARRAYLIKE, avg 700ns/call
31 ? $test_for{$expected}->($got)
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 362µs (205+157) within Data::OptList::mkopt which was called 9 times, avg 40µs/call: # 5 times (154µs+154µs) by Data::OptList::mkopt_hash at line 94, avg 62µs/call # 3 times (40µ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 # once (11µs+700ns) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm
sub mkopt {
3794µs my ($opt_list) = shift;
38
3992µs my ($moniker, $require_unique, $must_be); # the old positional args
4091µs my $name_test;
41
42910µs1700ns if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) {
# spent 700ns making 1 call to Params::Util::_HASHLIKE
43 my $arg = $_[0];
44 ($moniker, $require_unique, $must_be, $name_test)
45 = @$arg{ qw(moniker require_unique must_be name_test) };
46 } else {
4798µs ($moniker, $require_unique, $must_be) = @_;
48 }
49
5093µs $moniker = 'unnamed' unless defined $moniker;
51
5291µs return [] unless $opt_list;
53
541950µs
# spent 16µ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 10 times, avg 2µs/call: # 10 times (16µs+0s) by Data::OptList::mkopt at line 71, avg 2µs/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
57914µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
6092µs my @return;
6192µs my %seen;
62
63915µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64115µs my $name = $opt_list->[$i];
65112µs my $value;
66
67118µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
711125µs1016µs if ($i == $#$opt_list) { $value = undef; }
# spent 16µs making 10 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 2µs/call
72 elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ }
73 elsif ($name_test->($opt_list->[$i+1])) { $value = undef; }
7484µs else { $value = $opt_list->[++$i] }
75
761113µs if ($must_be and defined $value) {
77710µs7140µs unless (__is_a($value, $must_be)) {
# spent 140µs making 7 calls to Data::OptList::__is_a, avg 20µs/call
78 my $ref = ref $value;
79 Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 }
81 }
82
831114µs push @return, [ $name => $value ];
84 }
85
86945µs return \@return;
87}
88
89
90
# spent 358µs (49+308) within Data::OptList::mkopt_hash which was called 6 times, avg 60µs/call: # 4 times (34µs+212µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 62µs/call # 2 times (15µs+97µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 56µs/call
sub mkopt_hash {
9165µs my ($opt_list, $moniker, $must_be) = @_;
9264µs return {} unless $opt_list;
93
9456µs5308µs $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 308µs making 5 calls to Data::OptList::mkopt, avg 62µs/call
95517µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96518µs return \%hash;
97}
98
99
100
# spent 20µs (12+8) within Data::OptList::BEGIN@100 which was called: # once (12µs+8µs) by Sub::Exporter::BEGIN@11 at line 104
BEGIN {
10117µs18µs *import = Sub::Install::exporter {
# spent 8µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104120µs120µs}
# spent 20µs making 1 call to Data::OptList::BEGIN@100
105
10612µs1;
107
108__END__