← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:06 2014

Filename/usr/local/share/perl/5.14.2/Data/OptList.pm
StatementsExecuted 4136 statements in 4.04ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
118432.34ms3.00msData::OptList::::mkoptData::OptList::mkopt
1111.66ms1.95msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
1111.16ms1.41msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
7821307µs437µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 177µs)
22711207µs207µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
1221108µs1.14msData::OptList::::mkopt_hashData::OptList::mkopt_hash
11113µs22µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
11111µs14µsClass::Load::::BEGIN@1 Class::Load::BEGIN@1
1117µs7µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
1116µs10µsClass::Load::::BEGIN@2 Class::Load::BEGIN@2
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
1220µs216µs
# spent 14µs (11+3) within Class::Load::BEGIN@1 which was called: # once (11µs+3µs) by Class::Load::BEGIN@8 at line 1
use strict;
# spent 14µs making 1 call to Class::Load::BEGIN@1 # spent 3µs making 1 call to strict::import
2241µs215µs
# spent 10µs (6+4) within Class::Load::BEGIN@2 which was called: # once (6µs+4µs) by Class::Load::BEGIN@8 at line 2
use warnings;
# spent 10µs making 1 call to Class::Load::BEGIN@2 # spent 4µs making 1 call to warnings::import
3package Data::OptList;
4{
52900ns $Data::OptList::VERSION = '0.108';
6}
7# ABSTRACT: parse and validate simple name/value option pairs
8
9218µ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
102116µs11.95ms
# spent 1.95ms (1.66+282µs) within Data::OptList::BEGIN@10 which was called: # once (1.66ms+282µs) by Class::Load::BEGIN@8 at line 10
use Params::Util ();
# spent 1.95ms making 1 call to Data::OptList::BEGIN@10
113152µs21.42ms
# spent 1.41ms (1.16+244µs) within Data::OptList::BEGIN@11 which was called: # once (1.16ms+244µs) by Class::Load::BEGIN@8 at line 11
use Sub::Install 0.921 ();
# spent 1.41ms making 1 call to Data::OptList::BEGIN@11 # spent 13µs making 1 call to UNIVERSAL::VERSION
12
13
141200nsmy %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 {
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 );
221406µs17µs}
# spent 7µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 437µs (307+130) within Data::OptList::__is_a which was called 78 times, avg 6µs/call: # 41 times (142µs+-142µs) by List::Util::first at line 27, avg 0s/call # 37 times (165µs+272µs) by Data::OptList::mkopt at line 77, avg 12µs/call
sub __is_a {
25197317µs my ($got, $expected) = @_;
26
2741137µs78272µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 272µs making 37 calls to List::Util::first, avg 7µs/call # spent 177µs making 41 calls to Data::OptList::__is_a, avg 4µs/call, recursion: max depth 1, sum of overlapping time 177µs
28
29 return defined (
304135µs exists($test_for{$expected})
# spent 22µs making 33 calls to Params::Util::_CODELIKE, avg 682ns/call # spent 7µs making 4 calls to Params::Util::_HASHLIKE, avg 2µs/call # spent 5µ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 3.00ms (2.34+662µs) within Data::OptList::mkopt which was called 118 times, avg 25µs/call: # 56 times (506µs+0s) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 9µs/call # 32 times (1.11ms+167µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 40µs/call # 21 times (189µ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 (539µs+495µs) by Data::OptList::mkopt_hash at line 94, avg 115µs/call
sub mkopt {
3735502.28ms my ($opt_list) = shift;
38
39 my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
423218µs if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) {
# spent 18µs making 32 calls to Params::Util::_HASHLIKE, avg 572ns/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
54227408µs
# spent 207µs within Data::OptList::__ANON__[/usr/local/share/perl/5.14.2/Data/OptList.pm:54] which was called 227 times, avg 912ns/call: # 227 times (207µs+0s) by Data::OptList::mkopt at line 71, avg 912ns/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
57 map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
60 my @return;
61 my %seen;
62
63 for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64 my $name = $opt_list->[$i];
65 my $value;
66
67 if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
71227207µs if ($i == $#$opt_list) { $value = undef; }
# spent 207µs making 227 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 912ns/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
76 if ($must_be and defined $value) {
7737437µs unless (__is_a($value, $must_be)) {
# spent 437µs making 37 calls to Data::OptList::__is_a, avg 12µ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.14ms (108µs+1.03) within Data::OptList::mkopt_hash which was called 12 times, avg 95µs/call: # 8 times (83µs+869µs) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 119µs/call # 4 times (24µs+165µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 47µs/call
sub mkopt_hash {
91104108µs my ($opt_list, $moniker, $must_be) = @_;
92 return {} unless $opt_list;
93
9491.03ms $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 1.03ms making 9 calls to Data::OptList::mkopt, avg 115µs/call
95 my %hash = map { $_->[0] => $_->[1] } @$opt_list;
96 return \%hash;
97}
98
99
100
# spent 22µs (13+9) within Data::OptList::BEGIN@100 which was called: # once (13µs+9µs) by Class::Load::BEGIN@8 at line 104
BEGIN {
10117µs19µs *import = Sub::Install::exporter {
# spent 9µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104118µs122µs}
# spent 22µs making 1 call to Data::OptList::BEGIN@100
105
10613µs1;
107
108__END__