← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:09 2016

Filename/usr/share/perl5/Method/Generate/Constructor.pm
StatementsExecuted 1937 statements in 4.46ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.22ms1.59msMethod::Generate::Constructor::::BEGIN@4Method::Generate::Constructor::BEGIN@4
1011854µs3.48msMethod::Generate::Constructor::::_assign_newMethod::Generate::Constructor::_assign_new
211450µs789µsMethod::Generate::Constructor::::buildall_generatorMethod::Generate::Constructor::buildall_generator
1011449µs5.92msMethod::Generate::Constructor::::generate_methodMethod::Generate::Constructor::generate_method
2643432µs456µsMethod::Generate::Constructor::::register_attribute_specsMethod::Generate::Constructor::register_attribute_specs
1011330µs357µsMethod::Generate::Constructor::::_check_requiredMethod::Generate::Constructor::_check_required
7611185µs185µsMethod::Generate::Constructor::::_cap_callMethod::Generate::Constructor::_cap_call
101182µs11.4msMethod::Generate::Constructor::::__ANON__[:76]Method::Generate::Constructor::__ANON__[:76]
101179µs343µsMethod::Generate::Constructor::::install_delayedMethod::Generate::Constructor::install_delayed
101165µs87µsMethod::Generate::Constructor::::_build_construction_stringMethod::Generate::Constructor::_build_construction_string
101164µs87µsMethod::Generate::Constructor::::_handle_subconstructorMethod::Generate::Constructor::_handle_subconstructor
303158µs58µsMethod::Generate::Constructor::::CORE:sortMethod::Generate::Constructor::CORE:sort (opcode)
101141µs128µsMethod::Generate::Constructor::::construction_stringMethod::Generate::Constructor::construction_string
821124µs24µsMethod::Generate::Constructor::::CORE:substMethod::Generate::Constructor::CORE:subst (opcode)
202120µs20µsMethod::Generate::Constructor::::accessor_generatorMethod::Generate::Constructor::accessor_generator
11120µs73µsMethod::Generate::Constructor::::BEGIN@3Method::Generate::Constructor::BEGIN@3
11112µs74µsMethod::Generate::Constructor::::BEGIN@8Method::Generate::Constructor::BEGIN@8
11111µs75µsMethod::Generate::Constructor::::BEGIN@5Method::Generate::Constructor::BEGIN@5
61110µs10µsMethod::Generate::Constructor::::_generate_argsMethod::Generate::Constructor::_generate_args
11110µs339µsMethod::Generate::Constructor::::BEGIN@197Method::Generate::Constructor::BEGIN@197
11110µs46µsMethod::Generate::Constructor::::BEGIN@6Method::Generate::Constructor::BEGIN@6
1118µs32µsMethod::Generate::Constructor::::BEGIN@7Method::Generate::Constructor::BEGIN@7
4117µs7µsMethod::Generate::Constructor::::_generate_args_via_buildargsMethod::Generate::Constructor::_generate_args_via_buildargs
1116µs45µsMethod::Generate::Constructor::::__ANON__[:197]Method::Generate::Constructor::__ANON__[:197]
0000s0sMethod::Generate::Constructor::::all_attribute_specsMethod::Generate::Constructor::all_attribute_specs
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Method::Generate::Constructor;
2
3341µs3127µs
# spent 73µs (20+54) within Method::Generate::Constructor::BEGIN@3 which was called: # once (20µs+54µs) by Moo::_constructor_maker_for at line 3
use strictures 1;
# spent 73µs making 1 call to Method::Generate::Constructor::BEGIN@3 # spent 35µs making 1 call to strictures::import # spent 18µs making 1 call to strictures::VERSION
42131µs21.62ms
# spent 1.59ms (1.22+362µs) within Method::Generate::Constructor::BEGIN@4 which was called: # once (1.22ms+362µs) by Moo::_constructor_maker_for at line 4
use Sub::Quote;
# spent 1.59ms making 1 call to Method::Generate::Constructor::BEGIN@4 # spent 38µs making 1 call to Exporter::import
5233µs2140µs
# spent 75µs (11+65) within Method::Generate::Constructor::BEGIN@5 which was called: # once (11µs+65µs) by Moo::_constructor_maker_for at line 5
use base qw(Moo::Object);
# spent 75µs making 1 call to Method::Generate::Constructor::BEGIN@5 # spent 65µs making 1 call to base::import
6232µs282µs
# spent 46µs (10+36) within Method::Generate::Constructor::BEGIN@6 which was called: # once (10µs+36µs) by Moo::_constructor_maker_for at line 6
use Sub::Defer;
# spent 46µs making 1 call to Method::Generate::Constructor::BEGIN@6 # spent 36µs making 1 call to Exporter::import
7231µs255µs
# spent 32µs (8+24) within Method::Generate::Constructor::BEGIN@7 which was called: # once (8µs+24µs) by Moo::_constructor_maker_for at line 7
use B 'perlstring';
# spent 32µs making 1 call to Method::Generate::Constructor::BEGIN@7 # spent 24µs making 1 call to Exporter::import
821.16ms2135µs
# spent 74µs (12+62) within Method::Generate::Constructor::BEGIN@8 which was called: # once (12µs+62µs) by Moo::_constructor_maker_for at line 8
use Moo::_Utils qw(_getstash);
# spent 74µs making 1 call to Method::Generate::Constructor::BEGIN@8 # spent 62µs making 1 call to Exporter::import
9
10
# spent 456µs (432+24) within Method::Generate::Constructor::register_attribute_specs which was called 26 times, avg 18µs/call: # 10 times (315µs+19µs) by Moo::Role::_handle_constructor at line 351 of Moo/Role.pm, avg 33µs/call # 10 times (44µs+0s) by Moo::_constructor_maker_for at line 199 of Moo.pm, avg 4µs/call # 5 times (41µs+3µs) by Moo::has at line 54 of Moo.pm, avg 9µs/call # once (31µs+2µs) by Moo::_constructor_maker_for at line 198
sub register_attribute_specs {
112633µs my ($self, @new_specs) = @_;
122620µs my $specs = $self->{attribute_specs}||={};
132694µs while (my ($name, $new_spec) = splice @new_specs, 0, 2) {
1482164µs8224µs if ($name =~ s/^\+//) {
# spent 24µs making 82 calls to Method::Generate::Constructor::CORE:subst, avg 294ns/call
15 die "has '+${name}' given but no ${name} attribute already exists"
16 unless my $old_spec = $specs->{$name};
17 foreach my $key (keys %$old_spec) {
18 if (!exists $new_spec->{$key}) {
19 $new_spec->{$key} = $old_spec->{$key}
20 unless $key eq 'handles';
21 }
22 elsif ($key eq 'moosify') {
23 $new_spec->{$key} = [
24 map { ref $_ eq 'ARRAY' ? @$_ : $_ }
25 ($old_spec->{$key}, $new_spec->{$key})
26 ];
27 }
28 }
29 }
308223µs if (exists $new_spec->{init_arg} && !defined $new_spec->{init_arg}
31 && $new_spec->{required}) {
32 die "${name} attribute can't be required with init_arg => undef";
33 }
348248µs $new_spec->{index} = scalar keys %$specs
35 unless defined $new_spec->{index};
368242µs $specs->{$name} = $new_spec;
37 }
382659µs $self;
39}
40
41sub all_attribute_specs {
42 $_[0]->{attribute_specs}
43}
44
45
# spent 20µs within Method::Generate::Constructor::accessor_generator which was called 20 times, avg 995ns/call: # 10 times (12µs+0s) by Method::Generate::Constructor::_build_construction_string at line 63, avg 1µs/call # 10 times (8µs+0s) by Method::Generate::Constructor::_assign_new at line 163, avg 770ns/call
sub accessor_generator {
462049µs $_[0]->{accessor_generator}
47}
48
49
# spent 128µs (41+87) within Method::Generate::Constructor::construction_string which was called 10 times, avg 13µs/call: # 10 times (41µs+87µs) by Method::Generate::Constructor::generate_method at line 96, avg 13µs/call
sub construction_string {
50104µs my ($self) = @_;
511034µs1087µs $self->{construction_string}
# spent 87µs making 10 calls to Method::Generate::Constructor::_build_construction_string, avg 9µs/call
52 ||= $self->_build_construction_string;
53}
54
55
# spent 789µs (450+339) within Method::Generate::Constructor::buildall_generator which was called 2 times, avg 395µs/call: # 2 times (450µs+339µs) by Method::Generate::Constructor::generate_method at line 98, avg 395µs/call
sub buildall_generator {
56292µs require Method::Generate::BuildAll;
57211µs227µs Method::Generate::BuildAll->new;
# spent 27µs making 2 calls to Moo::Object::new, avg 14µs/call
58}
59
60
# spent 87µs (65+22) within Method::Generate::Constructor::_build_construction_string which was called 10 times, avg 9µs/call: # 10 times (65µs+22µs) by Method::Generate::Constructor::construction_string at line 51, avg 9µs/call
sub _build_construction_string {
61102µs my ($self) = @_;
62104µs my $builder = $self->{construction_builder};
631044µs2022µs $builder ? $self->$builder
# spent 12µs making 10 calls to Method::Generate::Constructor::accessor_generator, avg 1µs/call # spent 10µs making 10 calls to Method::Generate::Accessor::default_construction_string, avg 1µs/call
64 : 'bless('
65 .$self->accessor_generator->default_construction_string
66 .', $class);'
67}
68
69
# spent 343µs (79+264) within Method::Generate::Constructor::install_delayed which was called 10 times, avg 34µs/call: # 10 times (79µs+264µs) by Moo::_constructor_maker_for at line 199 of Moo.pm, avg 34µs/call
sub install_delayed {
70104µs my ($self) = @_;
71108µs my $package = $self->{package};
72
# spent 11.4ms (82µs+11.3) within Method::Generate::Constructor::__ANON__[/usr/share/perl5/Method/Generate/Constructor.pm:76] which was called 10 times, avg 1.14ms/call: # 10 times (82µs+11.3ms) by Sub::Defer::undefer_sub at line 22 of Sub/Defer.pm, avg 1.14ms/call
defer_sub "${package}::new" => sub {
731064µs2011.3ms unquote_sub $self->generate_method(
# spent 5.92ms making 10 calls to Method::Generate::Constructor::generate_method, avg 592µs/call # spent 5.36ms making 10 calls to Sub::Quote::unquote_sub, avg 536µs/call
74 $package, 'new', $self->{attribute_specs}, { no_install => 1 }
75 )
761048µs10264µs };
# spent 264µs making 10 calls to Sub::Defer::defer_sub, avg 26µs/call
771019µs $self;
78}
79
80
# spent 5.92ms (449µs+5.47) within Method::Generate::Constructor::generate_method which was called 10 times, avg 592µs/call: # 10 times (449µs+5.47ms) by Method::Generate::Constructor::__ANON__[/usr/share/perl5/Method/Generate/Constructor.pm:76] at line 73, avg 592µs/call
sub generate_method {
81105µs my ($self, $into, $name, $spec, $quote_opts) = @_;
821052µs foreach my $no_init (grep !exists($spec->{$_}{init_arg}), keys %$spec) {
837638µs $spec->{$no_init}{init_arg} = $no_init;
84 }
851010µs local $self->{captures} = {};
86103µs my $body = ' my $class = shift;'."\n"
87 .' $class = ref($class) if ref($class);'."\n";
881016µs1087µs $body .= $self->_handle_subconstructor($into, $name);
# spent 87µs making 10 calls to Method::Generate::Constructor::_handle_subconstructor, avg 9µs/call
891063µs1033µs my $into_buildargs = $into->can('BUILDARGS');
# spent 33µs making 10 calls to UNIVERSAL::can, avg 3µs/call
901019µs47µs if ( $into_buildargs && $into_buildargs != \&Moo::Object::BUILDARGS ) {
# spent 7µs making 4 calls to Method::Generate::Constructor::_generate_args_via_buildargs, avg 2µs/call
91 $body .= $self->_generate_args_via_buildargs;
92 } else {
93610µs610µs $body .= $self->_generate_args;
# spent 10µs making 6 calls to Method::Generate::Constructor::_generate_args, avg 2µs/call
94 }
951016µs10357µs $body .= $self->_check_required($spec);
# spent 357µs making 10 calls to Method::Generate::Constructor::_check_required, avg 36µs/call
961020µs10128µs $body .= ' my $new = '.$self->construction_string.";\n";
# spent 128µs making 10 calls to Method::Generate::Constructor::construction_string, avg 13µs/call
971027µs103.48ms $body .= $self->_assign_new($spec);
# spent 3.48ms making 10 calls to Method::Generate::Constructor::_assign_new, avg 348µs/call
981083µs14895µs if ($into->can('BUILD')) {
# spent 789µs making 2 calls to Method::Generate::Constructor::buildall_generator, avg 395µs/call # spent 62µs making 2 calls to Method::Generate::BuildAll::buildall_body_for, avg 31µs/call # spent 44µs making 10 calls to UNIVERSAL::can, avg 4µs/call
99 $body .= $self->buildall_generator->buildall_body_for(
100 $into, '$new', '$args'
101 );
102 }
103104µs $body .= ' return $new;'."\n";
1041052µs1029µs if ($into->can('DEMOLISH')) {
# spent 29µs making 10 calls to UNIVERSAL::can, avg 3µs/call
105 require Method::Generate::DemolishAll;
106 Method::Generate::DemolishAll->new->generate_method($into);
107 }
108 quote_sub
1091058µs10440µs "${into}::${name}" => $body,
# spent 440µs making 10 calls to Sub::Quote::quote_sub, avg 44µs/call
110 $self->{captures}, $quote_opts||{}
111 ;
112}
113
114
# spent 87µs (64+23) within Method::Generate::Constructor::_handle_subconstructor which was called 10 times, avg 9µs/call: # 10 times (64µs+23µs) by Method::Generate::Constructor::generate_method at line 88, avg 9µs/call
sub _handle_subconstructor {
115104µs my ($self, $into, $name) = @_;
1161098µs1023µs if (my $gen = $self->{subconstructor_handler}) {
# spent 23µs making 10 calls to B::perlstring, avg 2µs/call
117 ' if ($class ne '.perlstring($into).') {'."\n".
118 $gen.
119 ' }'."\n";
120 } else {
121 ''
122 }
123}
124
125
# spent 185µs within Method::Generate::Constructor::_cap_call which was called 76 times, avg 2µs/call: # 76 times (185µs+0s) by Method::Generate::Constructor::_assign_new at line 176, avg 2µs/call
sub _cap_call {
1267627µs my ($self, $code, $captures) = @_;
1277680µs @{$self->{captures}}{keys %$captures} = values %$captures if $captures;
12876162µs $code;
129}
130
131
# spent 7µs within Method::Generate::Constructor::_generate_args_via_buildargs which was called 4 times, avg 2µs/call: # 4 times (7µs+0s) by Method::Generate::Constructor::generate_method at line 90, avg 2µs/call
sub _generate_args_via_buildargs {
13242µs my ($self) = @_;
133421µs q{ my $args = $class->BUILDARGS(@_);}."\n"
134 .q{ die "BUILDARGS did not return a hashref" unless ref($args) eq 'HASH';}
135 ."\n";
136}
137
138# inlined from Moo::Object - update that first.
139
# spent 10µs within Method::Generate::Constructor::_generate_args which was called 6 times, avg 2µs/call: # 6 times (10µs+0s) by Method::Generate::Constructor::generate_method at line 93, avg 2µs/call
sub _generate_args {
14062µs my ($self) = @_;
141619µs return <<'_EOA';
142 my $args;
143 if ( scalar @_ == 1 ) {
144 unless ( defined $_[0] && ref $_[0] eq 'HASH' ) {
145 die "Single parameters to new() must be a HASH ref"
146 ." data => ". $_[0] ."\n";
147 }
148 $args = { %{ $_[0] } };
149 }
150 elsif ( @_ % 2 ) {
151 die "The new() method for $class expects a hash reference or a key/value list."
152 . " You passed an odd number of arguments\n";
153 }
154 else {
155 $args = {@_};
156 }
157_EOA
158
159}
160
161
# spent 3.48ms (854µs+2.63) within Method::Generate::Constructor::_assign_new which was called 10 times, avg 348µs/call: # 10 times (854µs+2.63ms) by Method::Generate::Constructor::generate_method at line 97, avg 348µs/call
sub _assign_new {
162104µs my ($self, $spec) = @_;
163109µs108µs my $ag = $self->accessor_generator;
# spent 8µs making 10 calls to Method::Generate::Constructor::accessor_generator, avg 770ns/call
164101µs my %test;
1651052µs1017µs NAME: foreach my $name (sort keys %$spec) {
# spent 17µs making 10 calls to Method::Generate::Constructor::CORE:sort, avg 2µs/call
1668217µs my $attr_spec = $spec->{$name};
1678224µs68µs next NAME unless defined($attr_spec->{init_arg})
# spent 8µs making 6 calls to Method::Generate::Accessor::has_eager_default, avg 1µs/call
168 or $ag->has_eager_default($name, $attr_spec);
1697646µs $test{$name} = $attr_spec->{init_arg};
170 }
17176234µs7677µs join '', map {
# spent 77µs making 76 calls to B::perlstring, avg 1µs/call
17210150µs1013µs my $arg_key = perlstring($test{$_});
# spent 13µs making 10 calls to Method::Generate::Constructor::CORE:sort, avg 1µs/call
1737634µs my $test = "exists \$args->{$arg_key}";
1747621µs my $source = "\$args->{$arg_key}";
1757622µs my $attr_spec = $spec->{$_};
17676179µs1522.51ms $self->_cap_call($ag->generate_populate_set(
# spent 2.32ms making 76 calls to Method::Generate::Accessor::generate_populate_set, avg 31µs/call # spent 185µs making 76 calls to Method::Generate::Constructor::_cap_call, avg 2µs/call
177 '$new', $_, $attr_spec, $source, $test, $test{$_},
178 ));
179 } sort keys %test;
180}
181
182
# spent 357µs (330+28) within Method::Generate::Constructor::_check_required which was called 10 times, avg 36µs/call: # 10 times (330µs+28µs) by Method::Generate::Constructor::generate_method at line 95, avg 36µs/call
sub _check_required {
183103µs my ($self, $spec) = @_;
184 my @required_init =
185 map $spec->{$_}{init_arg},
186 grep {
18792266µs1028µs my %s = %{$spec->{$_}}; # ignore required if default or builder set
# spent 28µs making 10 calls to Method::Generate::Constructor::CORE:sort, avg 3µs/call
1888258µs $s{required} and not($s{builder} or $s{default})
189 } sort keys %$spec;
1901010µs return '' unless @required_init;
191836µs ' if (my @missing = grep !exists $args->{$_}, qw('
192 .join(' ',@required_init).')) {'."\n"
193 .q{ die "Missing required arguments: ".join(', ', sort @missing);}."\n"
194 ." }\n";
195}
196
197481µs3708µs
# spent 339µs (10+330) within Method::Generate::Constructor::BEGIN@197 which was called: # once (10µs+330µs) by Moo::_constructor_maker_for at line 197 # spent 45µs (6+39) within Method::Generate::Constructor::__ANON__[/usr/share/perl5/Method/Generate/Constructor.pm:197] which was called: # once (6µs+39µs) by import::into at line 34 of Import/Into.pm
use Moo;
# spent 339µs making 1 call to Method::Generate::Constructor::BEGIN@197 # spent 330µs making 1 call to Moo::import # spent 39µs making 1 call to strictures::import
198116µs233µsMoo->_constructor_maker_for(__PACKAGE__)->register_attribute_specs(
# spent 33µs making 1 call to Method::Generate::Constructor::register_attribute_specs # spent 7.03ms making 1 call to Moo::_constructor_maker_for, recursion: max depth 1, sum of overlapping time 7.03ms
199 attribute_specs => {
200 is => 'ro',
201 reader => 'all_attribute_specs',
202 },
203 accessor_generator => { is => 'ro' },
204 construction_string => { is => 'lazy' },
205 construction_builder => { is => 'lazy' },
206 subconstructor_handler => { is => 'ro' },
207 package => { is => 'ro' },
208);
209
21016µs1;
 
# spent 58µs within Method::Generate::Constructor::CORE:sort which was called 30 times, avg 2µs/call: # 10 times (28µs+0s) by Method::Generate::Constructor::_check_required at line 187, avg 3µs/call # 10 times (17µs+0s) by Method::Generate::Constructor::_assign_new at line 165, avg 2µs/call # 10 times (13µs+0s) by Method::Generate::Constructor::_assign_new at line 172, avg 1µs/call
sub Method::Generate::Constructor::CORE:sort; # opcode
# spent 24µs within Method::Generate::Constructor::CORE:subst which was called 82 times, avg 294ns/call: # 82 times (24µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 14, avg 294ns/call
sub Method::Generate::Constructor::CORE:subst; # opcode