Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Method/Generate/Constructor.pm |
Statements | Executed 2498 statements in 7.16ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
62 | 4 | 2 | 961µs | 1.96ms | register_attribute_specs | Method::Generate::Constructor::
3 | 1 | 1 | 854µs | 1.13ms | buildall_generator | Method::Generate::Constructor::
8 | 1 | 1 | 682µs | 17.4ms | _assign_new | Method::Generate::Constructor::
8 | 1 | 1 | 563µs | 33.3ms | generate_method | Method::Generate::Constructor::
1 | 1 | 1 | 509µs | 523µs | BEGIN@10 | Method::Generate::Constructor::
74 | 3 | 2 | 414µs | 944µs | assert_constructor | Method::Generate::Constructor::
74 | 1 | 1 | 335µs | 530µs | current_constructor | Method::Generate::Constructor::
8 | 1 | 1 | 294µs | 33.7ms | __ANON__[:101] | Method::Generate::Constructor::
10 | 1 | 1 | 254µs | 2.75ms | install_delayed | Method::Generate::Constructor::
8 | 1 | 1 | 163µs | 224µs | _check_required | Method::Generate::Constructor::
76 | 3 | 1 | 139µs | 139µs | accessor_generator | Method::Generate::Constructor::
55 | 1 | 1 | 125µs | 125µs | _cap_call | Method::Generate::Constructor::
7 | 1 | 1 | 73µs | 129µs | _build_construction_string | Method::Generate::Constructor::
8 | 1 | 1 | 67µs | 296µs | _handle_subconstructor | Method::Generate::Constructor::
63 | 1 | 1 | 51µs | 51µs | CORE:subst (opcode) | Method::Generate::Constructor::
9 | 2 | 2 | 45µs | 174µs | construction_string | Method::Generate::Constructor::
24 | 3 | 1 | 34µs | 34µs | CORE:sort (opcode) | Method::Generate::Constructor::
1 | 1 | 1 | 24µs | 27µs | BEGIN@2 | Method::Generate::Constructor::
6 | 1 | 1 | 17µs | 17µs | _generate_args | Method::Generate::Constructor::
1 | 1 | 1 | 8µs | 301µs | BEGIN@12 | Method::Generate::Constructor::
1 | 1 | 1 | 7µs | 21µs | BEGIN@8 | Method::Generate::Constructor::
1 | 1 | 1 | 6µs | 43µs | BEGIN@3 | Method::Generate::Constructor::
1 | 1 | 1 | 6µs | 38µs | BEGIN@5 | Method::Generate::Constructor::
1 | 1 | 1 | 6µs | 29µs | BEGIN@7 | Method::Generate::Constructor::
1 | 1 | 1 | 5µs | 18µs | BEGIN@9 | Method::Generate::Constructor::
1 | 1 | 1 | 4µs | 4µs | BEGIN@11 | Method::Generate::Constructor::
1 | 1 | 1 | 4µs | 29µs | BEGIN@6 | Method::Generate::Constructor::
2 | 1 | 1 | 4µs | 4µs | _generate_args_via_buildargs | Method::Generate::Constructor::
3 | 2 | 1 | 4µs | 4µs | all_attribute_specs | Method::Generate::Constructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Method::Generate::Constructor; | ||||
2 | 2 | 31µs | 2 | 30µs | # spent 27µs (24+3) within Method::Generate::Constructor::BEGIN@2 which was called:
# once (24µs+3µs) by Moo::_constructor_maker_for at line 2 # spent 27µs making 1 call to Method::Generate::Constructor::BEGIN@2
# spent 3µs making 1 call to strict::import |
3 | 2 | 31µs | 2 | 80µs | # spent 43µs (6+37) within Method::Generate::Constructor::BEGIN@3 which was called:
# once (6µs+37µs) by Moo::_constructor_maker_for at line 3 # spent 43µs making 1 call to Method::Generate::Constructor::BEGIN@3
# spent 37µs making 1 call to warnings::import |
4 | |||||
5 | 2 | 23µs | 2 | 70µs | # spent 38µs (6+32) within Method::Generate::Constructor::BEGIN@5 which was called:
# once (6µs+32µs) by Moo::_constructor_maker_for at line 5 # spent 38µs making 1 call to Method::Generate::Constructor::BEGIN@5
# spent 32µs making 1 call to Exporter::import |
6 | 2 | 22µs | 2 | 54µs | # spent 29µs (4+25) within Method::Generate::Constructor::BEGIN@6 which was called:
# once (4µs+25µs) by Moo::_constructor_maker_for at line 6 # spent 29µs making 1 call to Method::Generate::Constructor::BEGIN@6
# spent 25µs making 1 call to Exporter::import |
7 | 2 | 19µs | 2 | 52µs | # spent 29µs (6+23) within Method::Generate::Constructor::BEGIN@7 which was called:
# once (6µs+23µs) by Moo::_constructor_maker_for at line 7 # spent 29µs making 1 call to Method::Generate::Constructor::BEGIN@7
# spent 23µs making 1 call to Exporter::import |
8 | 2 | 20µs | 2 | 35µs | # spent 21µs (7+14) within Method::Generate::Constructor::BEGIN@8 which was called:
# once (7µs+14µs) by Moo::_constructor_maker_for at line 8 # spent 21µs making 1 call to Method::Generate::Constructor::BEGIN@8
# spent 14µs making 1 call to Exporter::import |
9 | 2 | 21µs | 2 | 31µs | # spent 18µs (5+13) within Method::Generate::Constructor::BEGIN@9 which was called:
# once (5µs+13µs) by Moo::_constructor_maker_for at line 9 # spent 18µs making 1 call to Method::Generate::Constructor::BEGIN@9
# spent 13µs making 1 call to Exporter::import |
10 | 2 | 407µs | 1 | 523µs | # spent 523µs (509+14) within Method::Generate::Constructor::BEGIN@10 which was called:
# once (509µs+14µs) by Moo::_constructor_maker_for at line 10 # spent 523µs making 1 call to Method::Generate::Constructor::BEGIN@10 |
11 | 1 | 34µs | 1 | 4µs | # spent 4µs within Method::Generate::Constructor::BEGIN@11 which was called:
# once (4µs+0s) by Moo::_constructor_maker_for at line 11 # spent 4µs making 1 call to Method::Generate::Constructor::BEGIN@11 |
12 | # spent 301µs (8+293) within Method::Generate::Constructor::BEGIN@12 which was called:
# once (8µs+293µs) by Moo::_constructor_maker_for at line 16 | ||||
13 | 1 | 0s | local $Moo::sification::disabled = 1; | ||
14 | 1 | 1µs | require Moo; | ||
15 | 1 | 5µs | 1 | 293µs | Moo->import; # spent 293µs making 1 call to Moo::import |
16 | 1 | 1.52ms | 1 | 301µs | } # spent 301µs making 1 call to Method::Generate::Constructor::BEGIN@12 |
17 | |||||
18 | # spent 1.96ms (961µs+1.00) within Method::Generate::Constructor::register_attribute_specs which was called 62 times, avg 32µs/call:
# 49 times (789µs+835µs) by Moo::has at line 119 of Moo.pm, avg 33µs/call
# 10 times (137µs+135µs) by Moo::_constructor_maker_for at line 262 of Moo.pm, avg 27µs/call
# 2 times (11µs+16µs) by Moo::_set_superclasses at line 158 of Moo.pm, avg 14µs/call
# once (24µs+15µs) by Moo::_constructor_maker_for at line 250 | ||||
19 | 62 | 35µs | my ($self, @new_specs) = @_; | ||
20 | 62 | 95µs | 62 | 773µs | $self->assert_constructor; # spent 773µs making 62 calls to Method::Generate::Constructor::assert_constructor, avg 12µs/call |
21 | 62 | 39µs | my $specs = $self->{attribute_specs}||={}; | ||
22 | 62 | 131µs | 62 | 106µs | my $ag = $self->accessor_generator; # spent 106µs making 62 calls to Method::Generate::Constructor::accessor_generator, avg 2µs/call |
23 | 62 | 169µs | while (my ($name, $new_spec) = splice @new_specs, 0, 2) { | ||
24 | 63 | 162µs | 63 | 51µs | if ($name =~ s/^\+//) { # spent 51µs making 63 calls to Method::Generate::Constructor::CORE:subst, avg 810ns/call |
25 | croak "has '+${name}' given but no ${name} attribute already exists" | ||||
26 | 2 | 1µs | unless my $old_spec = $specs->{$name}; | ||
27 | 2 | 6µs | 2 | 31µs | $ag->merge_specs($new_spec, $old_spec); # spent 31µs making 2 calls to Method::Generate::Accessor::merge_specs, avg 16µs/call |
28 | } | ||||
29 | 63 | 54µs | 13 | 40µs | if ($new_spec->{required} # spent 40µs making 13 calls to Method::Generate::Accessor::has_default, avg 3µs/call |
30 | && !( | ||||
31 | $ag->has_default($name, $new_spec) | ||||
32 | || !exists $new_spec->{init_arg} | ||||
33 | || defined $new_spec->{init_arg} | ||||
34 | ) | ||||
35 | ) { | ||||
36 | croak "You cannot have a required attribute (${name})" | ||||
37 | . " without a default, builder, or an init_arg"; | ||||
38 | } | ||||
39 | $new_spec->{index} = scalar keys %$specs | ||||
40 | 63 | 44µs | unless defined $new_spec->{index}; | ||
41 | 63 | 52µs | $specs->{$name} = $new_spec; | ||
42 | } | ||||
43 | 62 | 179µs | $self; | ||
44 | } | ||||
45 | |||||
46 | # spent 4µs within Method::Generate::Constructor::all_attribute_specs which was called 3 times, avg 1µs/call:
# 2 times (1µs+0s) by Moo::_set_superclasses at line 158 of Moo.pm, avg 500ns/call
# once (3µs+0s) by Moo::_constructor_maker_for at line 262 of Moo.pm | ||||
47 | $_[0]->{attribute_specs} | ||||
48 | 3 | 7µs | } | ||
49 | |||||
50 | # spent 139µs within Method::Generate::Constructor::accessor_generator which was called 76 times, avg 2µs/call:
# 62 times (106µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 22, avg 2µs/call
# 8 times (2µs+0s) by Method::Generate::Constructor::_assign_new at line 209, avg 250ns/call
# 6 times (31µs+0s) by Method::Generate::Constructor::_build_construction_string at line 68, avg 5µs/call | ||||
51 | $_[0]->{accessor_generator} | ||||
52 | 76 | 154µs | } | ||
53 | |||||
54 | # spent 174µs (45+129) within Method::Generate::Constructor::construction_string which was called 9 times, avg 19µs/call:
# 8 times (39µs+112µs) by Method::Generate::Constructor::generate_method at line 138, avg 19µs/call
# once (6µs+17µs) by Moo::_constructor_maker_for at line 237 of Moo.pm | ||||
55 | 9 | 5µs | my ($self) = @_; | ||
56 | $self->{construction_string} | ||||
57 | 9 | 39µs | 7 | 129µs | ||= $self->_build_construction_string; # spent 129µs making 7 calls to Method::Generate::Constructor::_build_construction_string, avg 18µs/call |
58 | } | ||||
59 | |||||
60 | # spent 1.13ms (854µs+280µs) within Method::Generate::Constructor::buildall_generator which was called 3 times, avg 378µs/call:
# 3 times (854µs+280µs) by Method::Generate::Constructor::generate_method at line 138, avg 378µs/call | ||||
61 | 3 | 442µs | require Method::Generate::BuildAll; | ||
62 | 3 | 56µs | 3 | 102µs | Method::Generate::BuildAll->new; # spent 102µs making 3 calls to Moo::Object::new, avg 34µs/call |
63 | } | ||||
64 | |||||
65 | # spent 129µs (73+56) within Method::Generate::Constructor::_build_construction_string which was called 7 times, avg 18µs/call:
# 7 times (73µs+56µs) by Method::Generate::Constructor::construction_string at line 57, avg 18µs/call | ||||
66 | 7 | 1µs | my ($self) = @_; | ||
67 | 7 | 4µs | my $builder = $self->{construction_builder}; | ||
68 | 7 | 72µs | 13 | 56µs | $builder ? $self->$builder # spent 31µs making 6 calls to Method::Generate::Constructor::accessor_generator, avg 5µs/call
# spent 15µs making 6 calls to Method::Generate::Accessor::default_construction_string, avg 2µs/call
# spent 10µs making 1 call to Moo::__ANON__[Moo.pm:256] |
69 | : 'bless(' | ||||
70 | .$self->accessor_generator->default_construction_string | ||||
71 | .', $class);' | ||||
72 | } | ||||
73 | |||||
74 | # spent 2.75ms (254µs+2.49) within Method::Generate::Constructor::install_delayed which was called 10 times, avg 274µs/call:
# 10 times (254µs+2.49ms) by Moo::_constructor_maker_for at line 262 of Moo.pm, avg 274µs/call | ||||
75 | 10 | 3µs | my ($self) = @_; | ||
76 | 10 | 24µs | 10 | 152µs | $self->assert_constructor; # spent 152µs making 10 calls to Method::Generate::Constructor::assert_constructor, avg 15µs/call |
77 | 10 | 5µs | my $package = $self->{package}; | ||
78 | 10 | 43µs | 10 | 7µs | my (undef, @isa) = @{_linear_isa($package)}; # spent 7µs making 10 calls to mro::get_linear_isa, avg 700ns/call |
79 | 10 | 11µs | my $isa = join ',', @isa; | ||
80 | 10 | 54µs | 10 | 1.81ms | my (undef, $from_file, $from_line) = caller(Carp::short_error_loc()); # spent 1.81ms making 10 calls to Carp::short_error_loc, avg 181µs/call |
81 | # spent 33.7ms (294µs+33.4) within Method::Generate::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Method/Generate/Constructor.pm:101] which was called 8 times, avg 4.22ms/call:
# 8 times (294µs+33.4ms) by Sub::Defer::undefer_sub at line 85 of Sub/Defer.pm, avg 4.22ms/call | ||||
82 | 8 | 180µs | 8 | 80µs | my (undef, @new_isa) = @{_linear_isa($package)}; # spent 80µs making 8 calls to mro::get_linear_isa, avg 10µs/call |
83 | 8 | 43µs | if (join(',', @new_isa) ne $isa) { | ||
84 | my ($expected_new) = grep { *{_getglob($_.'::new')}{CODE} } @isa; | ||||
85 | my ($found_new) = grep { *{_getglob($_.'::new')}{CODE} } @new_isa; | ||||
86 | if (($found_new||'') ne ($expected_new||'')) { | ||||
87 | $found_new ||= 'none'; | ||||
88 | $expected_new ||= 'none'; | ||||
89 | croak "Expected parent constructor of $package to be" | ||||
90 | . " $expected_new, but found $found_new: changing the inheritance" | ||||
91 | . " chain (\@ISA) at runtime (after $from_file line $from_line) is unsupported"; | ||||
92 | } | ||||
93 | } | ||||
94 | |||||
95 | my $constructor = $self->generate_method( | ||||
96 | 8 | 69µs | 8 | 33.3ms | $package, 'new', $self->{attribute_specs}, { no_install => 1, no_defer => 1 } # spent 33.3ms making 8 calls to Method::Generate::Constructor::generate_method, avg 4.17ms/call |
97 | ); | ||||
98 | 8 | 16µs | $self->{inlined} = 1; | ||
99 | 8 | 30µs | 8 | 7µs | weaken($self->{constructor} = $constructor); # spent 7µs making 8 calls to Scalar::Util::weaken, avg 875ns/call |
100 | 8 | 29µs | $constructor; | ||
101 | 10 | 60µs | 10 | 509µs | }; # spent 509µs making 10 calls to Sub::Defer::defer_sub, avg 51µs/call |
102 | 10 | 9µs | $self->{inlined} = 0; | ||
103 | 10 | 34µs | 10 | 9µs | weaken($self->{constructor} = $constructor); # spent 9µs making 10 calls to Scalar::Util::weaken, avg 900ns/call |
104 | 10 | 26µs | $self; | ||
105 | } | ||||
106 | |||||
107 | # spent 530µs (335+195) within Method::Generate::Constructor::current_constructor which was called 74 times, avg 7µs/call:
# 74 times (335µs+195µs) by Method::Generate::Constructor::assert_constructor at line 115, avg 7µs/call | ||||
108 | 74 | 32µs | my ($self, $package) = @_; | ||
109 | 74 | 309µs | 74 | 195µs | return *{_getglob("${package}::new")}{CODE}; # spent 195µs making 74 calls to Moo::_Utils::_getglob, avg 3µs/call |
110 | } | ||||
111 | |||||
112 | # spent 944µs (414+530) within Method::Generate::Constructor::assert_constructor which was called 74 times, avg 13µs/call:
# 62 times (346µs+427µs) by Method::Generate::Constructor::register_attribute_specs at line 20, avg 12µs/call
# 10 times (58µs+94µs) by Method::Generate::Constructor::install_delayed at line 76, avg 15µs/call
# 2 times (10µs+9µs) by Moo::_set_superclasses at line 155 of Moo.pm, avg 10µs/call | ||||
113 | 74 | 19µs | my ($self) = @_; | ||
114 | 74 | 59µs | my $package = $self->{package} or return 1; | ||
115 | 74 | 138µs | 74 | 530µs | my $current = $self->current_constructor($package) # spent 530µs making 74 calls to Method::Generate::Constructor::current_constructor, avg 7µs/call |
116 | or return 1; | ||||
117 | my $constructor = $self->{constructor} | ||||
118 | 64 | 30µs | or croak "Unknown constructor for $package already exists"; | ||
119 | 64 | 32µs | croak "Constructor for $package has been replaced with an unknown sub" | ||
120 | if $constructor != $current; | ||||
121 | croak "Constructor for $package has been inlined and cannot be updated" | ||||
122 | 64 | 196µs | if $self->{inlined}; | ||
123 | } | ||||
124 | |||||
125 | # spent 33.3ms (563µs+32.8) within Method::Generate::Constructor::generate_method which was called 8 times, avg 4.17ms/call:
# 8 times (563µs+32.8ms) by Method::Generate::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Method/Generate/Constructor.pm:101] at line 96, avg 4.17ms/call | ||||
126 | 8 | 3µs | my ($self, $into, $name, $spec, $quote_opts) = @_; | ||
127 | $quote_opts = { | ||||
128 | 8 | 48µs | %{$quote_opts||{}}, | ||
129 | package => $into, | ||||
130 | }; | ||||
131 | 8 | 118µs | foreach my $no_init (grep !exists($spec->{$_}{init_arg}), keys %$spec) { | ||
132 | 51 | 41µs | $spec->{$no_init}{init_arg} = $no_init; | ||
133 | } | ||||
134 | 8 | 8µs | local $self->{captures} = {}; | ||
135 | |||||
136 | 8 | 105µs | 8 | 54µs | my $into_buildargs = $into->can('BUILDARGS'); # spent 54µs making 8 calls to UNIVERSAL::can, avg 7µs/call |
137 | |||||
138 | 8 | 261µs | 54 | 19.4ms | my $body # spent 17.4ms making 8 calls to Method::Generate::Constructor::_assign_new, avg 2.18ms/call
# spent 1.13ms making 3 calls to Method::Generate::Constructor::buildall_generator, avg 378µs/call
# spent 296µs making 8 calls to Method::Generate::Constructor::_handle_subconstructor, avg 37µs/call
# spent 224µs making 8 calls to Method::Generate::Constructor::_check_required, avg 28µs/call
# spent 151µs making 8 calls to Method::Generate::Constructor::construction_string, avg 19µs/call
# spent 135µs making 3 calls to Method::Generate::BuildAll::buildall_body_for, avg 45µs/call
# spent 61µs making 8 calls to UNIVERSAL::can, avg 8µs/call
# spent 17µs making 6 calls to Method::Generate::Constructor::_generate_args, avg 3µs/call
# spent 4µs making 2 calls to Method::Generate::Constructor::_generate_args_via_buildargs, avg 2µs/call |
139 | = ' my $invoker = CORE::shift();'."\n" | ||||
140 | . ' my $class = CORE::ref($invoker) ? CORE::ref($invoker) : $invoker;'."\n" | ||||
141 | . $self->_handle_subconstructor($into, $name) | ||||
142 | . ( $into_buildargs && $into_buildargs != \&Moo::Object::BUILDARGS | ||||
143 | ? $self->_generate_args_via_buildargs | ||||
144 | : $self->_generate_args | ||||
145 | ) | ||||
146 | . $self->_check_required($spec) | ||||
147 | . ' my $new = '.$self->construction_string.";\n" | ||||
148 | . $self->_assign_new($spec) | ||||
149 | . ( $into->can('BUILD') | ||||
150 | ? $self->buildall_generator->buildall_body_for( $into, '$new', '$args' ) | ||||
151 | : '' | ||||
152 | ) | ||||
153 | . ' return $new;'."\n"; | ||||
154 | |||||
155 | 8 | 40µs | 8 | 19µs | if ($into->can('DEMOLISH')) { # spent 19µs making 8 calls to UNIVERSAL::can, avg 2µs/call |
156 | require Method::Generate::DemolishAll; | ||||
157 | Method::Generate::DemolishAll->new->generate_method($into); | ||||
158 | } | ||||
159 | quote_sub | ||||
160 | "${into}::${name}" => $body, | ||||
161 | 8 | 81µs | 8 | 13.3ms | $self->{captures}, $quote_opts||{} # spent 13.3ms making 8 calls to Sub::Quote::quote_sub, avg 1.66ms/call |
162 | ; | ||||
163 | } | ||||
164 | |||||
165 | # spent 296µs (67+229) within Method::Generate::Constructor::_handle_subconstructor which was called 8 times, avg 37µs/call:
# 8 times (67µs+229µs) by Method::Generate::Constructor::generate_method at line 138, avg 37µs/call | ||||
166 | 8 | 16µs | my ($self, $into, $name) = @_; | ||
167 | 8 | 118µs | 8 | 229µs | if (my $gen = $self->{subconstructor_handler}) { # spent 229µs making 8 calls to Sub::Quote::quotify, avg 29µs/call |
168 | ' if ($class ne '.quotify($into).') {'."\n". | ||||
169 | $gen. | ||||
170 | ' }'."\n"; | ||||
171 | } else { | ||||
172 | '' | ||||
173 | } | ||||
174 | } | ||||
175 | |||||
176 | # spent 125µs within Method::Generate::Constructor::_cap_call which was called 55 times, avg 2µs/call:
# 55 times (125µs+0s) by Method::Generate::Constructor::_assign_new at line 223, avg 2µs/call | ||||
177 | 55 | 11µs | my ($self, $code, $captures) = @_; | ||
178 | 55 | 78µs | @{$self->{captures}}{keys %$captures} = values %$captures if $captures; | ||
179 | 55 | 77µs | $code; | ||
180 | } | ||||
181 | |||||
182 | # spent 4µs within Method::Generate::Constructor::_generate_args_via_buildargs which was called 2 times, avg 2µs/call:
# 2 times (4µs+0s) by Method::Generate::Constructor::generate_method at line 138, avg 2µs/call | ||||
183 | 2 | 2µs | my ($self) = @_; | ||
184 | 2 | 5µs | q{ my $args = $class->BUILDARGS(@_);}."\n" | ||
185 | .q{ Carp::croak("BUILDARGS did not return a hashref") unless CORE::ref($args) eq 'HASH';} | ||||
186 | ."\n"; | ||||
187 | } | ||||
188 | |||||
189 | # inlined from Moo::Object - update that first. | ||||
190 | # spent 17µs within Method::Generate::Constructor::_generate_args which was called 6 times, avg 3µs/call:
# 6 times (17µs+0s) by Method::Generate::Constructor::generate_method at line 138, avg 3µs/call | ||||
191 | 6 | 1µs | my ($self) = @_; | ||
192 | 6 | 13µs | return <<'_EOA'; | ||
193 | my $args = scalar @_ == 1 | ||||
194 | ? CORE::ref $_[0] eq 'HASH' | ||||
195 | ? { %{ $_[0] } } | ||||
196 | : Carp::croak("Single parameters to new() must be a HASH ref" | ||||
197 | . " data => ". $_[0]) | ||||
198 | : @_ % 2 | ||||
199 | ? Carp::croak("The new() method for $class expects a hash reference or a" | ||||
200 | . " key/value list. You passed an odd number of arguments") | ||||
201 | : {@_} | ||||
202 | ; | ||||
203 | _EOA | ||||
204 | |||||
205 | } | ||||
206 | |||||
207 | # spent 17.4ms (682µs+16.7) within Method::Generate::Constructor::_assign_new which was called 8 times, avg 2.18ms/call:
# 8 times (682µs+16.7ms) by Method::Generate::Constructor::generate_method at line 138, avg 2.18ms/call | ||||
208 | 8 | 2µs | my ($self, $spec) = @_; | ||
209 | 8 | 5µs | 8 | 2µs | my $ag = $self->accessor_generator; # spent 2µs making 8 calls to Method::Generate::Constructor::accessor_generator, avg 250ns/call |
210 | 8 | 1µs | my %test; | ||
211 | 8 | 26µs | 8 | 7µs | NAME: foreach my $name (sort keys %$spec) { # spent 7µs making 8 calls to Method::Generate::Constructor::CORE:sort, avg 875ns/call |
212 | 61 | 6µs | my $attr_spec = $spec->{$name}; | ||
213 | next NAME unless defined($attr_spec->{init_arg}) | ||||
214 | 61 | 24µs | 6 | 16µs | or $ag->has_eager_default($name, $attr_spec); # spent 16µs making 6 calls to Method::Generate::Accessor::has_eager_default, avg 3µs/call |
215 | 55 | 26µs | $test{$name} = $attr_spec->{init_arg}; | ||
216 | } | ||||
217 | join '', map { | ||||
218 | 63 | 193µs | 8 | 5µs | my $arg = $test{$_}; # spent 5µs making 8 calls to Method::Generate::Constructor::CORE:sort, avg 625ns/call |
219 | 55 | 82µs | 55 | 206µs | my $arg_key = quotify($arg); # spent 206µs making 55 calls to Sub::Quote::quotify, avg 4µs/call |
220 | 55 | 22µs | my $test = defined $arg ? "exists \$args->{$arg_key}" : undef; | ||
221 | 55 | 28µs | my $source = defined $arg ? "\$args->{$arg_key}" : undef; | ||
222 | 55 | 25µs | my $attr_spec = $spec->{$_}; | ||
223 | 55 | 129µs | 110 | 16.5ms | $self->_cap_call($ag->generate_populate_set( # spent 16.4ms making 55 calls to Method::Generate::Accessor::generate_populate_set, avg 297µs/call
# spent 125µs making 55 calls to Method::Generate::Constructor::_cap_call, avg 2µs/call |
224 | '$new', $_, $attr_spec, $source, $test, $arg, | ||||
225 | )); | ||||
226 | } sort keys %test; | ||||
227 | } | ||||
228 | |||||
229 | # spent 224µs (163+61) within Method::Generate::Constructor::_check_required which was called 8 times, avg 28µs/call:
# 8 times (163µs+61µs) by Method::Generate::Constructor::generate_method at line 138, avg 28µs/call | ||||
230 | 8 | 9µs | my ($self, $spec) = @_; | ||
231 | my @required_init = | ||||
232 | map $spec->{$_}{init_arg}, | ||||
233 | grep { | ||||
234 | 69 | 77µs | 8 | 22µs | my $s = $spec->{$_}; # ignore required if default or builder set # spent 22µs making 8 calls to Method::Generate::Constructor::CORE:sort, avg 3µs/call |
235 | $s->{required} and not($s->{builder} or exists $s->{default}) | ||||
236 | 61 | 61µs | } sort keys %$spec; | ||
237 | 8 | 7µs | return '' unless @required_init; | ||
238 | 5 | 22µs | 13 | 39µs | ' if (my @missing = grep !exists $args->{$_}, ' # spent 39µs making 13 calls to Sub::Quote::quotify, avg 3µs/call |
239 | .join(', ', map quotify($_), @required_init).') {'."\n" | ||||
240 | .q{ Carp::croak("Missing required arguments: ".CORE::join(', ', sort @missing));}."\n" | ||||
241 | ." }\n"; | ||||
242 | } | ||||
243 | |||||
244 | # bootstrap our own constructor | ||||
245 | sub new { | ||||
246 | 1 | 0s | my $class = shift; | ||
247 | 1 | 6µs | 1 | 2µs | delete _getstash(__PACKAGE__)->{new}; # spent 2µs making 1 call to Moo::_Utils::_getstash |
248 | 1 | 12µs | 1 | 3µs | bless $class->BUILDARGS(@_), $class; # spent 3µs making 1 call to Moo::Object::BUILDARGS |
249 | } | ||||
250 | 1 | 15µs | 2 | 39µs | Moo->_constructor_maker_for(__PACKAGE__) # spent 39µs making 1 call to Method::Generate::Constructor::register_attribute_specs
# spent 482µs making 1 call to Moo::_constructor_maker_for, recursion: max depth 1, sum of overlapping time 482µs |
251 | ->register_attribute_specs( | ||||
252 | attribute_specs => { | ||||
253 | is => 'ro', | ||||
254 | reader => 'all_attribute_specs', | ||||
255 | }, | ||||
256 | accessor_generator => { is => 'ro' }, | ||||
257 | construction_string => { is => 'lazy' }, | ||||
258 | construction_builder => { is => 'bare' }, | ||||
259 | subconstructor_handler => { is => 'ro' }, | ||||
260 | package => { is => 'bare' }, | ||||
261 | ); | ||||
262 | 1 | 1µs | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
263 | Moo::HandleMoose::inject_fake_metaclass_for(__PACKAGE__); | ||||
264 | } | ||||
265 | |||||
266 | 1 | 15µs | 1; | ||
# spent 34µs within Method::Generate::Constructor::CORE:sort which was called 24 times, avg 1µs/call:
# 8 times (22µs+0s) by Method::Generate::Constructor::_check_required at line 234, avg 3µs/call
# 8 times (7µs+0s) by Method::Generate::Constructor::_assign_new at line 211, avg 875ns/call
# 8 times (5µs+0s) by Method::Generate::Constructor::_assign_new at line 218, avg 625ns/call | |||||
# spent 51µs within Method::Generate::Constructor::CORE:subst which was called 63 times, avg 810ns/call:
# 63 times (51µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 24, avg 810ns/call |