← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 16:10:05 2022
Reported on Wed Dec 14 16:12:56 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Moo.pm
StatementsExecuted 2129 statements in 8.47ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
116436.24ms14.0msMoo::::_accessor_maker_forMoo::_accessor_maker_for
1112.88ms11.8msMoo::::BEGIN@6Moo::BEGIN@6
99432.75ms8.71msMoo::::_constructor_maker_forMoo::_constructor_maker_for (recurses: max depth 1, inclusive time 433µs)
17111.66ms1.79msMoo::::make_classMoo::make_class
45661.02ms88.9msMoo::::hasMoo::has
171717405µs5.34msMoo::::importMoo::import
1711372µs2.49msMoo::::_install_subsMoo::_install_subs
1711242µs242µsMoo::::_gen_subsMoo::_gen_subs
6031142µs142µsMoo::::_maybe_reset_handlemooseMoo::_maybe_reset_handlemoose
211132µs2.61msMoo::::_set_superclassesMoo::_set_superclasses
99993µs8.98msMoo::::withMoo::with
171150µs50µsMoo::::CORE:sortMoo::CORE:sort (opcode)
2921142µs42µsMoo::::CORE:matchMoo::CORE:match (opcode)
66432µs1.52msMoo::::aroundMoo::around
71122µs22µsMoo::::is_classMoo::is_class
11121µs23µsMoo::::BEGIN@2Moo::BEGIN@2
22219µs2.63msMoo::::extendsMoo::extends
11110µs28µsMoo::::BEGIN@70Moo::BEGIN@70
1119µs14µsMoo::::BEGIN@180Moo::BEGIN@180
2219µs351µsMoo::::beforeMoo::before
1117µs10µsMoo::::__ANON__[:256]Moo::__ANON__[:256]
1116µs19µsMoo::::BEGIN@18Moo::BEGIN@18
1116µs9µsMoo::::BEGIN@230Moo::BEGIN@230
1114µs7µsMoo::::BEGIN@275Moo::BEGIN@275
1113µs20µsMoo::::BEGIN@3Moo::BEGIN@3
1113µs14µsMoo::::BEGIN@4Moo::BEGIN@4
1112µs2µsMoo::::BEGIN@19Moo::BEGIN@19
0000s0sMoo::::__ANON__[:101]Moo::__ANON__[:101]
0000s0sMoo::::__ANON__[:106]Moo::__ANON__[:106]
0000s0sMoo::::__ANON__[:126]Moo::__ANON__[:126]
0000s0sMoo::::__ANON__[:133]Moo::__ANON__[:133]
0000s0sMoo::::__ANON__[:248]Moo::__ANON__[:248]
0000s0sMoo::::_concrete_methods_ofMoo::_concrete_methods_of
0000s0sMoo::::afterMoo::after
0000s0sMoo::::unimportMoo::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moo;
2224µs225µs
# spent 23µs (21+2) within Moo::BEGIN@2 which was called: # once (21µs+2µs) by OpenAPI::Modern::BEGIN@11 at line 2
use strict;
# spent 23µs making 1 call to Moo::BEGIN@2 # spent 2µs making 1 call to strict::import
3214µs237µs
# spent 20µs (3+17) within Moo::BEGIN@3 which was called: # once (3µs+17µs) by OpenAPI::Modern::BEGIN@11 at line 3
use warnings;
# spent 20µs making 1 call to Moo::BEGIN@3 # spent 17µs making 1 call to warnings::import
4227µs225µs
# spent 14µs (3+11) within Moo::BEGIN@4 which was called: # once (3µs+11µs) by OpenAPI::Modern::BEGIN@11 at line 4
no warnings 'once';
# spent 14µs making 1 call to Moo::BEGIN@4 # spent 11µs making 1 call to warnings::unimport
5
61473µs
# spent 11.8ms (2.88+8.94) within Moo::BEGIN@6 which was called: # once (2.88ms+8.94ms) by OpenAPI::Modern::BEGIN@11 at line 17
use Moo::_Utils qw(
7 _check_tracked
8 _getglob
9 _getstash
10 _install_coderef
11 _install_modifier
12 _install_tracked
13 _linear_isa
14 _load_module
15 _set_loaded
16 _unimport_coderefs
17130µs211.9ms);
# spent 11.8ms making 1 call to Moo::BEGIN@6 # spent 72µs making 1 call to Exporter::import
18229µs232µs
# spent 19µs (6+13) within Moo::BEGIN@18 which was called: # once (6µs+13µs) by OpenAPI::Modern::BEGIN@11 at line 18
use Carp qw(croak);
# spent 19µs making 1 call to Moo::BEGIN@18 # spent 13µs making 1 call to Exporter::import
19
# spent 2µs within Moo::BEGIN@19 which was called: # once (2µs+0s) by OpenAPI::Modern::BEGIN@11 at line 27
BEGIN {
2013µs our @CARP_NOT = qw(
21 Method::Generate::Constructor
22 Method::Generate::Accessor
23 Moo::sification
24 Moo::_Utils
25 Moo::Role
26 );
271176µs12µs}
# spent 2µs making 1 call to Moo::BEGIN@19
28
2911µsour $VERSION = '2.005004';
3011µs$VERSION =~ tr/_//d;
31
321530µsrequire Moo::sification;
3313µs14µsMoo::sification->import;
# spent 4µs making 1 call to Moo::sification::import
34
35our %MAKERS;
36
37
# spent 5.34ms (405µs+4.94) within Moo::import which was called 17 times, avg 314µs/call: # once (19µs+1.20ms) by OpenAPI::Modern::BEGIN@11 at line 11 of OpenAPI/Modern.pm # once (94µs+415µs) by JSON::Schema::Modern::Vocabulary::MetaData::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/MetaData.pm # once (26µs+430µs) by Method::Generate::Constructor::BEGIN@12 at line 15 of Method/Generate/Constructor.pm # once (28µs+351µs) by JSON::Schema::Modern::Error::BEGIN@10 at line 10 of JSON/Schema/Modern/Error.pm # once (24µs+278µs) by JSON::Schema::Modern::Vocabulary::Validation::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/Validation.pm # once (20µs+241µs) by JSON::Schema::Modern::BEGIN@11 at line 11 of JSON/Schema/Modern.pm # once (21µs+237µs) by JSON::Schema::Modern::Document::OpenAPI::BEGIN@11 at line 11 of JSON/Schema/Modern/Document/OpenAPI.pm # once (17µs+220µs) by JSON::Schema::Modern::Result::BEGIN@10 at line 10 of JSON/Schema/Modern/Result.pm # once (13µs+194µs) by JSON::Schema::Modern::Vocabulary::FormatAssertion::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (14µs+192µs) by JSON::Schema::Modern::Annotation::BEGIN@10 at line 10 of JSON/Schema/Modern/Annotation.pm # once (19µs+186µs) by JSON::Schema::Modern::Vocabulary::Unevaluated::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm # once (19µs+173µs) by JSON::Schema::Modern::Vocabulary::Core::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/Core.pm # once (19µs+170µs) by JSON::Schema::Modern::Document::BEGIN@10 at line 10 of JSON/Schema/Modern/Document.pm # once (16µs+168µs) by JSON::Schema::Modern::Vocabulary::Content::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/Content.pm # once (19µs+164µs) by JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/OpenAPI.pm # once (17µs+159µs) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm # once (20µs+156µs) by JSON::Schema::Modern::Vocabulary::Applicator::BEGIN@10 at line 10 of JSON/Schema/Modern/Vocabulary/Applicator.pm
sub import {
381715µs my $target = caller;
39175µs my $class = shift;
401771µs1538µs if ($INC{'Role/Tiny.pm'} and Role::Tiny->is_role($target)) {
# spent 38µs making 15 calls to Role::Tiny::is_role, avg 3µs/call
41 croak "Cannot import Moo into a role";
42 }
43
441759µs17181µs _set_loaded(caller);
# spent 181µs making 17 calls to Moo::_Utils::_set_loaded, avg 11µs/call
45
461768µs1731µs strict->import;
# spent 31µs making 17 calls to strict::import, avg 2µs/call
471721µs17396µs warnings->import;
# spent 396µs making 17 calls to warnings::import, avg 23µs/call
48
491738µs172.49ms $class->_install_subs($target, @_);
# spent 2.49ms making 17 calls to Moo::_install_subs, avg 147µs/call
501726µs171.79ms $class->make_class($target);
# spent 1.79ms making 17 calls to Moo::make_class, avg 106µs/call
511760µs return;
52}
53
54
# spent 1.79ms (1.66+137µs) within Moo::make_class which was called 17 times, avg 106µs/call: # 17 times (1.66ms+137µs) by Moo::import at line 50, avg 106µs/call
sub make_class {
55176µs my ($me, $target) = @_;
56
571724µs my $makers = $MAKERS{$target} ||= {};
58174µs return $target if $makers->{is_class};
59
601723µs1730µs my $stash = _getstash($target);
# spent 30µs making 17 calls to Moo::_Utils::_getstash, avg 2µs/call
61 $makers->{non_methods} = {
62 map +($_ => \&{"${target}::${_}"}),
6317547µs29242µs grep exists &{"${target}::${_}"},
# spent 42µs making 292 calls to Moo::CORE:match, avg 144ns/call
64 grep !/::\z/ && !/\A\(/,
65 keys %$stash
66 };
67
68178µs $makers->{is_class} = 1;
69 {
7019617µs246µs
# spent 28µs (10+18) within Moo::BEGIN@70 which was called: # once (10µs+18µs) by OpenAPI::Modern::BEGIN@11 at line 70
no strict 'refs';
# spent 28µs making 1 call to Moo::BEGIN@70 # spent 18µs making 1 call to strict::unimport
71 @{"${target}::ISA"} = do {
7234472µs require Moo::Object; ('Moo::Object');
7317183µs } unless @{"${target}::ISA"};
74 }
75178µs if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) {
76 Moo::HandleMoose::inject_fake_metaclass_for($target);
77 }
781740µs return $target;
79}
80
81
# spent 22µs within Moo::is_class which was called 7 times, avg 3µs/call: # 7 times (22µs+0s) by MooX::TypeTiny::import at line 14 of MooX/TypeTiny.pm, avg 3µs/call
sub is_class {
8274µs my ($me, $class) = @_;
83734µs return $MAKERS{$class} && $MAKERS{$class}{is_class};
84}
85
86
# spent 2.49ms (372µs+2.12) within Moo::_install_subs which was called 17 times, avg 147µs/call: # 17 times (372µs+2.12ms) by Moo::import at line 49, avg 147µs/call
sub _install_subs {
871710µs my ($me, $target) = @_;
881768µs17242µs my %install = $me->_gen_subs($target);
# spent 242µs making 17 calls to Moo::_gen_subs, avg 14µs/call
89 _install_tracked $target => $_ => $install{$_}
9017210µs1191.88ms for sort keys %install;
# spent 1.83ms making 102 calls to Moo::_Utils::_install_tracked, avg 18µs/call # spent 50µs making 17 calls to Moo::CORE:sort, avg 3µs/call
911742µs return;
92}
93
94
# spent 242µs within Moo::_gen_subs which was called 17 times, avg 14µs/call: # 17 times (242µs+0s) by Moo::_install_subs at line 88, avg 14µs/call
sub _gen_subs {
95179µs my ($me, $target) = @_;
96 return (
97
# spent 2.63ms (19µs+2.61) within Moo::extends which was called 2 times, avg 1.31ms/call: # once (9µs+2.01ms) by JSON::Schema::Modern::Document::extends at line 6 of (eval 262)[Class/Method/Modifiers.pm:148] # once (10µs+598µs) by JSON::Schema::Modern::Document::OpenAPI::extends at line 6 of (eval 386)[Class/Method/Modifiers.pm:148]
extends => sub {
9825µs22.61ms $me->_set_superclasses($target, @_);
# spent 2.61ms making 2 calls to Moo::_set_superclasses, avg 1.30ms/call
9924µs24µs $me->_maybe_reset_handlemoose($target);
# spent 4µs making 2 calls to Moo::_maybe_reset_handlemoose, avg 2µs/call
10025µs return;
101 },
102
# spent 8.98ms (93µs+8.89) within Moo::with which was called 9 times, avg 998µs/call: # once (11µs+5.46ms) by Module::Runtime::require_module at line 20 of JSON/Schema/Modern/Vocabulary/Core.pm # once (21µs+667µs) by Module::Runtime::require_module at line 24 of JSON/Schema/Modern/Vocabulary/Applicator.pm # once (15µs+625µs) by Module::Runtime::require_module at line 23 of JSON/Schema/Modern/Vocabulary/Validation.pm # once (10µs+485µs) by JSON::Schema::Modern::Vocabulary::Applicator::BEGIN@21 at line 21 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm # once (9µs+387µs) by Module::Runtime::require_module at line 21 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (7µs+352µs) by Module::Runtime::require_module at line 22 of JSON/Schema/Modern/Vocabulary/Content.pm # once (7µs+330µs) by Module::Runtime::require_module at line 20 of JSON/Schema/Modern/Vocabulary/MetaData.pm # once (5µs+296µs) by Module::Runtime::require_module at line 21 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm # once (8µs+291µs) by Module::Runtime::require_module at line 20 of JSON/Schema/Modern/Vocabulary/OpenAPI.pm
with => sub {
103910µs require Moo::Role;
104939µs98.87ms Moo::Role->apply_roles_to_package($target, @_);
# spent 8.87ms making 9 calls to Role::Tiny::apply_roles_to_package, avg 986µs/call
105940µs917µs $me->_maybe_reset_handlemoose($target);
# spent 17µs making 9 calls to Moo::_maybe_reset_handlemoose, avg 2µs/call
106 },
107
# spent 88.9ms (1.02+87.9) within Moo::has which was called 45 times, avg 1.98ms/call: # 16 times (346µs+39.7ms) by JSON::Schema::Modern::has at line 6 of (eval 33)[Class/Method/Modifiers.pm:148], avg 2.50ms/call # 8 times (188µs+21.8ms) by JSON::Schema::Modern::Document::has at line 6 of (eval 260)[Class/Method/Modifiers.pm:148], avg 2.75ms/call # 6 times (152µs+9.63ms) by JSON::Schema::Modern::Result::has at line 6 of (eval 219)[Class/Method/Modifiers.pm:148], avg 1.63ms/call # 6 times (131µs+9.60ms) by MooX::HandlesVia::has at line 31 of MooX/HandlesVia.pm, avg 1.62ms/call # 5 times (134µs+4.57ms) by JSON::Schema::Modern::Error::has at line 6 of (eval 192)[Class/Method/Modifiers.pm:148], avg 940µs/call # 4 times (68µs+2.62ms) by JSON::Schema::Modern::Annotation::has at line 6 of (eval 225)[Class/Method/Modifiers.pm:148], avg 673µs/call
has => sub {
1084516µs my $name_proto = shift;
1094554µs my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto;
1104548µs if (@_ % 2 != 0) {
111 croak "Invalid options for " . join(', ', map "'$_'", @name_proto)
112 . " attribute(s): even number of arguments expected, got " . scalar @_;
113 }
1144568µs my %spec = @_;
1154529µs foreach my $name (@name_proto) {
116 # Note that when multiple attributes specified, each attribute
117 # needs a separate \%specs hashref
1184946µs my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec;
11949134µs981.80ms $me->_constructor_maker_for($target)
# spent 1.74ms making 49 calls to Method::Generate::Constructor::register_attribute_specs, avg 36µs/call # spent 63µs making 49 calls to Moo::_constructor_maker_for, avg 1µs/call
120 ->register_attribute_specs($name, $spec_ref);
12149200µs9886.0ms $me->_accessor_maker_for($target)
# spent 85.9ms making 49 calls to Method::Generate::Accessor::generate_method, avg 1.75ms/call # spent 81µs making 49 calls to Moo::_accessor_maker_for, avg 2µs/call
122 ->generate_method($target, $name, $spec_ref);
12349150µs49121µs $me->_maybe_reset_handlemoose($target);
# spent 121µs making 49 calls to Moo::_maybe_reset_handlemoose, avg 2µs/call
124 }
12545161µs return;
126 },
127 (map {
12868197µs my $type = $_;
129 (
130
# spent 351µs (9+342) within Moo::before which was called 2 times, avg 176µs/call: # once (4µs+196µs) by OpenAPI::Modern::BEGIN@26 at line 938 of JSON/Schema/Modern.pm # once (5µs+146µs) by OpenAPI::Modern::BEGIN@26 at line 124 of JSON/Schema/Modern.pm # spent 1.52ms (32µs+1.48) within Moo::around which was called 6 times, avg 252µs/call: # once (5µs+328µs) by main::BEGIN@2 at line 79 of OpenAPI/Modern.pm # once (7µs+323µs) by OpenAPI::Modern::BEGIN@26 at line 936 of JSON/Schema/Modern.pm # once (7µs+256µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 62 of JSON/Schema/Modern/Annotation.pm # once (5µs+226µs) by JSON::Schema::Modern::BEGIN@35 at line 135 of JSON/Schema/Modern/Document.pm # once (4µs+214µs) by OpenAPI::Modern::BEGIN@26 at line 676 of JSON/Schema/Modern.pm # once (4µs+136µs) by OpenAPI::Modern::BEGIN@26 at line 133 of JSON/Schema/Modern.pm
$type => sub {
131817µs81.82ms _install_modifier($target, $type, @_);
# spent 1.82ms making 8 calls to Moo::_Utils::_install_modifier, avg 228µs/call
132826µs return;
133 },
134 )
1355155µs } qw(before after around)),
136 );
137}
138
139sub unimport {
140 my $target = caller;
141 _unimport_coderefs($target);
142}
143
144
# spent 2.61ms (132µs+2.47) within Moo::_set_superclasses which was called 2 times, avg 1.30ms/call: # 2 times (132µs+2.47ms) by Moo::extends at line 98, avg 1.30ms/call
sub _set_superclasses {
14520s my $class = shift;
14621µs my $target = shift;
14723µs foreach my $superclass (@_) {
14824µs21.45ms _load_module($superclass);
# spent 1.45ms making 2 calls to Moo::_Utils::_load_module, avg 726µs/call
14927µs26µs if ($INC{'Role/Tiny.pm'} && Role::Tiny->is_role($superclass)) {
# spent 6µs making 2 calls to Role::Tiny::is_role, avg 3µs/call
150 croak "Can't extend role '$superclass'";
151 }
152 }
153256µs232µs @{*{_getglob("${target}::ISA")}} = @_;
# spent 32µs making 2 calls to Moo::_Utils::_getglob, avg 16µs/call
15422µs if (my $old = delete $Moo::MAKERS{$target}{constructor}) {
15525µs219µs $old->assert_constructor;
# spent 19µs making 2 calls to Method::Generate::Constructor::assert_constructor, avg 10µs/call
156231µs23µs delete _getstash($target)->{new};
# spent 3µs making 2 calls to Moo::_Utils::_getstash, avg 2µs/call
157 Moo->_constructor_maker_for($target)
15828µs6933µs ->register_attribute_specs(%{$old->all_attribute_specs});
# spent 867µs making 2 calls to Moo::_constructor_maker_for, avg 434µs/call # spent 64µs making 2 calls to Method::Generate::Constructor::register_attribute_specs, avg 32µs/call # spent 2µs making 2 calls to Method::Generate::Constructor::all_attribute_specs, avg 1µs/call
159 }
160 elsif (!$target->isa('Moo::Object')) {
161 Moo->_constructor_maker_for($target);
162 }
163248µs230µs $Moo::HandleMoose::MOUSE{$target} = [
# spent 30µs making 2 calls to UNIVERSAL::can, avg 15µs/call
164 grep defined, map Mouse::Util::find_meta($_), @_
165 ] if Mouse::Util->can('find_meta');
166}
167
168
# spent 142µs within Moo::_maybe_reset_handlemoose which was called 60 times, avg 2µs/call: # 49 times (121µs+0s) by Moo::has at line 123, avg 2µs/call # 9 times (17µs+0s) by Moo::with at line 105, avg 2µs/call # 2 times (4µs+0s) by Moo::extends at line 99, avg 2µs/call
sub _maybe_reset_handlemoose {
1696038µs my ($class, $target) = @_;
17060145µs if ($INC{'Moo/HandleMoose.pm'} && !$Moo::sification::disabled) {
171 Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target);
172 }
173}
174
175
# spent 14.0ms (6.24+7.74) within Moo::_accessor_maker_for which was called 116 times, avg 121µs/call: # 49 times (81µs+0s) by Moo::has at line 121, avg 2µs/call # 47 times (5.92ms+7.61ms) by MooX::TypeTiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny.pm:25] at line 19 of MooX/TypeTiny.pm, avg 288µs/call # 10 times (204µs+117µs) by Moo::Role::_maybe_make_accessors at line 254 of Moo/Role.pm, avg 32µs/call # 10 times (35µs+13µs) by Moo::_constructor_maker_for at line 207, avg 5µs/call
sub _accessor_maker_for {
17611660µs my ($class, $target) = @_;
17711657µs return unless $MAKERS{$target};
178116316µs $MAKERS{$target}{accessor} ||= do {
179188µs my $maker_class = do {
1802182µs219µs
# spent 14µs (9+5) within Moo::BEGIN@180 which was called: # once (9µs+5µs) by OpenAPI::Modern::BEGIN@11 at line 180
no strict 'refs';
# spent 14µs making 1 call to Moo::BEGIN@180 # spent 5µs making 1 call to strict::unimport
1811813µs if (my $m = do {
18218168µs1849µs my @isa = @{_linear_isa($target)};
# spent 49µs making 18 calls to mro::get_linear_isa, avg 3µs/call
183189µs shift @isa;
1841866µs if (my ($parent_new) = grep +(defined &{$_.'::new'}), @isa) {
185 $MAKERS{$parent_new} && $MAKERS{$parent_new}{accessor};
186 }
187 else {
188 undef;
189 }
190 }) {
191 ref($m);
192 } else {
19318645µs require Method::Generate::Accessor;
194186µs 'Method::Generate::Accessor'
195 }
196 };
1971849µs18226µs $maker_class->new;
# spent 226µs making 18 calls to Moo::Object::new, avg 13µs/call
198 }
199}
200
201
# spent 8.71ms (2.75+5.96) within Moo::_constructor_maker_for which was called 99 times, avg 88µs/call: # 49 times (63µs+0s) by Moo::has at line 119, avg 1µs/call # 47 times (2.56ms+5.22ms) by MooX::TypeTiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny.pm:25] at line 24 of MooX/TypeTiny.pm, avg 165µs/call # 2 times (89µs+778µs) by Moo::_set_superclasses at line 158, avg 434µs/call # once (38µs+-38µs) by Moo::_constructor_maker_for at line 250 of Method/Generate/Constructor.pm
sub _constructor_maker_for {
2029960µs my ($class, $target) = @_;
2039944µs return unless $MAKERS{$target};
20499263µs $MAKERS{$target}{constructor} ||= do {
20510281µs require Method::Generate::Constructor;
206
2071057µs1048µs my %construct_opts = (
# spent 48µs making 10 calls to Moo::_accessor_maker_for, avg 5µs/call
208 package => $target,
209 accessor_generator => $class->_accessor_maker_for($target),
210 subconstructor_handler => (
211 ' if ($Moo::MAKERS{$class}) {'."\n"
212 .' if ($Moo::MAKERS{$class}{constructor}) {'."\n"
213 .' package '.$target.';'."\n"
214 .' return $invoker->SUPER::new(@_);'."\n"
215 .' }'."\n"
216 .' '.$class.'->_constructor_maker_for($class);'."\n"
217 .' return $invoker->new(@_)'.";\n"
218 .' } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n"
219 .' return $meta->new_object('."\n"
220 .' $class->can("BUILDARGS") ? $class->BUILDARGS(@_)'."\n"
221 .' : $class->Moo::Object::BUILDARGS(@_)'."\n"
222 .' );'."\n"
223 .' }'."\n"
224 ),
225 );
226
227100s my $con;
2281036µs1010µs my @isa = @{_linear_isa($target)};
# spent 10µs making 10 calls to mro::get_linear_isa, avg 1µs/call
229103µs shift @isa;
2302172µs212µs
# spent 9µs (6+3) within Moo::BEGIN@230 which was called: # once (6µs+3µs) by OpenAPI::Modern::BEGIN@11 at line 230
no strict 'refs';
# spent 9µs making 1 call to Moo::BEGIN@230 # spent 3µs making 1 call to strict::unimport
2311032µs if (my ($parent_new) = grep +(defined &{$_.'::new'}), @isa) {
2321015µs12µs if ($parent_new eq 'Moo::Object') {
# spent 2µs making 1 call to UNIVERSAL::can
233 # no special constructor needed
234 }
235 elsif (my $makers = $MAKERS{$parent_new}) {
23611µs $con = $makers->{constructor};
23712µs121µs $construct_opts{construction_string} = $con->construction_string
238 if $con;
239 }
240 elsif ($parent_new->can('BUILDALL')) {
241 $construct_opts{construction_builder} = sub {
242 my $inv = $target->can('BUILDARGS') ? '' : 'Moo::Object::';
243 'do {'
244 .' my $args = $class->'.$inv.'BUILDARGS(@_);'
245 .' $args->{__no_BUILD__} = 1;'
246 .' $invoker->'.$target.'::SUPER::new($args);'
247 .'}'
248 };
249 }
250 else {
251
# spent 10µs (7+3) within Moo::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Moo.pm:256] which was called: # once (7µs+3µs) by Method::Generate::Constructor::_build_construction_string at line 68 of Method/Generate/Constructor.pm
$construct_opts{construction_builder} = sub {
252111µs13µs '$invoker->'.$target.'::SUPER::new('
# spent 3µs making 1 call to UNIVERSAL::can
253 .($target->can('FOREIGNBUILDARGS') ?
254 '$class->FOREIGNBUILDARGS(@_)' : '@_')
255 .')'
25612µs };
257 }
258 }
259 ($con ? ref($con) : 'Method::Generate::Constructor')
260 ->new(%construct_opts)
261 ->install_delayed
26210109µs314.68ms ->register_attribute_specs(%{$con?$con->all_attribute_specs:{}})
# spent 2.79ms making 10 calls to Method::Generate::Constructor::install_delayed, avg 278µs/call # spent 1.58ms making 10 calls to Method::Generate::Constructor::new, avg 158µs/call # spent 310µs making 10 calls to Method::Generate::Constructor::register_attribute_specs, avg 31µs/call # spent 2µs making 1 call to Method::Generate::Constructor::all_attribute_specs
263 }
264}
265
266sub _concrete_methods_of {
267 my ($me, $class) = @_;
268 my $makers = $MAKERS{$class};
269
270 my $non_methods = $makers->{non_methods} || {};
271 my $stash = _getstash($class);
272
273 my $subs = {
274 map {;
2752168µs210µs
# spent 7µs (4+3) within Moo::BEGIN@275 which was called: # once (4µs+3µs) by OpenAPI::Modern::BEGIN@11 at line 275
no strict 'refs';
# spent 7µs making 1 call to Moo::BEGIN@275 # spent 3µs making 1 call to strict::unimport
276 ${"${class}::${_}"} = ${"${class}::${_}"};
277 ($_ => \&{"${class}::${_}"});
278 }
279 grep exists &{"${class}::${_}"},
280 grep !/::\z/,
281 keys %$stash
282 };
283
284 my %tracked = map +($_ => 1), _check_tracked($class, [ keys %$subs ]);
285
286 return {
287 map +($_ => \&{"${class}::${_}"}),
288 grep !($non_methods->{$_} && $non_methods->{$_} == $subs->{$_}),
289 grep !exists $tracked{$_},
290 keys %$subs
291 };
292}
293
29414µs1;
295__END__
 
# spent 42µs within Moo::CORE:match which was called 292 times, avg 144ns/call: # 292 times (42µs+0s) by Moo::make_class at line 63, avg 144ns/call
sub Moo::CORE:match; # opcode
# spent 50µs within Moo::CORE:sort which was called 17 times, avg 3µs/call: # 17 times (50µs+0s) by Moo::_install_subs at line 90, avg 3µs/call
sub Moo::CORE:sort; # opcode