← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:16 2014

Filename/usr/local/share/perl/5.14.2/Data/OptList.pm
StatementsExecuted 4136 statements in 4.98ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.76ms4.36msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
1112.66ms3.20msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
118432.25ms2.90msData::OptList::::mkoptData::OptList::mkopt
7821297µs420µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 170µs)
22711211µs211µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
1221102µs1.10msData::OptList::::mkopt_hashData::OptList::mkopt_hash
11130µs37µsClass::Load::::BEGIN@1 Class::Load::BEGIN@1
11124µs44µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
11116µs16µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
11114µs24µsClass::Load::::BEGIN@2 Class::Load::BEGIN@2
11110µs10µ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
1249µs244µs
# spent 37µs (30+7) within Class::Load::BEGIN@1 which was called: # once (30µs+7µs) by Class::Load::BEGIN@8 at line 1
use strict;
# spent 37µs making 1 call to Class::Load::BEGIN@1 # spent 7µs making 1 call to strict::import
22122µs234µs
# spent 24µs (14+10) within Class::Load::BEGIN@2 which was called: # once (14µs+10µs) by Class::Load::BEGIN@8 at line 2
use warnings;
# spent 24µs making 1 call to Class::Load::BEGIN@2 # spent 10µs making 1 call to warnings::import
3package Data::OptList;
4{
522µs $Data::OptList::VERSION = '0.108';
6}
7# ABSTRACT: parse and validate simple name/value option pairs
8
9255µs110µs
# spent 10µs within Data::OptList::BEGIN@9 which was called: # once (10µs+0s) by Class::Load::BEGIN@8 at line 9
use List::Util ();
# spent 10µs making 1 call to Data::OptList::BEGIN@9
102261µs14.36ms
# spent 4.36ms (3.76+606µs) within Data::OptList::BEGIN@10 which was called: # once (3.76ms+606µs) by Class::Load::BEGIN@8 at line 10
use Params::Util ();
# spent 4.36ms making 1 call to Data::OptList::BEGIN@10
113358µs23.23ms
# spent 3.20ms (2.66+539µs) within Data::OptList::BEGIN@11 which was called: # once (2.66ms+539µs) by Class::Load::BEGIN@8 at line 11
use Sub::Install 0.921 ();
# spent 3.20ms making 1 call to Data::OptList::BEGIN@11 # spent 29µs making 1 call to UNIVERSAL::VERSION
12
13
141300nsmy %test_for;
15
# spent 16µs within Data::OptList::BEGIN@15 which was called: # once (16µs+0s) by Class::Load::BEGIN@8 at line 22
BEGIN {
16115µ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 );
221932µs116µs}
# spent 16µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 420µs (297+123) within Data::OptList::__is_a which was called 78 times, avg 5µs/call: # 41 times (138µs+-138µs) by List::Util::first at line 27, avg 0s/call # 37 times (159µs+261µs) by Data::OptList::mkopt at line 77, avg 11µs/call
sub __is_a {
25197304µs my ($got, $expected) = @_;
26
2741131µs78261µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 261µs making 37 calls to List::Util::first, avg 7µs/call # spent 170µs making 41 calls to Data::OptList::__is_a, avg 4µs/call, recursion: max depth 1, sum of overlapping time 170µs
28
29 return defined (
304132µs exists($test_for{$expected})
# spent 23µs making 33 calls to Params::Util::_CODELIKE, avg 703ns/call # spent 6µs making 4 calls to Params::Util::_HASHLIKE, avg 2µs/call # spent 2µs making 4 calls to Params::Util::_ARRAYLIKE, avg 625ns/call
31 ? $test_for{$expected}->($got)
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 2.90ms (2.25+647µs) within Data::OptList::mkopt which was called 118 times, avg 25µs/call: # 56 times (481µs+0s) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 9µs/call # 32 times (1.06ms+172µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 39µs/call # 21 times (186µs+0s) by Sub::Exporter::__ANON__[/usr/local/share/perl/5.14.2/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 9µs/call # 9 times (521µs+475µs) by Data::OptList::mkopt_hash at line 94, avg 111µs/call
sub mkopt {
3714161.19ms my ($opt_list) = shift;
38
39 my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
4211868µs3217µs if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) {
# spent 17µs making 32 calls to Params::Util::_HASHLIKE, avg 519ns/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 {
47 ($moniker, $require_unique, $must_be) = @_;
48 }
49
50 $moniker = 'unnamed' unless defined $moniker;
51
52 return [] unless $opt_list;
53
54227386µs
# spent 211µs within Data::OptList::__ANON__[/usr/local/share/perl/5.14.2/Data/OptList.pm:54] which was called 227 times, avg 928ns/call: # 227 times (211µs+0s) by Data::OptList::mkopt at line 71, avg 928ns/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
573620µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
60 my @return;
61 my %seen;
62
631620801µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64 my $name = $opt_list->[$i];
65 my $value;
66
675329µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
7127055µs227211µs if ($i == $#$opt_list) { $value = undef; }
# spent 211µs making 227 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 928ns/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
763735µs if ($must_be and defined $value) {
7737420µs unless (__is_a($value, $must_be)) {
# spent 420µs making 37 calls to Data::OptList::__is_a, avg 11µ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.10ms (102µs+997µs) within Data::OptList::mkopt_hash which was called 12 times, avg 92µs/call: # 8 times (78µs+838µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 115µs/call # 4 times (24µs+158µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 46µs/call
sub mkopt_hash {
915183µs my ($opt_list, $moniker, $must_be) = @_;
92 return {} unless $opt_list;
93
949997µs $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 997µs making 9 calls to Data::OptList::mkopt, avg 111µs/call
955320µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96 return \%hash;
97}
98
99
100
# spent 44µs (24+20) within Data::OptList::BEGIN@100 which was called: # once (24µs+20µs) by Class::Load::BEGIN@8 at line 104
BEGIN {
101114µs120µs *import = Sub::Install::exporter {
# spent 20µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104141µs144µs}
# spent 44µs making 1 call to Data::OptList::BEGIN@100
105
10616µs1;
107
108__END__