← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:40 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/Data/OptList.pm
StatementsExecuted 1385 statements in 2.91ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1115.88ms8.13msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
1111.57ms1.87msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
32431.11ms1.78msData::OptList::::mkoptData::OptList::mkopt
7821398µs559µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 226µs)
1221123µs1.41msData::OptList::::mkopt_hashData::OptList::mkopt_hash
8111106µs106µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
11117µs26µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
11114µs30µsClass::Load::::BEGIN@1 Class::Load::BEGIN@1
1119µs14µsClass::Load::::BEGIN@2 Class::Load::BEGIN@2
1117µs7µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
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
1230µs246µs
# spent 30µs (14+16) within Class::Load::BEGIN@1 which was called: # once (14µs+16µs) by Class::Load::BEGIN@8 at line 1
use strict;
# spent 30µs making 1 call to Class::Load::BEGIN@1 # spent 16µs making 1 call to strict::import
2249µs219µs
# spent 14µs (9+5) within Class::Load::BEGIN@2 which was called: # once (9µs+5µs) by Class::Load::BEGIN@8 at line 2
use warnings;
# spent 14µs making 1 call to Class::Load::BEGIN@2 # spent 5µs making 1 call to warnings::import
3package Data::OptList;
4{
521µs $Data::OptList::VERSION = '0.108';
6}
7# ABSTRACT: parse and validate simple name/value option pairs
8
9226µs14µs
# spent 4µs within Data::OptList::BEGIN@9 which was called: # once (4µs+0s) by Class::Load::BEGIN@8 at line 9
use List::Util ();
# spent 4µs making 1 call to Data::OptList::BEGIN@9
102178µs18.13ms
# spent 8.13ms (5.88+2.25) within Data::OptList::BEGIN@10 which was called: # once (5.88ms+2.25ms) by Class::Load::BEGIN@8 at line 10
use Params::Util ();
# spent 8.13ms making 1 call to Data::OptList::BEGIN@10
113167µs21.88ms
# spent 1.87ms (1.57+297µs) within Data::OptList::BEGIN@11 which was called: # once (1.57ms+297µs) by Class::Load::BEGIN@8 at line 11
use Sub::Install 0.921 ();
# spent 1.87ms making 1 call to Data::OptList::BEGIN@11 # spent 12µs making 1 call to UNIVERSAL::VERSION
12
13
141100nsmy %test_for;
15
# spent 7µs within Data::OptList::BEGIN@15 which was called: # once (7µs+0s) by Class::Load::BEGIN@8 at line 22
BEGIN {
1618µ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 );
221542µs17µs}
# spent 7µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 559µs (398+161) within Data::OptList::__is_a which was called 78 times, avg 7µs/call: # 41 times (189µs+-189µs) by List::Util::first at line 27, avg 0s/call # 37 times (209µs+350µs) by Data::OptList::mkopt at line 77, avg 15µs/call
sub __is_a {
257821µs my ($got, $expected) = @_;
26
27119292µs78350µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 350µs making 37 calls to List::Util::first, avg 9µs/call # spent 226µs making 41 calls to Data::OptList::__is_a, avg 6µs/call, recursion: max depth 1, sum of overlapping time 226µs
28
29 return defined (
3041234µs4137µs exists($test_for{$expected})
# spent 24µs making 33 calls to Params::Util::_CODELIKE, avg 733ns/call # spent 8µs making 4 calls to Params::Util::_HASHLIKE, avg 2µs/call # spent 4µs making 4 calls to Params::Util::_ARRAYLIKE, avg 1µs/call
31 ? $test_for{$expected}->($got)
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 1.78ms (1.11+671µs) within Data::OptList::mkopt which was called 32 times, avg 56µs/call: # 9 times (660µs+631µs) by Data::OptList::mkopt_hash at line 94, avg 143µs/call # 9 times (109µs+0s) by Sub::Exporter::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 12µs/call # 8 times (260µs+40µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 38µs/call # 6 times (78µs+0s) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 13µs/call
sub mkopt {
373210µs my ($opt_list) = shift;
38
39323µs my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
423240µs86µs if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) {
# spent 6µs making 8 calls to Params::Util::_HASHLIKE, avg 688ns/call
43 my $arg = $_[0];
44 ($moniker, $require_unique, $must_be, $name_test)
45 = @$arg{ qw(moniker require_unique must_be name_test) };
46 } else {
473219µs ($moniker, $require_unique, $must_be) = @_;
48 }
49
50328µs $moniker = 'unnamed' unless defined $moniker;
51
52324µs return [] unless $opt_list;
53
54113273µs
# spent 106µs within Data::OptList::__ANON__[/opt/perl-5.18.1/lib/site_perl/5.18.1/Data/OptList.pm:54] which was called 81 times, avg 1µs/call: # 81 times (106µs+0s) by Data::OptList::mkopt at line 71, avg 1µs/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
573253µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
60324µs my @return;
61324µs my %seen;
62
633256µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
649027µs my $name = $opt_list->[$i];
65901µs my $value;
66
679029µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
7190160µs81106µs if ($i == $#$opt_list) { $value = undef; }
# spent 106µs making 81 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; }
743713µs else { $value = $opt_list->[++$i] }
75
769078µs if ($must_be and defined $value) {
773737µs37559µs unless (__is_a($value, $must_be)) {
# spent 559µs making 37 calls to Data::OptList::__is_a, avg 15µs/call
78 my $ref = ref $value;
79 Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 }
81 }
82
8390100µs push @return, [ $name => $value ];
84 }
85
8632173µs return \@return;
87}
88
89
90
# spent 1.41ms (123µs+1.29) within Data::OptList::mkopt_hash which was called 12 times, avg 118µs/call: # 8 times (95µs+1.09ms) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 148µs/call # 4 times (28µs+205µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 58µs/call
sub mkopt_hash {
91127µs my ($opt_list, $moniker, $must_be) = @_;
921210µs return {} unless $opt_list;
93
94911µs91.29ms $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 1.29ms making 9 calls to Data::OptList::mkopt, avg 143µs/call
95950µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96941µs return \%hash;
97}
98
99
100
# spent 26µs (17+9) within Data::OptList::BEGIN@100 which was called: # once (17µs+9µs) by Class::Load::BEGIN@8 at line 104
BEGIN {
1011105µs19µs *import = Sub::Install::exporter {
# spent 9µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104135µs126µs}
# spent 26µs making 1 call to Data::OptList::BEGIN@100
105
10614µs1;
107
108__END__