← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Data/OptList.pm
StatementsExecuted 431 statements in 1.02ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.00ms1.22msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
1322239µs405µsData::OptList::::mkoptData::OptList::mkopt
212193µs144µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 68µs)
122164µs398µsData::OptList::::mkopt_hashData::OptList::mkopt_hash
151122µs22µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
11111µs17µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
11111µs22µsSub::Exporter::::BEGIN@1Sub::Exporter::BEGIN@1
1117µs10µsSub::Exporter::::BEGIN@2Sub::Exporter::BEGIN@2
1116µs6µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
1114µs4µsData::OptList::::BEGIN@10Data::OptList::BEGIN@10
1114µs4µ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
1222µs234µs
# spent 22µs (11+11) within Sub::Exporter::BEGIN@1 which was called: # once (11µs+11µs) by Sub::Exporter::BEGIN@11 at line 1
use strict;
# spent 22µs making 1 call to Sub::Exporter::BEGIN@1 # spent 11µs making 1 call to strict::import
2232µs214µs
# spent 10µs (7+4) within Sub::Exporter::BEGIN@2 which was called: # once (7µs+4µs) by Sub::Exporter::BEGIN@11 at line 2
use warnings;
# spent 10µs making 1 call to Sub::Exporter::BEGIN@2 # spent 4µs making 1 call to warnings::import
3package Data::OptList;
4{
52900ns $Data::OptList::VERSION = '0.109';
6}
7# ABSTRACT: parse and validate simple name/value option pairs
8
9217µs14µs
# spent 4µs within Data::OptList::BEGIN@9 which was called: # once (4µs+0s) by Sub::Exporter::BEGIN@11 at line 9
use List::Util ();
# spent 4µs making 1 call to Data::OptList::BEGIN@9
10217µs14µs
# spent 4µs within Data::OptList::BEGIN@10 which was called: # once (4µs+0s) by Sub::Exporter::BEGIN@11 at line 10
use Params::Util ();
# spent 4µs making 1 call to Data::OptList::BEGIN@10
113107µs21.23ms
# spent 1.22ms (1.00+214µs) within Data::OptList::BEGIN@11 which was called: # once (1.00ms+214µs) by Sub::Exporter::BEGIN@11 at line 11
use Sub::Install 0.921 ();
# spent 1.22ms making 1 call to Data::OptList::BEGIN@11 # spent 9µs making 1 call to UNIVERSAL::VERSION
12
13
141100nsmy %test_for;
15
# spent 6µs within Data::OptList::BEGIN@15 which was called: # once (6µs+0s) by Sub::Exporter::BEGIN@11 at line 22
BEGIN {
1616µ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 );
221345µs16µs}
# spent 6µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 144µs (93+51) within Data::OptList::__is_a which was called 21 times, avg 7µs/call: # 12 times (54µs+-54µs) by List::Util::first at line 27, avg 0s/call # 9 times (39µs+105µs) by Data::OptList::mkopt at line 77, avg 16µs/call
sub __is_a {
25215µs my ($got, $expected) = @_;
26
273365µs21105µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 105µs making 9 calls to List::Util::first, avg 12µs/call # spent 68µs making 12 calls to Data::OptList::__is_a, avg 6µs/call, recursion: max depth 1, sum of overlapping time 68µs
28
29 return defined (
301272µs1214µs exists($test_for{$expected})
# spent 7µs making 3 calls to Params::Util::_HASHLIKE, avg 2µs/call # spent 5µs making 6 calls to Params::Util::_CODELIKE, avg 817ns/call # spent 2µs making 3 calls to Params::Util::_ARRAYLIKE, avg 767ns/call
31 ? $test_for{$expected}->($got)
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 405µs (239+165) within Data::OptList::mkopt which was called 13 times, avg 31µs/call: # 8 times (174µs+160µs) by Data::OptList::mkopt_hash at line 94, avg 42µs/call # 5 times (65µs+6µs) by Sub::Exporter::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 14µs/call
sub mkopt {
37133µs my ($opt_list) = shift;
38
39131µs my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
42136µ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 {
47138µs ($moniker, $require_unique, $must_be) = @_;
48 }
49
50132µs $moniker = 'unnamed' unless defined $moniker;
51
5213800ns return [] unless $opt_list;
53
542859µs
# spent 22µs within Data::OptList::__ANON__[/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Data/OptList.pm:54] which was called 15 times, avg 1µs/call: # 15 times (22µs+0s) by Data::OptList::mkopt at line 71, avg 1µs/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
571312µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
60131µs my @return;
61131µs my %seen;
62
631313µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64185µs my $name = $opt_list->[$i];
6518400ns my $value;
66
67187µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
711830µs1522µs if ($i == $#$opt_list) { $value = undef; }
# spent 22µs making 15 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; }
74124µs else { $value = $opt_list->[++$i] }
75
761814µs if ($must_be and defined $value) {
77910µs9144µs unless (__is_a($value, $must_be)) {
# spent 144µs making 9 calls to Data::OptList::__is_a, avg 16µs/call
78 my $ref = ref $value;
79 Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 }
81 }
82
831818µs push @return, [ $name => $value ];
84 }
85
861347µs return \@return;
87}
88
89
90
# spent 398µs (64+333) within Data::OptList::mkopt_hash which was called 12 times, avg 33µs/call: # 8 times (49µs+222µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 34µs/call # 4 times (16µs+111µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 32µs/call
sub mkopt_hash {
91126µs my ($opt_list, $moniker, $must_be) = @_;
92129µs return {} unless $opt_list;
93
9488µs8333µs $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 333µs making 8 calls to Data::OptList::mkopt, avg 42µs/call
95818µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96822µs return \%hash;
97}
98
99
100
# spent 17µs (11+6) within Data::OptList::BEGIN@100 which was called: # once (11µs+6µs) by Sub::Exporter::BEGIN@11 at line 104
BEGIN {
10115µs16µs *import = Sub::Install::exporter {
# spent 6µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104118µs117µs}
# spent 17µs making 1 call to Data::OptList::BEGIN@100
105
10612µs1;
107
108__END__