← Index
NYTProf Performance Profile   « line view »
For bin/benchmark-perlformance
  Run on Fri Apr 17 15:31:48 2015
Reported on Fri Apr 17 15:32:03 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/site_perl/5.16.3/Data/OptList.pm
StatementsExecuted 282 statements in 898µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.33ms1.64msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
111914µs1.15msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
722132µs245µsData::OptList::::mkoptData::OptList::mkopt
162163µs101µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 43µs)
62134µs251µsData::OptList::::mkopt_hashData::OptList::mkopt_hash
111112µs12µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
11110µs19µsSub::Exporter::::BEGIN@1Sub::Exporter::BEGIN@1
11110µs16µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
1116µs9µsSub::Exporter::::BEGIN@2Sub::Exporter::BEGIN@2
1115µs5µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
1113µs3µsData::OptList::::BEGIN@4Data::OptList::BEGIN@4
1112µs2µ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
1217µs229µs
# spent 19µs (10+10) within Sub::Exporter::BEGIN@1 which was called: # once (10µs+10µs) by Sub::Exporter::BEGIN@11 at line 1
use strict;
# spent 19µs making 1 call to Sub::Exporter::BEGIN@1 # spent 10µs making 1 call to strict::import
2230µs212µs
# spent 9µs (6+3) within Sub::Exporter::BEGIN@2 which was called: # once (6µs+3µs) by Sub::Exporter::BEGIN@11 at line 2
use warnings;
# spent 9µs making 1 call to Sub::Exporter::BEGIN@2 # spent 3µs making 1 call to warnings::import
3package Data::OptList;
4
# spent 3µs within Data::OptList::BEGIN@4 which was called: # once (3µs+0s) by Sub::Exporter::BEGIN@11 at line 6
BEGIN {
513µs $Data::OptList::VERSION = '0.107';
6111µs13µs}
# spent 3µs making 1 call to Data::OptList::BEGIN@4
7# ABSTRACT: parse and validate simple name/value option pairs
8
9216µs12µs
# spent 2µs within Data::OptList::BEGIN@9 which was called: # once (2µs+0s) by Sub::Exporter::BEGIN@11 at line 9
use List::Util ();
# spent 2µs making 1 call to Data::OptList::BEGIN@9
10286µs11.64ms
# spent 1.64ms (1.33+312µs) within Data::OptList::BEGIN@10 which was called: # once (1.33ms+312µs) by Sub::Exporter::BEGIN@11 at line 10
use Params::Util ();
# spent 1.64ms making 1 call to Data::OptList::BEGIN@10
113113µs21.16ms
# spent 1.15ms (914µs+234µs) within Data::OptList::BEGIN@11 which was called: # once (914µs+234µs) by Sub::Exporter::BEGIN@11 at line 11
use Sub::Install 0.921 ();
# spent 1.15ms making 1 call to Data::OptList::BEGIN@11 # spent 10µs making 1 call to UNIVERSAL::VERSION
12
13
141200nsmy %test_for;
15
# spent 5µs within Data::OptList::BEGIN@15 which was called: # once (5µs+0s) by Sub::Exporter::BEGIN@11 at line 22
BEGIN {
1615µ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 );
221305µs15µs}
# spent 5µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 101µs (63+38) within Data::OptList::__is_a which was called 16 times, avg 6µs/call: # 9 times (37µs+-37µs) by List::Util::first at line 27, avg 0s/call # 7 times (26µs+75µs) by Data::OptList::mkopt at line 77, avg 14µs/call
sub __is_a {
25165µs my ($got, $expected) = @_;
26
272555µs1675µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 75µs making 7 calls to List::Util::first, avg 11µs/call # spent 43µs making 9 calls to Data::OptList::__is_a, avg 5µs/call, recursion: max depth 1, sum of overlapping time 43µs
28
29 return defined (
30946µs96µs exists($test_for{$expected})
# spent 3µs making 5 calls to Params::Util::_CODELIKE, avg 580ns/call # spent 3µs making 2 calls to Params::Util::_HASHLIKE, avg 1µs/call # spent 900ns making 2 calls to Params::Util::_ARRAYLIKE, avg 450ns/call
31 ? $test_for{$expected}->($got)
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 245µs (132+112) within Data::OptList::mkopt which was called 7 times, avg 35µs/call: # 5 times (107µs+110µs) by Data::OptList::mkopt_hash at line 94, avg 43µs/call # 2 times (26µ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
sub mkopt {
3772µs my ($opt_list) = shift;
38
3971µs my ($moniker, $require_unique, $must_be); # the old positional args
407700ns my $name_test;
41
4273µ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 {
4775µs ($moniker, $require_unique, $must_be) = @_;
48 }
49
5072µs $moniker = 'unnamed' unless defined $moniker;
51
527800ns return [] unless $opt_list;
53
541836µs
# spent 12µ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 11 times, avg 1µs/call: # 11 times (12µs+0s) by Data::OptList::mkopt at line 71, avg 1µs/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
5779µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
607900ns my @return;
617700ns my %seen;
62
6379µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64124µs my $name = $opt_list->[$i];
6512900ns my $value;
66
67126µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
711218µs1112µs if ($i == $#$opt_list) { $value = undef; }
# spent 12µs making 11 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; }
7483µs else { $value = $opt_list->[++$i] }
75
76129µs if ($must_be and defined $value) {
7776µs7101µs unless (__is_a($value, $must_be)) {
# spent 101µs making 7 calls to Data::OptList::__is_a, avg 14µs/call
78 my $ref = ref $value;
79 Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 }
81 }
82
831210µs push @return, [ $name => $value ];
84 }
85
86722µs return \@return;
87}
88
89
90
# spent 251µs (34+217) within Data::OptList::mkopt_hash which was called 6 times, avg 42µs/call: # 4 times (24µs+151µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 44µs/call # 2 times (10µs+66µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 38µs/call
sub mkopt_hash {
9163µs my ($opt_list, $moniker, $must_be) = @_;
9262µs return {} unless $opt_list;
93
9454µs5217µs $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 217µs making 5 calls to Data::OptList::mkopt, avg 43µs/call
95512µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96513µs return \%hash;
97}
98
99
100
# spent 16µs (10+6) within Data::OptList::BEGIN@100 which was called: # once (10µs+6µs) by Sub::Exporter::BEGIN@11 at line 104
BEGIN {
10116µs16µs *import = Sub::Install::exporter {
# spent 6µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104114µs116µs}
# spent 16µs making 1 call to Data::OptList::BEGIN@100
105
10612µs1;
107
108__END__