Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Method/Generate/Constructor.pm |
Statements | Executed 2374 statements in 6.95ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
62 | 4 | 2 | 1.01ms | 2.15ms | register_attribute_specs | Method::Generate::Constructor::
3 | 1 | 1 | 990µs | 1.25ms | buildall_generator | Method::Generate::Constructor::
7 | 1 | 1 | 636µs | 18.9ms | _assign_new | Method::Generate::Constructor::
74 | 3 | 2 | 553µs | 1.10ms | assert_constructor | Method::Generate::Constructor::
7 | 1 | 1 | 444µs | 31.5ms | generate_method | Method::Generate::Constructor::
1 | 1 | 1 | 418µs | 434µs | BEGIN@10 | Method::Generate::Constructor::
74 | 1 | 1 | 357µs | 544µs | current_constructor | Method::Generate::Constructor::
10 | 1 | 1 | 284µs | 2.79ms | install_delayed | Method::Generate::Constructor::
7 | 1 | 1 | 172µs | 31.7ms | __ANON__[:101] | Method::Generate::Constructor::
7 | 1 | 1 | 129µs | 182µs | _check_required | Method::Generate::Constructor::
49 | 1 | 1 | 122µs | 122µs | _cap_call | Method::Generate::Constructor::
74 | 3 | 1 | 106µs | 106µs | accessor_generator | Method::Generate::Constructor::
6 | 1 | 1 | 99µs | 128µs | _build_construction_string | Method::Generate::Constructor::
7 | 1 | 1 | 53µs | 179µs | _handle_subconstructor | Method::Generate::Constructor::
63 | 1 | 1 | 49µs | 49µs | CORE:subst (opcode) | Method::Generate::Constructor::
8 | 2 | 2 | 35µs | 163µs | construction_string | Method::Generate::Constructor::
1 | 1 | 1 | 31µs | 35µs | BEGIN@2 | Method::Generate::Constructor::
21 | 3 | 1 | 30µs | 30µs | CORE:sort (opcode) | Method::Generate::Constructor::
1 | 1 | 1 | 10µs | 466µs | BEGIN@12 | Method::Generate::Constructor::
1 | 1 | 1 | 10µs | 47µs | BEGIN@6 | Method::Generate::Constructor::
5 | 1 | 1 | 9µs | 9µs | _generate_args | Method::Generate::Constructor::
1 | 1 | 1 | 8µs | 50µs | BEGIN@5 | Method::Generate::Constructor::
1 | 1 | 1 | 6µs | 40µs | BEGIN@3 | Method::Generate::Constructor::
1 | 1 | 1 | 6µs | 36µs | BEGIN@7 | Method::Generate::Constructor::
1 | 1 | 1 | 6µs | 18µs | BEGIN@9 | Method::Generate::Constructor::
1 | 1 | 1 | 5µs | 5µs | BEGIN@11 | Method::Generate::Constructor::
1 | 1 | 1 | 5µs | 20µs | BEGIN@8 | Method::Generate::Constructor::
3 | 2 | 1 | 4µs | 4µs | all_attribute_specs | Method::Generate::Constructor::
2 | 1 | 1 | 3µs | 3µs | _generate_args_via_buildargs | Method::Generate::Constructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Method::Generate::Constructor; | ||||
2 | 2 | 38µs | 2 | 39µs | # spent 35µs (31+4) within Method::Generate::Constructor::BEGIN@2 which was called:
# once (31µs+4µs) by Moo::_constructor_maker_for at line 2 # spent 35µs making 1 call to Method::Generate::Constructor::BEGIN@2
# spent 4µs making 1 call to strict::import |
3 | 2 | 31µs | 2 | 74µs | # spent 40µs (6+34) within Method::Generate::Constructor::BEGIN@3 which was called:
# once (6µs+34µs) by Moo::_constructor_maker_for at line 3 # spent 40µs making 1 call to Method::Generate::Constructor::BEGIN@3
# spent 34µs making 1 call to warnings::import |
4 | |||||
5 | 2 | 42µs | 2 | 92µs | # spent 50µs (8+42) within Method::Generate::Constructor::BEGIN@5 which was called:
# once (8µs+42µs) by Moo::_constructor_maker_for at line 5 # spent 50µs making 1 call to Method::Generate::Constructor::BEGIN@5
# spent 42µs making 1 call to Exporter::import |
6 | 2 | 31µs | 2 | 84µs | # spent 47µs (10+37) within Method::Generate::Constructor::BEGIN@6 which was called:
# once (10µs+37µs) by Moo::_constructor_maker_for at line 6 # spent 47µs making 1 call to Method::Generate::Constructor::BEGIN@6
# spent 37µs making 1 call to Exporter::import |
7 | 2 | 23µs | 2 | 66µs | # spent 36µs (6+30) within Method::Generate::Constructor::BEGIN@7 which was called:
# once (6µs+30µs) by Moo::_constructor_maker_for at line 7 # spent 36µs making 1 call to Method::Generate::Constructor::BEGIN@7
# spent 30µs making 1 call to Exporter::import |
8 | 2 | 21µs | 2 | 35µs | # spent 20µs (5+15) within Method::Generate::Constructor::BEGIN@8 which was called:
# once (5µs+15µs) by Moo::_constructor_maker_for at line 8 # spent 20µs making 1 call to Method::Generate::Constructor::BEGIN@8
# spent 15µs making 1 call to Exporter::import |
9 | 2 | 16µs | 2 | 30µs | # spent 18µs (6+12) within Method::Generate::Constructor::BEGIN@9 which was called:
# once (6µs+12µs) by Moo::_constructor_maker_for at line 9 # spent 18µs making 1 call to Method::Generate::Constructor::BEGIN@9
# spent 12µs making 1 call to Exporter::import |
10 | 2 | 293µs | 1 | 434µs | # spent 434µs (418+16) within Method::Generate::Constructor::BEGIN@10 which was called:
# once (418µs+16µs) by Moo::_constructor_maker_for at line 10 # spent 434µs making 1 call to Method::Generate::Constructor::BEGIN@10 |
11 | 1 | 42µs | 1 | 5µs | # spent 5µs within Method::Generate::Constructor::BEGIN@11 which was called:
# once (5µs+0s) by Moo::_constructor_maker_for at line 11 # spent 5µs making 1 call to Method::Generate::Constructor::BEGIN@11 |
12 | # spent 466µs (10+456) within Method::Generate::Constructor::BEGIN@12 which was called:
# once (10µs+456µ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 | 10µs | 1 | 456µs | Moo->import; # spent 456µs making 1 call to Moo::import |
16 | 1 | 1.66ms | 1 | 466µs | } # spent 466µs making 1 call to Method::Generate::Constructor::BEGIN@12 |
17 | |||||
18 | # spent 2.15ms (1.01+1.14) within Method::Generate::Constructor::register_attribute_specs which was called 62 times, avg 35µs/call:
# 49 times (824µs+917µs) by Moo::has at line 119 of Moo.pm, avg 36µs/call
# 10 times (149µs+161µs) by Moo::_constructor_maker_for at line 262 of Moo.pm, avg 31µs/call
# 2 times (12µs+52µs) by Moo::_set_superclasses at line 158 of Moo.pm, avg 32µs/call
# once (28µs+9µs) by Moo::_constructor_maker_for at line 250 | ||||
19 | 62 | 61µs | my ($self, @new_specs) = @_; | ||
20 | 62 | 91µs | 62 | 935µs | $self->assert_constructor; # spent 935µs making 62 calls to Method::Generate::Constructor::assert_constructor, avg 15µs/call |
21 | 62 | 42µs | my $specs = $self->{attribute_specs}||={}; | ||
22 | 62 | 94µs | 62 | 92µs | my $ag = $self->accessor_generator; # spent 92µs making 62 calls to Method::Generate::Constructor::accessor_generator, avg 1µs/call |
23 | 62 | 178µs | while (my ($name, $new_spec) = splice @new_specs, 0, 2) { | ||
24 | 63 | 156µs | 63 | 49µs | if ($name =~ s/^\+//) { # spent 49µs making 63 calls to Method::Generate::Constructor::CORE:subst, avg 778ns/call |
25 | croak "has '+${name}' given but no ${name} attribute already exists" | ||||
26 | 2 | 2µs | unless my $old_spec = $specs->{$name}; | ||
27 | 2 | 9µs | 2 | 33µs | $ag->merge_specs($new_spec, $old_spec); # spent 33µs making 2 calls to Method::Generate::Accessor::merge_specs, avg 16µs/call |
28 | } | ||||
29 | 63 | 51µs | 13 | 30µs | if ($new_spec->{required} # spent 30µs making 13 calls to Method::Generate::Accessor::has_default, avg 2µ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 | 86µs | unless defined $new_spec->{index}; | ||
41 | 63 | 62µs | $specs->{$name} = $new_spec; | ||
42 | } | ||||
43 | 62 | 127µ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 (2µs+0s) by Moo::_set_superclasses at line 158 of Moo.pm, avg 1µs/call
# once (2µs+0s) by Moo::_constructor_maker_for at line 262 of Moo.pm | ||||
47 | $_[0]->{attribute_specs} | ||||
48 | 3 | 8µs | } | ||
49 | |||||
50 | # spent 106µs within Method::Generate::Constructor::accessor_generator which was called 74 times, avg 1µs/call:
# 62 times (92µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 22, avg 1µs/call
# 7 times (5µs+0s) by Method::Generate::Constructor::_assign_new at line 209, avg 714ns/call
# 5 times (9µs+0s) by Method::Generate::Constructor::_build_construction_string at line 68, avg 2µs/call | ||||
51 | $_[0]->{accessor_generator} | ||||
52 | 74 | 243µs | } | ||
53 | |||||
54 | # spent 163µs (35+128) within Method::Generate::Constructor::construction_string which was called 8 times, avg 20µs/call:
# 7 times (30µs+112µs) by Method::Generate::Constructor::generate_method at line 138, avg 20µs/call
# once (5µs+16µs) by Moo::_constructor_maker_for at line 237 of Moo.pm | ||||
55 | 8 | 3µs | my ($self) = @_; | ||
56 | $self->{construction_string} | ||||
57 | 8 | 32µs | 6 | 128µs | ||= $self->_build_construction_string; # spent 128µs making 6 calls to Method::Generate::Constructor::_build_construction_string, avg 21µs/call |
58 | } | ||||
59 | |||||
60 | # spent 1.25ms (990µs+257µs) within Method::Generate::Constructor::buildall_generator which was called 3 times, avg 416µs/call:
# 3 times (990µs+257µs) by Method::Generate::Constructor::generate_method at line 138, avg 416µs/call | ||||
61 | 3 | 600µs | require Method::Generate::BuildAll; | ||
62 | 3 | 35µs | 3 | 53µs | Method::Generate::BuildAll->new; # spent 53µs making 3 calls to Moo::Object::new, avg 18µs/call |
63 | } | ||||
64 | |||||
65 | # spent 128µs (99+29) within Method::Generate::Constructor::_build_construction_string which was called 6 times, avg 21µs/call:
# 6 times (99µs+29µs) by Method::Generate::Constructor::construction_string at line 57, avg 21µs/call | ||||
66 | 6 | 4µs | my ($self) = @_; | ||
67 | 6 | 2µs | my $builder = $self->{construction_builder}; | ||
68 | 6 | 46µs | 11 | 29µs | $builder ? $self->$builder # spent 10µs making 5 calls to Method::Generate::Accessor::default_construction_string, avg 2µs/call
# spent 10µs making 1 call to Moo::__ANON__[Moo.pm:256]
# spent 9µs making 5 calls to Method::Generate::Constructor::accessor_generator, avg 2µs/call |
69 | : 'bless(' | ||||
70 | .$self->accessor_generator->default_construction_string | ||||
71 | .', $class);' | ||||
72 | } | ||||
73 | |||||
74 | # spent 2.79ms (284µs+2.50) within Method::Generate::Constructor::install_delayed which was called 10 times, avg 278µs/call:
# 10 times (284µs+2.50ms) by Moo::_constructor_maker_for at line 262 of Moo.pm, avg 278µs/call | ||||
75 | 10 | 2µs | my ($self) = @_; | ||
76 | 10 | 22µs | 10 | 143µs | $self->assert_constructor; # spent 143µs making 10 calls to Method::Generate::Constructor::assert_constructor, avg 14µs/call |
77 | 10 | 6µs | my $package = $self->{package}; | ||
78 | 10 | 62µs | 10 | 36µs | my (undef, @isa) = @{_linear_isa($package)}; # spent 36µs making 10 calls to mro::get_linear_isa, avg 4µs/call |
79 | 10 | 14µs | my $isa = join ',', @isa; | ||
80 | 10 | 66µs | 10 | 1.70ms | my (undef, $from_file, $from_line) = caller(Carp::short_error_loc()); # spent 1.70ms making 10 calls to Carp::short_error_loc, avg 170µs/call |
81 | # spent 31.7ms (172µs+31.6) within Method::Generate::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Method/Generate/Constructor.pm:101] which was called 7 times, avg 4.53ms/call:
# 7 times (172µs+31.6ms) by Sub::Defer::undefer_sub at line 85 of Sub/Defer.pm, avg 4.53ms/call | ||||
82 | 7 | 58µs | 7 | 21µs | my (undef, @new_isa) = @{_linear_isa($package)}; # spent 21µs making 7 calls to mro::get_linear_isa, avg 3µs/call |
83 | 7 | 12µ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 | 7 | 61µs | 7 | 31.5ms | $package, 'new', $self->{attribute_specs}, { no_install => 1, no_defer => 1 } # spent 31.5ms making 7 calls to Method::Generate::Constructor::generate_method, avg 4.51ms/call |
97 | ); | ||||
98 | 7 | 12µs | $self->{inlined} = 1; | ||
99 | 7 | 27µs | 7 | 6µs | weaken($self->{constructor} = $constructor); # spent 6µs making 7 calls to Scalar::Util::weaken, avg 857ns/call |
100 | 7 | 19µs | $constructor; | ||
101 | 10 | 71µs | 10 | 607µs | }; # spent 607µs making 10 calls to Sub::Defer::defer_sub, avg 61µs/call |
102 | 10 | 11µs | $self->{inlined} = 0; | ||
103 | 10 | 25µs | 10 | 10µs | weaken($self->{constructor} = $constructor); # spent 10µs making 10 calls to Scalar::Util::weaken, avg 1µs/call |
104 | 10 | 52µs | $self; | ||
105 | } | ||||
106 | |||||
107 | # spent 544µs (357+187) within Method::Generate::Constructor::current_constructor which was called 74 times, avg 7µs/call:
# 74 times (357µs+187µs) by Method::Generate::Constructor::assert_constructor at line 115, avg 7µs/call | ||||
108 | 74 | 32µs | my ($self, $package) = @_; | ||
109 | 74 | 397µs | 74 | 187µs | return *{_getglob("${package}::new")}{CODE}; # spent 187µs making 74 calls to Moo::_Utils::_getglob, avg 3µs/call |
110 | } | ||||
111 | |||||
112 | # spent 1.10ms (553µs+544µs) within Method::Generate::Constructor::assert_constructor which was called 74 times, avg 15µs/call:
# 62 times (484µs+451µs) by Method::Generate::Constructor::register_attribute_specs at line 20, avg 15µs/call
# 10 times (60µs+83µs) by Method::Generate::Constructor::install_delayed at line 76, avg 14µs/call
# 2 times (9µs+10µs) by Moo::_set_superclasses at line 155 of Moo.pm, avg 10µs/call | ||||
113 | 74 | 23µs | my ($self) = @_; | ||
114 | 74 | 56µs | my $package = $self->{package} or return 1; | ||
115 | 74 | 134µs | 74 | 544µs | my $current = $self->current_constructor($package) # spent 544µ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 | 29µs | or croak "Unknown constructor for $package already exists"; | ||
119 | 64 | 40µ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 | 152µs | if $self->{inlined}; | ||
123 | } | ||||
124 | |||||
125 | # spent 31.5ms (444µs+31.1) within Method::Generate::Constructor::generate_method which was called 7 times, avg 4.51ms/call:
# 7 times (444µs+31.1ms) by Method::Generate::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Method/Generate/Constructor.pm:101] at line 96, avg 4.51ms/call | ||||
126 | 7 | 8µs | my ($self, $into, $name, $spec, $quote_opts) = @_; | ||
127 | $quote_opts = { | ||||
128 | 7 | 18µs | %{$quote_opts||{}}, | ||
129 | package => $into, | ||||
130 | }; | ||||
131 | 7 | 103µs | foreach my $no_init (grep !exists($spec->{$_}{init_arg}), keys %$spec) { | ||
132 | 45 | 29µs | $spec->{$no_init}{init_arg} = $no_init; | ||
133 | } | ||||
134 | 7 | 11µs | local $self->{captures} = {}; | ||
135 | |||||
136 | 7 | 67µs | 7 | 28µs | my $into_buildargs = $into->can('BUILDARGS'); # spent 28µs making 7 calls to UNIVERSAL::can, avg 4µs/call |
137 | |||||
138 | 7 | 153µs | 48 | 20.8ms | my $body # spent 18.9ms making 7 calls to Method::Generate::Constructor::_assign_new, avg 2.70ms/call
# spent 1.25ms making 3 calls to Method::Generate::Constructor::buildall_generator, avg 416µs/call
# spent 182µs making 7 calls to Method::Generate::Constructor::_check_required, avg 26µs/call
# spent 179µs making 7 calls to Method::Generate::Constructor::_handle_subconstructor, avg 26µs/call
# spent 142µs making 7 calls to Method::Generate::Constructor::construction_string, avg 20µs/call
# spent 98µs making 3 calls to Method::Generate::BuildAll::buildall_body_for, avg 33µs/call
# spent 32µs making 7 calls to UNIVERSAL::can, avg 5µs/call
# spent 9µs making 5 calls to Method::Generate::Constructor::_generate_args, avg 2µs/call
# spent 3µ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 | 7 | 27µs | 7 | 13µs | if ($into->can('DEMOLISH')) { # spent 13µs making 7 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 | 7 | 51µs | 7 | 10.3ms | $self->{captures}, $quote_opts||{} # spent 10.3ms making 7 calls to Sub::Quote::quote_sub, avg 1.47ms/call |
162 | ; | ||||
163 | } | ||||
164 | |||||
165 | # spent 179µs (53+126) within Method::Generate::Constructor::_handle_subconstructor which was called 7 times, avg 26µs/call:
# 7 times (53µs+126µs) by Method::Generate::Constructor::generate_method at line 138, avg 26µs/call | ||||
166 | 7 | 5µs | my ($self, $into, $name) = @_; | ||
167 | 7 | 84µs | 7 | 126µs | if (my $gen = $self->{subconstructor_handler}) { # spent 126µs making 7 calls to Sub::Quote::quotify, avg 18µs/call |
168 | ' if ($class ne '.quotify($into).') {'."\n". | ||||
169 | $gen. | ||||
170 | ' }'."\n"; | ||||
171 | } else { | ||||
172 | '' | ||||
173 | } | ||||
174 | } | ||||
175 | |||||
176 | # spent 122µs within Method::Generate::Constructor::_cap_call which was called 49 times, avg 2µs/call:
# 49 times (122µs+0s) by Method::Generate::Constructor::_assign_new at line 223, avg 2µs/call | ||||
177 | 49 | 21µs | my ($self, $code, $captures) = @_; | ||
178 | 49 | 80µs | @{$self->{captures}}{keys %$captures} = values %$captures if $captures; | ||
179 | 49 | 62µs | $code; | ||
180 | } | ||||
181 | |||||
182 | # spent 3µs within Method::Generate::Constructor::_generate_args_via_buildargs which was called 2 times, avg 2µs/call:
# 2 times (3µs+0s) by Method::Generate::Constructor::generate_method at line 138, avg 2µs/call | ||||
183 | 2 | 1µs | my ($self) = @_; | ||
184 | 2 | 6µ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 9µs within Method::Generate::Constructor::_generate_args which was called 5 times, avg 2µs/call:
# 5 times (9µs+0s) by Method::Generate::Constructor::generate_method at line 138, avg 2µs/call | ||||
191 | 5 | 3µs | my ($self) = @_; | ||
192 | 5 | 9µ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 18.9ms (636µs+18.2) within Method::Generate::Constructor::_assign_new which was called 7 times, avg 2.70ms/call:
# 7 times (636µs+18.2ms) by Method::Generate::Constructor::generate_method at line 138, avg 2.70ms/call | ||||
208 | 7 | 1µs | my ($self, $spec) = @_; | ||
209 | 7 | 7µs | 7 | 5µs | my $ag = $self->accessor_generator; # spent 5µs making 7 calls to Method::Generate::Constructor::accessor_generator, avg 714ns/call |
210 | 7 | 2µs | my %test; | ||
211 | 7 | 25µs | 7 | 6µs | NAME: foreach my $name (sort keys %$spec) { # spent 6µs making 7 calls to Method::Generate::Constructor::CORE:sort, avg 857ns/call |
212 | 55 | 7µs | my $attr_spec = $spec->{$name}; | ||
213 | next NAME unless defined($attr_spec->{init_arg}) | ||||
214 | 55 | 42µs | 6 | 7µs | or $ag->has_eager_default($name, $attr_spec); # spent 7µs making 6 calls to Method::Generate::Accessor::has_eager_default, avg 1µs/call |
215 | 49 | 28µs | $test{$name} = $attr_spec->{init_arg}; | ||
216 | } | ||||
217 | join '', map { | ||||
218 | 56 | 160µs | 7 | 4µs | my $arg = $test{$_}; # spent 4µs making 7 calls to Method::Generate::Constructor::CORE:sort, avg 571ns/call |
219 | 49 | 38µs | 49 | 200µs | my $arg_key = quotify($arg); # spent 200µs making 49 calls to Sub::Quote::quotify, avg 4µs/call |
220 | 49 | 22µs | my $test = defined $arg ? "exists \$args->{$arg_key}" : undef; | ||
221 | 49 | 13µs | my $source = defined $arg ? "\$args->{$arg_key}" : undef; | ||
222 | 49 | 23µs | my $attr_spec = $spec->{$_}; | ||
223 | 49 | 142µs | 98 | 18.0ms | $self->_cap_call($ag->generate_populate_set( # spent 17.9ms making 49 calls to Method::Generate::Accessor::generate_populate_set, avg 365µs/call
# spent 122µs making 49 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 182µs (129+53) within Method::Generate::Constructor::_check_required which was called 7 times, avg 26µs/call:
# 7 times (129µs+53µs) by Method::Generate::Constructor::generate_method at line 138, avg 26µs/call | ||||
230 | 7 | 3µs | my ($self, $spec) = @_; | ||
231 | my @required_init = | ||||
232 | map $spec->{$_}{init_arg}, | ||||
233 | grep { | ||||
234 | 62 | 72µs | 7 | 20µs | my $s = $spec->{$_}; # ignore required if default or builder set # spent 20µs making 7 calls to Method::Generate::Constructor::CORE:sort, avg 3µs/call |
235 | $s->{required} and not($s->{builder} or exists $s->{default}) | ||||
236 | 55 | 15µs | } sort keys %$spec; | ||
237 | 7 | 8µs | return '' unless @required_init; | ||
238 | 4 | 45µs | 9 | 33µs | ' if (my @missing = grep !exists $args->{$_}, ' # spent 33µs making 9 calls to Sub::Quote::quotify, avg 4µ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 | 9µs | 1 | 2µs | bless $class->BUILDARGS(@_), $class; # spent 2µs making 1 call to Moo::Object::BUILDARGS |
249 | } | ||||
250 | 1 | 15µs | 2 | 37µs | Moo->_constructor_maker_for(__PACKAGE__) # spent 37µs making 1 call to Method::Generate::Constructor::register_attribute_specs
# spent 433µs making 1 call to Moo::_constructor_maker_for, recursion: max depth 1, sum of overlapping time 433µ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 | 0s | if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) { | ||
263 | Moo::HandleMoose::inject_fake_metaclass_for(__PACKAGE__); | ||||
264 | } | ||||
265 | |||||
266 | 1 | 10µs | 1; | ||
# spent 30µs within Method::Generate::Constructor::CORE:sort which was called 21 times, avg 1µs/call:
# 7 times (20µs+0s) by Method::Generate::Constructor::_check_required at line 234, avg 3µs/call
# 7 times (6µs+0s) by Method::Generate::Constructor::_assign_new at line 211, avg 857ns/call
# 7 times (4µs+0s) by Method::Generate::Constructor::_assign_new at line 218, avg 571ns/call | |||||
# spent 49µs within Method::Generate::Constructor::CORE:subst which was called 63 times, avg 778ns/call:
# 63 times (49µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 24, avg 778ns/call |