← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Data/OptList.pm
StatementsExecuted 2250 statements in 2.17ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.05ms2.81msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
77431.08ms1.43msData::OptList::::mkoptData::OptList::mkopt
111960µs1.15msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
7921197µs294µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 109µs)
182186µs767µsData::OptList::::mkopt_hashData::OptList::mkopt_hash
991160µs60µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
1118µs10µsClass::Load::::BEGIN@1.23 Class::Load::BEGIN@1.23
1117µs12µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
1115µs5µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
1114µs8µsClass::Load::::BEGIN@2 Class::Load::BEGIN@2
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
1228µs211µs
# spent 10µs (8+2) within Class::Load::BEGIN@1.23 which was called: # once (8µs+2µs) by Class::Load::BEGIN@10 at line 1
use strict;
# spent 10µs making 1 call to Class::Load::BEGIN@1.23 # spent 2µs making 1 call to strict::import
2227µs212µs
# spent 8µs (4+4) within Class::Load::BEGIN@2 which was called: # once (4µs+4µs) by Class::Load::BEGIN@10 at line 2
use warnings;
# spent 8µs making 1 call to Class::Load::BEGIN@2 # spent 4µs making 1 call to warnings::import
3package Data::OptList;
4{
52700ns $Data::OptList::VERSION = '0.109';
6}
7# ABSTRACT: parse and validate simple name/value option pairs
8
9215µs12µs
# spent 2µs within Data::OptList::BEGIN@9 which was called: # once (2µs+0s) by Class::Load::BEGIN@10 at line 9
use List::Util ();
# spent 2µs making 1 call to Data::OptList::BEGIN@9
10283µs12.81ms
# spent 2.81ms (2.05+762µs) within Data::OptList::BEGIN@10 which was called: # once (2.05ms+762µs) by Class::Load::BEGIN@10 at line 10
use Params::Util ();
# spent 2.81ms making 1 call to Data::OptList::BEGIN@10
113104µs21.16ms
# spent 1.15ms (960µs+192µs) within Data::OptList::BEGIN@11 which was called: # once (960µs+192µs) by Class::Load::BEGIN@10 at line 11
use Sub::Install 0.921 ();
# spent 1.15ms making 1 call to Data::OptList::BEGIN@11 # spent 12µs making 1 call to UNIVERSAL::VERSION
12
13
141100nsmy %test_for;
15
# spent 5µs within Data::OptList::BEGIN@15 which was called: # once (5µs+0s) by Class::Load::BEGIN@10 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 );
221282µs15µs}
# spent 5µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 294µs (197+96) within Data::OptList::__is_a which was called 79 times, avg 4µs/call: # 42 times (90µs+-90µs) by List::Util::first at line 27, avg 0s/call # 37 times (107µs+186µs) by Data::OptList::mkopt at line 77, avg 8µs/call
sub __is_a {
257913µs my ($got, $expected) = @_;
26
27121175µs79186µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 186µs making 37 calls to List::Util::first, avg 5µs/call # spent 109µs making 42 calls to Data::OptList::__is_a, avg 3µs/call, recursion: max depth 1, sum of overlapping time 109µs
28
29 return defined (
30 exists($test_for{$expected})
3142120µs4219µs ? $test_for{$expected}->($got)
# spent 10µs making 33 calls to Params::Util::_CODELIKE, avg 312ns/call # spent 5µs making 4 calls to Params::Util::_HASHLIKE, avg 1µs/call # spent 3µs making 4 calls to Params::Util::_ARRAYLIKE, avg 825ns/call # spent 400ns making 1 call to Params::Util::_SCALAR0
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 1.43ms (1.08+356µs) within Data::OptList::mkopt which was called 77 times, avg 19µs/call: # 52 times (566µs+11µs) by Sub::Exporter::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 11µs/call # 11 times (351µs+330µs) by Data::OptList::mkopt_hash at line 94, avg 62µs/call # 8 times (114µs+15µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 16µs/call # 6 times (48µs+0s) by Moose::Meta::Class::superclasses at line 554 of Moose/Meta/Class.pm, avg 8µs/call
sub mkopt {
377722µs my ($opt_list) = shift;
38
397715µs my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
427760µs83µs if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) {
# spent 3µs making 8 calls to Params::Util::_HASHLIKE, avg 362ns/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 {
477733µs ($moniker, $require_unique, $must_be) = @_;
48 }
49
507727µs $moniker = 'unnamed' unless defined $moniker;
51
527711µs return [] unless $opt_list;
53
54176224µs
# spent 60µs within Data::OptList::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Data/OptList.pm:54] which was called 99 times, avg 602ns/call: # 99 times (60µs+0s) by Data::OptList::mkopt at line 71, avg 602ns/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
577755µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
607711µs my @return;
61 my %seen;
62
6377115µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
6415035µs my $name = $opt_list->[$i];
6515012µs my $value;
66
6715032µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
71150135µs9960µs if ($i == $#$opt_list) { $value = undef; }
# spent 60µs making 99 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 602ns/call
72 elsif (not defined $opt_list->[$i+1]) { $value = undef; $i++ }
73 elsif ($name_test->($opt_list->[$i+1])) { $value = undef; }
743910µs else { $value = $opt_list->[++$i] }
75
7615049µs if ($must_be and defined $value) {
773722µs37294µs unless (__is_a($value, $must_be)) {
# spent 294µs making 37 calls to Data::OptList::__is_a, avg 8µs/call
78 my $ref = ref $value;
79 Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 }
81 }
82
8315097µs push @return, [ $name => $value ];
84 }
85
8677241µs return \@return;
87}
88
89
90
# spent 767µs (86+680) within Data::OptList::mkopt_hash which was called 18 times, avg 43µs/call: # 12 times (72µs+570µs) by Sub::Exporter::_rewrite_build_config at line 254 of Sub/Exporter.pm, avg 53µs/call # 6 times (14µs+111µs) by Sub::Exporter::_rewrite_build_config at line 268 of Sub/Exporter.pm, avg 21µs/call
sub mkopt_hash {
91189µs my ($opt_list, $moniker, $must_be) = @_;
921811µs return {} unless $opt_list;
93
941110µs11680µs $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 680µs making 11 calls to Data::OptList::mkopt, avg 62µs/call
951134µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
961122µs return \%hash;
97}
98
99
100
# spent 12µs (7+5) within Data::OptList::BEGIN@100 which was called: # once (7µs+5µs) by Class::Load::BEGIN@10 at line 104
BEGIN {
10115µs15µs *import = Sub::Install::exporter {
# spent 5µs making 1 call to Sub::Install::exporter
102 exports => [qw(mkopt mkopt_hash)],
103 };
104116µs112µs}
# spent 12µs making 1 call to Data::OptList::BEGIN@100
105
10612µs1;
107
108__END__