← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Data/OptList.pm
StatementsExecuted 8831 statements in 5.74ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
310855.09ms6.11msData::OptList::::mkoptData::OptList::mkopt
1112.55ms3.26msData::OptList::::BEGIN@10Data::OptList::BEGIN@10
1111.14ms1.35msData::OptList::::BEGIN@11Data::OptList::BEGIN@11
46411431µs431µsData::OptList::::__ANON__[:54]Data::OptList::__ANON__[:54]
11221370µs518µsData::OptList::::__is_aData::OptList::__is_a (recurses: max depth 1, inclusive time 211µs)
1821116µs1.35msData::OptList::::mkopt_hashData::OptList::mkopt_hash
1119µs20µsClass::Load::::BEGIN@1 Class::Load::BEGIN@1
1118µs14µsData::OptList::::BEGIN@100Data::OptList::BEGIN@100
1116µs9µsClass::Load::::BEGIN@2 Class::Load::BEGIN@2
1114µs4µsData::OptList::::BEGIN@15Data::OptList::BEGIN@15
1113µs3µ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
1219µs230µs
# spent 20µs (9+10) within Class::Load::BEGIN@1 which was called: # once (9µs+10µs) by Class::Load::BEGIN@8 at line 1
use strict;
# spent 20µs making 1 call to Class::Load::BEGIN@1 # spent 10µs making 1 call to strict::import
2234µs212µs
# spent 9µs (6+3) within Class::Load::BEGIN@2 which was called: # once (6µs+3µs) by Class::Load::BEGIN@8 at line 2
use warnings;
# spent 9µs making 1 call to Class::Load::BEGIN@2 # spent 3µs making 1 call to warnings::import
3package Data::OptList;
4{
52600ns $Data::OptList::VERSION = '0.108';
6}
7# ABSTRACT: parse and validate simple name/value option pairs
8
9218µs13µs
# spent 3µs within Data::OptList::BEGIN@9 which was called: # once (3µs+0s) by Class::Load::BEGIN@8 at line 9
use List::Util ();
# spent 3µs making 1 call to Data::OptList::BEGIN@9
102117µs13.26ms
# spent 3.26ms (2.55+718µs) within Data::OptList::BEGIN@10 which was called: # once (2.55ms+718µs) by Class::Load::BEGIN@8 at line 10
use Params::Util ();
# spent 3.26ms making 1 call to Data::OptList::BEGIN@10
113120µs21.35ms
# spent 1.35ms (1.14+206µs) within Data::OptList::BEGIN@11 which was called: # once (1.14ms+206µs) by Class::Load::BEGIN@8 at line 11
use Sub::Install 0.921 ();
# spent 1.35ms making 1 call to Data::OptList::BEGIN@11 # spent 8µs making 1 call to UNIVERSAL::VERSION
12
13
141100nsmy %test_for;
15
# spent 4µs within Data::OptList::BEGIN@15 which was called: # once (4µs+0s) by Class::Load::BEGIN@8 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 );
221363µs14µs}
# spent 4µs making 1 call to Data::OptList::BEGIN@15
23
24
# spent 518µs (370+148) within Data::OptList::__is_a which was called 112 times, avg 5µs/call: # 59 times (178µs+-178µs) by List::Util::first at line 27, avg 0s/call # 53 times (192µs+326µs) by Data::OptList::mkopt at line 77, avg 10µs/call
sub __is_a {
2511220µs my ($got, $expected) = @_;
26
27171260µs112326µs return List::Util::first { __is_a($got, $_) } @$expected if ref $expected;
# spent 326µs making 53 calls to List::Util::first, avg 6µs/call # spent 211µs making 59 calls to Data::OptList::__is_a, avg 4µs/call, recursion: max depth 1, sum of overlapping time 211µs
28
29 return defined (
3059207µs5934µs exists($test_for{$expected})
# spent 22µs making 48 calls to Params::Util::_CODELIKE, avg 456ns/call # spent 7µs making 5 calls to Params::Util::_HASHLIKE, avg 1µs/call # spent 4µs making 5 calls to Params::Util::_ARRAYLIKE, avg 840ns/call # spent 700ns making 1 call to Params::Util::_SCALAR0
31 ? $test_for{$expected}->($got)
32 : Params::Util::_INSTANCE($got, $expected) ## no critic
33 );
34}
35
36
# spent 6.11ms (5.09+1.02) within Data::OptList::mkopt which was called 310 times, avg 20µs/call: # 67 times (540µs+8µs) by Moose::Meta::Class::superclasses at line 561 of Moose/Meta/Class.pm, avg 8µs/call # 58 times (1.91ms+311µs) by Sub::Exporter::_expand_group at line 120 of Sub/Exporter.pm, avg 38µs/call # 56 times (794µs+61µs) by Moose::Meta::Class::_anon_cache_key at line 120 of Moose/Meta/Class.pm, avg 15µs/call # 56 times (608µs+32µs) by Moose::Meta::Class::_anon_cache_key at line 126 of Moose/Meta/Class.pm, avg 11µs/call # 38 times (303µs+1µs) by Sub::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Sub/Exporter.pm:337] at line 316 of Sub/Exporter.pm, avg 8µs/call # 21 times (252µs+18µs) by Moose::Util::_apply_all_roles at line 122 of Moose/Util.pm, avg 13µs/call # 12 times (648µs+590µs) by Data::OptList::mkopt_hash at line 94, avg 103µs/call # 2 times (30µs+2µs) by Class::Load::load_first_existing_class at line 45 of Class/Load.pm, avg 16µs/call
sub mkopt {
3731061µs my ($opt_list) = shift;
38
393106µs my ($moniker, $require_unique, $must_be); # the old positional args
40 my $name_test;
41
42310354µs13568µs if (@_ == 1 and Params::Util::_HASHLIKE($_[0])) {
# spent 68µs making 135 calls to Params::Util::_HASHLIKE, avg 507ns/call
43779µs my $arg = $_[0];
447798µs ($moniker, $require_unique, $must_be, $name_test)
45 = @$arg{ qw(moniker require_unique must_be name_test) };
46 } else {
4723378µs ($moniker, $require_unique, $must_be) = @_;
48 }
49
5031050µs $moniker = 'unnamed' unless defined $moniker;
51
523108µs return [] unless $opt_list;
53
547741.13ms
# spent 431µs within Data::OptList::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/Data/OptList.pm:54] which was called 464 times, avg 929ns/call: # 464 times (431µs+0s) by Data::OptList::mkopt at line 71, avg 929ns/call
$name_test ||= sub { ! ref $_[0] };
55
56 $opt_list = [
57310116µs map { $_ => (ref $opt_list->{$_} ? $opt_list->{$_} : ()) } keys %$opt_list
58 ] if ref $opt_list eq 'HASH';
59
6031017µs my @return;
6131014µs my %seen;
62
63310264µs for (my $i = 0; $i < @$opt_list; $i++) { ## no critic
64672122µs my $name = $opt_list->[$i];
65672900ns my $value;
66
6767230µs if ($require_unique) {
68 Carp::croak "multiple definitions provided for $name" if $seen{$name}++;
69 }
70
71672631µs469437µs if ($i == $#$opt_list) { $value = undef; }
# spent 431µs making 464 calls to Data::OptList::__ANON__[Data/OptList.pm:54], avg 929ns/call # spent 5µs making 5 calls to Moose::Util::__ANON__[Moose/Util.pm:121], 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; }
745413µs else { $value = $opt_list->[++$i] }
75
7667268µs if ($must_be and defined $value) {
775338µs53518µs unless (__is_a($value, $must_be)) {
# spent 518µs making 53 calls to Data::OptList::__is_a, avg 10µs/call
78 my $ref = ref $value;
79 Carp::croak "$ref-ref values are not valid in $moniker opt list";
80 }
81 }
82
83672472µs push @return, [ $name => $value ];
84 }
85
86310859µs return \@return;
87}
88
89
90
# spent 1.35ms (116µs+1.24) within Data::OptList::mkopt_hash which was called 18 times, avg 75µs/call: # 12 times (89µs+1.06ms) by Sub::Exporter::_rewrite_build_config at line 253 of Sub/Exporter.pm, avg 96µs/call # 6 times (26µs+180µs) by Sub::Exporter::_rewrite_build_config at line 266 of Sub/Exporter.pm, avg 34µs/call
sub mkopt_hash {
91188µs my ($opt_list, $moniker, $must_be) = @_;
921811µs return {} unless $opt_list;
93
941211µs121.24ms $opt_list = mkopt($opt_list, $moniker, 1, $must_be);
# spent 1.24ms making 12 calls to Data::OptList::mkopt, avg 103µs/call
951245µs my %hash = map { $_->[0] => $_->[1] } @$opt_list;
961236µs return \%hash;
97}
98
99
100
# spent 14µs (8+6) within Data::OptList::BEGIN@100 which was called: # once (8µs+6µs) by Class::Load::BEGIN@8 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 };
104119µs114µs}
# spent 14µs making 1 call to Data::OptList::BEGIN@100
105
10615µs1;
107
108__END__