| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Class.pm |
| Statements | Executed 4834 statements in 11.3ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 2.33ms | 3.00ms | Moose::Meta::Class::BEGIN@28 |
| 148 | 1 | 1 | 1.74ms | 16.0ms | Moose::Meta::Class::_inline_create_error |
| 56 | 1 | 1 | 1.03ms | 2.57ms | Moose::Meta::Class::_anon_cache_key |
| 1 | 1 | 1 | 702µs | 885µs | Moose::Meta::Class::BEGIN@26 |
| 148 | 2 | 2 | 692µs | 16.9ms | Moose::Meta::Class::_inline_throw_error |
| 33 | 2 | 1 | 568µs | 877µs | Moose::Meta::Class::_base_metaclasses |
| 67 | 6 | 2 | 517µs | 10.4ms | Moose::Meta::Class::superclasses (recurses: max depth 1, inclusive time 610µs) |
| 10 | 1 | 1 | 456µs | 2.03ms | Moose::Meta::Class::excludes_role |
| 1 | 1 | 1 | 394µs | 4.99ms | Moose::Meta::Class::BEGIN@23 |
| 1 | 1 | 1 | 371µs | 603µs | Moose::Meta::Class::BEGIN@25 |
| 1 | 1 | 1 | 358µs | 481µs | Moose::Meta::Class::BEGIN@24 |
| 1 | 1 | 1 | 353µs | 3.40ms | Moose::Meta::Class::_eval_environment |
| 58 | 3 | 1 | 339µs | 422µs | Moose::Meta::Class::CORE:sort (opcode) |
| 1 | 1 | 1 | 338µs | 435µs | Moose::Meta::Class::BEGIN@22 |
| 1 | 1 | 1 | 331µs | 2.53ms | Moose::Meta::Class::BEGIN@21 |
| 28 | 2 | 2 | 298µs | 275ms | Moose::Meta::Class::add_attribute |
| 1 | 1 | 1 | 255µs | 379µs | Moose::Meta::Class::BEGIN@27 |
| 198 | 1 | 1 | 247µs | 247µs | Moose::Meta::Class::CORE:subst (opcode) |
| 148 | 1 | 1 | 200µs | 200µs | Moose::Meta::Class::_inline_raise_error |
| 4 | 1 | 1 | 199µs | 527µs | Moose::Meta::Class::_call_all_triggers |
| 22 | 1 | 1 | 181µs | 7.42ms | Moose::Meta::Class::_inline_init_attr_from_constructor |
| 21 | 1 | 1 | 141µs | 3.20ms | Moose::Meta::Class::add_override_method_modifier |
| 22 | 1 | 1 | 134µs | 8.36ms | Moose::Meta::Class::_inline_slot_initializer |
| 22 | 1 | 1 | 126µs | 170µs | Moose::Meta::Class::_inline_check_required_attr |
| 13 | 3 | 3 | 125µs | 9.39ms | Moose::Meta::Class::initialize |
| 22 | 1 | 1 | 114µs | 423µs | Moose::Meta::Class::_inline_init_attr_from_default |
| 8 | 1 | 1 | 106µs | 67.9ms | Moose::Meta::Class::create |
| 1 | 1 | 1 | 80µs | 344µs | Moose::Meta::Class::_inline_triggers |
| 10 | 1 | 1 | 68µs | 93µs | Moose::Meta::Class::add_role |
| 10 | 1 | 1 | 67µs | 95µs | Moose::Meta::Class::add_role_application |
| 9 | 1 | 1 | 60µs | 9.23ms | Moose::Meta::Class::_process_attribute |
| 9 | 1 | 1 | 60µs | 9.17ms | Moose::Meta::Class::_process_new_attribute |
| 4 | 1 | 1 | 45µs | 146µs | Moose::Meta::Class::calculate_all_roles |
| 4 | 1 | 1 | 37µs | 2.21ms | Moose::Meta::Class::new_object |
| 13 | 1 | 1 | 18µs | 18µs | Moose::Meta::Class::__ANON__[:37] |
| 1 | 1 | 1 | 16µs | 196µs | Moose::Meta::Class::_inline_BUILDARGS |
| 13 | 1 | 1 | 14µs | 14µs | Moose::Meta::Class::__ANON__[:43] |
| 13 | 1 | 1 | 12µs | 12µs | Moose::Meta::Class::_meta_method_class |
| 1 | 1 | 1 | 11µs | 103µs | Moose::Meta::Class::_inline_BUILDALL |
| 1 | 1 | 1 | 10µs | 206µs | Moose::Meta::Class::_inline_params |
| 8 | 1 | 1 | 9µs | 9µs | Moose::Meta::Class::_anon_package_prefix |
| 1 | 1 | 1 | 8µs | 455µs | Moose::Meta::Class::_inline_extra_init |
| 1 | 1 | 1 | 8µs | 8µs | Moose::Meta::Class::BEGIN@3 |
| 1 | 1 | 1 | 7µs | 41µs | Moose::Meta::Class::_immutable_options |
| 1 | 1 | 1 | 6µs | 27µs | Moose::Meta::Class::BEGIN@13 |
| 1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Class::BEGIN@16 |
| 1 | 1 | 1 | 6µs | 23µs | Moose::Meta::Class::BEGIN@19 |
| 1 | 1 | 1 | 6µs | 55µs | Moose::Meta::Class::BEGIN@31 |
| 1 | 1 | 1 | 6µs | 33µs | Moose::Meta::Class::BEGIN@18 |
| 1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Class::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 16µs | Moose::Meta::Class::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 24µs | Moose::Meta::Class::BEGIN@15 |
| 1 | 1 | 1 | 5µs | 22µs | Moose::Meta::Class::BEGIN@17 |
| 1 | 1 | 1 | 4µs | 4µs | Moose::Meta::Class::BEGIN@29 |
| 9 | 1 | 1 | 4µs | 4µs | Moose::Meta::Class::CORE:match (opcode) |
| 1 | 1 | 1 | 3µs | 3µs | Moose::Meta::Class::BEGIN@14 |
| 1 | 1 | 1 | 3µs | 3µs | Moose::Meta::Class::_generate_fallback_constructor |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::__ANON__[:125] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::__ANON__[:543] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_find_next_method_by_name_which_is_not_overridden |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_class_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fix_single_metaclass_incompatibility |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_fixup_attributes_after_rebless |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_process_inherited_attribute |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_replace_self |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_restore_metaobjects_from |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::add_augment_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::calculate_all_roles_with_inheritance |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::create_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::does_role |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::raise_error |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::reinitialize |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::role_applications |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Class::throw_error |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Class; | ||||
| 3 | # spent 8µs within Moose::Meta::Class::BEGIN@3 which was called:
# once (8µs+0s) by Moose::BEGIN@27 at line 5 | ||||
| 4 | 1 | 4µs | $Moose::Meta::Class::AUTHORITY = 'cpan:STEVAN'; | ||
| 5 | 1 | 26µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::Class::BEGIN@3 |
| 6 | { | ||||
| 7 | 2 | 900ns | $Moose::Meta::Class::VERSION = '2.1005'; | ||
| 8 | } | ||||
| 9 | |||||
| 10 | 2 | 19µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::Class::BEGIN@10 which was called:
# once (6µs+10µs) by Moose::BEGIN@27 at line 10 # spent 16µs making 1 call to Moose::Meta::Class::BEGIN@10
# spent 10µs making 1 call to strict::import |
| 11 | 2 | 21µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Class::BEGIN@11 which was called:
# once (6µs+3µs) by Moose::BEGIN@27 at line 11 # spent 9µs making 1 call to Moose::Meta::Class::BEGIN@11
# spent 3µs making 1 call to warnings::import |
| 12 | |||||
| 13 | 2 | 20µs | 2 | 49µs | # spent 27µs (6+21) within Moose::Meta::Class::BEGIN@13 which was called:
# once (6µs+21µs) by Moose::BEGIN@27 at line 13 # spent 27µs making 1 call to Moose::Meta::Class::BEGIN@13
# spent 21µs making 1 call to Exporter::import |
| 14 | 2 | 19µs | 1 | 3µs | # spent 3µs within Moose::Meta::Class::BEGIN@14 which was called:
# once (3µs+0s) by Moose::BEGIN@27 at line 14 # spent 3µs making 1 call to Moose::Meta::Class::BEGIN@14 |
| 15 | 2 | 19µs | 2 | 43µs | # spent 24µs (6+19) within Moose::Meta::Class::BEGIN@15 which was called:
# once (6µs+19µs) by Moose::BEGIN@27 at line 15 # spent 24µs making 1 call to Moose::Meta::Class::BEGIN@15
# spent 19µs making 1 call to Exporter::import |
| 16 | 2 | 19µs | 2 | 13µs | # spent 9µs (6+3) within Moose::Meta::Class::BEGIN@16 which was called:
# once (6µs+3µs) by Moose::BEGIN@27 at line 16 # spent 9µs making 1 call to Moose::Meta::Class::BEGIN@16
# spent 3µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284] |
| 17 | 2 | 25µs | 2 | 39µs | # spent 22µs (5+17) within Moose::Meta::Class::BEGIN@17 which was called:
# once (5µs+17µs) by Moose::BEGIN@27 at line 17 # spent 22µs making 1 call to Moose::Meta::Class::BEGIN@17
# spent 17µs making 1 call to Exporter::import |
| 18 | 2 | 24µs | 2 | 61µs | # spent 33µs (6+27) within Moose::Meta::Class::BEGIN@18 which was called:
# once (6µs+27µs) by Moose::BEGIN@27 at line 18 # spent 33µs making 1 call to Moose::Meta::Class::BEGIN@18
# spent 27µs making 1 call to Exporter::import |
| 19 | 2 | 23µs | 2 | 40µs | # spent 23µs (6+17) within Moose::Meta::Class::BEGIN@19 which was called:
# once (6µs+17µs) by Moose::BEGIN@27 at line 19 # spent 23µs making 1 call to Moose::Meta::Class::BEGIN@19
# spent 17µs making 1 call to Exporter::import |
| 20 | |||||
| 21 | 2 | 109µs | 1 | 2.53ms | # spent 2.53ms (331µs+2.20) within Moose::Meta::Class::BEGIN@21 which was called:
# once (331µs+2.20ms) by Moose::BEGIN@27 at line 21 # spent 2.53ms making 1 call to Moose::Meta::Class::BEGIN@21 |
| 22 | 2 | 101µs | 1 | 435µs | # spent 435µs (338+97) within Moose::Meta::Class::BEGIN@22 which was called:
# once (338µs+97µs) by Moose::BEGIN@27 at line 22 # spent 435µs making 1 call to Moose::Meta::Class::BEGIN@22 |
| 23 | 2 | 91µs | 1 | 4.99ms | # spent 4.99ms (394µs+4.59) within Moose::Meta::Class::BEGIN@23 which was called:
# once (394µs+4.59ms) by Moose::BEGIN@27 at line 23 # spent 4.99ms making 1 call to Moose::Meta::Class::BEGIN@23 |
| 24 | 2 | 94µs | 1 | 481µs | # spent 481µs (358+122) within Moose::Meta::Class::BEGIN@24 which was called:
# once (358µs+122µs) by Moose::BEGIN@27 at line 24 # spent 481µs making 1 call to Moose::Meta::Class::BEGIN@24 |
| 25 | 2 | 87µs | 1 | 603µs | # spent 603µs (371+232) within Moose::Meta::Class::BEGIN@25 which was called:
# once (371µs+232µs) by Moose::BEGIN@27 at line 25 # spent 603µs making 1 call to Moose::Meta::Class::BEGIN@25 |
| 26 | 2 | 90µs | 1 | 885µs | # spent 885µs (702+184) within Moose::Meta::Class::BEGIN@26 which was called:
# once (702µs+184µs) by Moose::BEGIN@27 at line 26 # spent 885µs making 1 call to Moose::Meta::Class::BEGIN@26 |
| 27 | 2 | 90µs | 1 | 379µs | # spent 379µs (255+123) within Moose::Meta::Class::BEGIN@27 which was called:
# once (255µs+123µs) by Moose::BEGIN@27 at line 27 # spent 379µs making 1 call to Moose::Meta::Class::BEGIN@27 |
| 28 | 2 | 90µs | 2 | 3.08ms | # spent 3.00ms (2.33+671µs) within Moose::Meta::Class::BEGIN@28 which was called:
# once (2.33ms+671µs) by Moose::BEGIN@27 at line 28 # spent 3.00ms making 1 call to Moose::Meta::Class::BEGIN@28
# spent 84µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 29 | 2 | 22µs | 1 | 4µs | # spent 4µs within Moose::Meta::Class::BEGIN@29 which was called:
# once (4µs+0s) by Moose::BEGIN@27 at line 29 # spent 4µs making 1 call to Moose::Meta::Class::BEGIN@29 |
| 30 | |||||
| 31 | 2 | 3.22ms | 2 | 105µs | # spent 55µs (6+50) within Moose::Meta::Class::BEGIN@31 which was called:
# once (6µs+50µs) by Moose::BEGIN@27 at line 31 # spent 55µs making 1 call to Moose::Meta::Class::BEGIN@31
# spent 50µs making 1 call to base::import |
| 32 | |||||
| 33 | 1 | 2µs | 1 | 1.11ms | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 1.11ms making 1 call to Class::MOP::MiniTrait::apply |
| 34 | |||||
| 35 | __PACKAGE__->meta->add_attribute('roles' => ( | ||||
| 36 | reader => 'roles', | ||||
| 37 | 13 | 25µs | # spent 18µs within Moose::Meta::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Class.pm:37] which was called 13 times, avg 1µs/call:
# 13 times (18µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 1µs/call | ||
| 38 | 1 | 11µs | 3 | 393µs | Class::MOP::_definition_context(), # spent 377µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Class::MOP::Object::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
| 39 | )); | ||||
| 40 | |||||
| 41 | __PACKAGE__->meta->add_attribute('role_applications' => ( | ||||
| 42 | reader => '_get_role_applications', | ||||
| 43 | 13 | 25µs | # spent 14µs within Moose::Meta::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Class.pm:43] which was called 13 times, avg 1µs/call:
# 13 times (14µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 1µs/call | ||
| 44 | 1 | 4µs | 3 | 268µs | Class::MOP::_definition_context(), # spent 255µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::Object::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 45 | )); | ||||
| 46 | |||||
| 47 | 1 | 5µs | 4 | 261µs | __PACKAGE__->meta->add_attribute( # spent 234µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 14µs making 1 call to Class::MOP::Attribute::new
# spent 8µs making 1 call to Class::MOP::Object::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 48 | Class::MOP::Attribute->new('immutable_trait' => ( | ||||
| 49 | accessor => "immutable_trait", | ||||
| 50 | default => 'Moose::Meta::Class::Immutable::Trait', | ||||
| 51 | Class::MOP::_definition_context(), | ||||
| 52 | )) | ||||
| 53 | ); | ||||
| 54 | |||||
| 55 | 1 | 3µs | 3 | 259µs | __PACKAGE__->meta->add_attribute('constructor_class' => ( # spent 247µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::Object::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 56 | accessor => 'constructor_class', | ||||
| 57 | default => 'Moose::Meta::Method::Constructor', | ||||
| 58 | Class::MOP::_definition_context(), | ||||
| 59 | )); | ||||
| 60 | |||||
| 61 | 1 | 3µs | 3 | 255µs | __PACKAGE__->meta->add_attribute('destructor_class' => ( # spent 243µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::Object::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 62 | accessor => 'destructor_class', | ||||
| 63 | default => 'Moose::Meta::Method::Destructor', | ||||
| 64 | Class::MOP::_definition_context(), | ||||
| 65 | )); | ||||
| 66 | |||||
| 67 | 1 | 3µs | 3 | 257µs | __PACKAGE__->meta->add_attribute('error_class' => ( # spent 245µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Class::MOP::Object::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 68 | accessor => 'error_class', | ||||
| 69 | default => 'Moose::Error::Default', | ||||
| 70 | Class::MOP::_definition_context(), | ||||
| 71 | )); | ||||
| 72 | |||||
| 73 | # spent 9.39ms (125µs+9.26) within Moose::Meta::Class::initialize which was called 13 times, avg 722µs/call:
# 8 times (74µs+3.40ms) by Class::MOP::Package::create at line 72 of Class/MOP/Package.pm, avg 435µs/call
# 4 times (35µs+5.16ms) by Moose::init_meta at line 202 of Moose.pm, avg 1.30ms/call
# once (16µs+705µs) by metaclass::import at line 48 of metaclass.pm | ||||
| 74 | 13 | 3µs | my $class = shift; | ||
| 75 | 13 | 6µs | my @args = @_; | ||
| 76 | 13 | 9µs | unshift @args, 'package' if @args % 2; | ||
| 77 | 13 | 9µs | my %opts = @args; | ||
| 78 | 13 | 7µs | my $package = delete $opts{package}; | ||
| 79 | 13 | 73µs | 26 | 9.26ms | return Class::MOP::get_metaclass_by_name($package) # spent 9.25ms making 13 calls to Class::MOP::Class::initialize, avg 712µs/call
# spent 12µs making 13 calls to Class::MOP::get_metaclass_by_name, avg 938ns/call |
| 80 | || $class->SUPER::initialize($package, | ||||
| 81 | 'attribute_metaclass' => 'Moose::Meta::Attribute', | ||||
| 82 | 'method_metaclass' => 'Moose::Meta::Method', | ||||
| 83 | 'instance_metaclass' => 'Moose::Meta::Instance', | ||||
| 84 | %opts, | ||||
| 85 | ); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | # spent 67.9ms (106µs+67.8) within Moose::Meta::Class::create which was called 8 times, avg 8.48ms/call:
# 8 times (106µs+67.8ms) by Class::MOP::Package::create_anon at line 120 of Class/MOP/Package.pm, avg 8.48ms/call | ||||
| 89 | 8 | 2µs | my $class = shift; | ||
| 90 | 8 | 7µs | my @args = @_; | ||
| 91 | |||||
| 92 | 8 | 9µs | unshift @args, 'package' if @args % 2 == 1; | ||
| 93 | 8 | 9µs | my %options = @args; | ||
| 94 | |||||
| 95 | 8 | 7µs | (ref $options{roles} eq 'ARRAY') | ||
| 96 | || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles}) | ||||
| 97 | if exists $options{roles}; | ||||
| 98 | |||||
| 99 | 8 | 4µs | my $package = delete $options{package}; | ||
| 100 | 8 | 2µs | my $roles = delete $options{roles}; | ||
| 101 | |||||
| 102 | 8 | 17µs | 8 | 16.7ms | my $new_meta = $class->SUPER::create($package, %options); # spent 16.7ms making 8 calls to Class::MOP::Class::create, avg 2.09ms/call |
| 103 | |||||
| 104 | 8 | 12µs | 8 | 5.17ms | if ($roles) { # spent 51.0ms making 8 calls to Moose::Util::apply_all_roles, avg 6.38ms/call, recursion: max depth 1, sum of overlapping time 45.9ms |
| 105 | Moose::Util::apply_all_roles( $new_meta, @$roles ); | ||||
| 106 | } | ||||
| 107 | |||||
| 108 | 8 | 23µs | return $new_meta; | ||
| 109 | } | ||||
| 110 | |||||
| 111 | 13 | 29µs | # spent 12µs within Moose::Meta::Class::_meta_method_class which was called 13 times, avg 962ns/call:
# 13 times (12µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 962ns/call | ||
| 112 | |||||
| 113 | 8 | 13µs | # spent 9µs within Moose::Meta::Class::_anon_package_prefix which was called 8 times, avg 1µs/call:
# 8 times (9µs+0s) by Class::MOP::Package::create_anon at line 118 of Class/MOP/Package.pm, avg 1µs/call | ||
| 114 | |||||
| 115 | # spent 2.57ms (1.03+1.54) within Moose::Meta::Class::_anon_cache_key which was called 56 times, avg 46µs/call:
# 56 times (1.03ms+1.54ms) by Class::MOP::Package::create_anon at line 108 of Class/MOP/Package.pm, avg 46µs/call | ||||
| 116 | 56 | 7µs | my $class = shift; | ||
| 117 | 56 | 37µs | my %options = @_; | ||
| 118 | |||||
| 119 | my $superclass_key = join('|', | ||||
| 120 | 56 | 182µs | 56 | 855µs | map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) } # spent 855µs making 56 calls to Data::OptList::mkopt, avg 15µs/call |
| 121 | ); | ||||
| 122 | |||||
| 123 | my $roles = Data::OptList::mkopt(($options{roles} || []), { | ||||
| 124 | moniker => 'role', | ||||
| 125 | val_test => sub { ref($_[0]) eq 'HASH' }, | ||||
| 126 | 56 | 241µs | 56 | 640µs | }); # spent 640µs making 56 calls to Data::OptList::mkopt, avg 11µs/call |
| 127 | |||||
| 128 | 56 | 6µs | my @role_keys; | ||
| 129 | 56 | 24µs | for my $role_spec (@$roles) { | ||
| 130 | 56 | 17µs | my ($role, $params) = @$role_spec; | ||
| 131 | 56 | 400ns | $params = { %$params } if $params; | ||
| 132 | |||||
| 133 | 56 | 117µs | 56 | 31µs | my $key = blessed($role) ? $role->name : $role; # spent 31µs making 56 calls to Scalar::Util::blessed, avg 550ns/call |
| 134 | |||||
| 135 | 56 | 400ns | if ($params && %$params) { | ||
| 136 | my $alias = delete $params->{'-alias'} | ||||
| 137 | || delete $params->{'alias'} | ||||
| 138 | || {}; | ||||
| 139 | my $excludes = delete $params->{'-excludes'} | ||||
| 140 | || delete $params->{'excludes'} | ||||
| 141 | || []; | ||||
| 142 | $excludes = [$excludes] unless ref($excludes) eq 'ARRAY'; | ||||
| 143 | |||||
| 144 | if (%$params) { | ||||
| 145 | warn "Roles with parameters cannot be cached. Consider " | ||||
| 146 | . "applying the parameters before calling " | ||||
| 147 | . "create_anon_class, or using 'weaken => 0' instead"; | ||||
| 148 | return; | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | my $alias_key = join('%', | ||||
| 152 | map { $_ => $alias->{$_} } sort keys %$alias | ||||
| 153 | ); | ||||
| 154 | my $excludes_key = join('%', | ||||
| 155 | sort @$excludes | ||||
| 156 | ); | ||||
| 157 | $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>'; | ||||
| 158 | } | ||||
| 159 | |||||
| 160 | 56 | 48µs | push @role_keys, $key; | ||
| 161 | } | ||||
| 162 | |||||
| 163 | 56 | 105µs | 56 | 16µs | my $role_key = join('|', sort @role_keys); # spent 16µs making 56 calls to Moose::Meta::Class::CORE:sort, avg 282ns/call |
| 164 | |||||
| 165 | # Makes something like Super::Class|Super::Class::2=Role|Role::1 | ||||
| 166 | 56 | 169µs | return join('=', $superclass_key, $role_key); | ||
| 167 | } | ||||
| 168 | |||||
| 169 | sub reinitialize { | ||||
| 170 | my $self = shift; | ||||
| 171 | my $pkg = shift; | ||||
| 172 | |||||
| 173 | my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg); | ||||
| 174 | |||||
| 175 | my %existing_classes; | ||||
| 176 | if ($meta) { | ||||
| 177 | %existing_classes = map { $_ => $meta->$_() } qw( | ||||
| 178 | attribute_metaclass | ||||
| 179 | method_metaclass | ||||
| 180 | wrapped_method_metaclass | ||||
| 181 | instance_metaclass | ||||
| 182 | constructor_class | ||||
| 183 | destructor_class | ||||
| 184 | error_class | ||||
| 185 | ); | ||||
| 186 | } | ||||
| 187 | |||||
| 188 | return $self->SUPER::reinitialize( | ||||
| 189 | $pkg, | ||||
| 190 | %existing_classes, | ||||
| 191 | @_, | ||||
| 192 | ); | ||||
| 193 | } | ||||
| 194 | |||||
| 195 | # spent 93µs (68+24) within Moose::Meta::Class::add_role which was called 10 times, avg 9µs/call:
# 10 times (68µs+24µs) by Moose::Meta::Role::Application::ToClass::apply at line 38 of Moose/Meta/Role/Application/ToClass.pm, avg 9µs/call | ||||
| 196 | 10 | 2µs | my ($self, $role) = @_; | ||
| 197 | 10 | 43µs | 20 | 12µs | (blessed($role) && $role->isa('Moose::Meta::Role')) # spent 6µs making 10 calls to Scalar::Util::blessed, avg 650ns/call
# spent 6µs making 10 calls to UNIVERSAL::isa, avg 570ns/call |
| 198 | || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role); | ||||
| 199 | 10 | 28µs | 10 | 12µs | push @{$self->roles} => $role; # spent 12µs making 10 calls to Moose::Meta::Class::roles, avg 1µs/call |
| 200 | } | ||||
| 201 | |||||
| 202 | sub role_applications { | ||||
| 203 | my ($self) = @_; | ||||
| 204 | |||||
| 205 | return @{$self->_get_role_applications}; | ||||
| 206 | } | ||||
| 207 | |||||
| 208 | # spent 95µs (67+28) within Moose::Meta::Class::add_role_application which was called 10 times, avg 10µs/call:
# 10 times (67µs+28µs) by Moose::Meta::Role::Application::ToClass::apply at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 10µs/call | ||||
| 209 | 10 | 2µs | my ($self, $application) = @_; | ||
| 210 | 10 | 43µs | 20 | 11µs | (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass')) # spent 6µs making 10 calls to UNIVERSAL::isa, avg 630ns/call
# spent 5µs making 10 calls to Scalar::Util::blessed, avg 480ns/call |
| 211 | || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application); | ||||
| 212 | 10 | 29µs | 10 | 17µs | push @{$self->_get_role_applications} => $application; # spent 17µs making 10 calls to Moose::Meta::Class::_get_role_applications, avg 2µs/call |
| 213 | } | ||||
| 214 | |||||
| 215 | # spent 146µs (45+102) within Moose::Meta::Class::calculate_all_roles which was called 4 times, avg 37µs/call:
# 4 times (45µs+102µs) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 216 of Moose/Meta/Attribute/Native/Trait.pm, avg 37µs/call | ||||
| 216 | 4 | 1µs | my $self = shift; | ||
| 217 | 4 | 400ns | my %seen; | ||
| 218 | 16 | 40µs | 16 | 102µs | grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles }; # spent 93µs making 4 calls to Moose::Meta::Role::calculate_all_roles, avg 23µs/call
# spent 5µs making 4 calls to Moose::Meta::Class::roles, avg 1µs/call
# spent 4µs making 8 calls to Class::MOP::Package::name, avg 438ns/call |
| 219 | } | ||||
| 220 | |||||
| 221 | sub _roles_with_inheritance { | ||||
| 222 | my $self = shift; | ||||
| 223 | my %seen; | ||||
| 224 | grep { !$seen{$_->name}++ } | ||||
| 225 | map { Class::MOP::class_of($_)->can('roles') | ||||
| 226 | ? @{ Class::MOP::class_of($_)->roles } | ||||
| 227 | : () } | ||||
| 228 | $self->linearized_isa; | ||||
| 229 | } | ||||
| 230 | |||||
| 231 | sub calculate_all_roles_with_inheritance { | ||||
| 232 | my $self = shift; | ||||
| 233 | my %seen; | ||||
| 234 | grep { !$seen{$_->name}++ } | ||||
| 235 | map { Class::MOP::class_of($_)->can('calculate_all_roles') | ||||
| 236 | ? Class::MOP::class_of($_)->calculate_all_roles | ||||
| 237 | : () } | ||||
| 238 | $self->linearized_isa; | ||||
| 239 | } | ||||
| 240 | |||||
| 241 | sub does_role { | ||||
| 242 | my ($self, $role_name) = @_; | ||||
| 243 | |||||
| 244 | (defined $role_name) | ||||
| 245 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 246 | |||||
| 247 | foreach my $class ($self->class_precedence_list) { | ||||
| 248 | my $meta = Class::MOP::class_of($class); | ||||
| 249 | # when a Moose metaclass is itself extended with a role, | ||||
| 250 | # this check needs to be done since some items in the | ||||
| 251 | # class_precedence_list might in fact be Class::MOP | ||||
| 252 | # based still. | ||||
| 253 | next unless $meta && $meta->can('roles'); | ||||
| 254 | foreach my $role (@{$meta->roles}) { | ||||
| 255 | return 1 if $role->does_role($role_name); | ||||
| 256 | } | ||||
| 257 | } | ||||
| 258 | return 0; | ||||
| 259 | } | ||||
| 260 | |||||
| 261 | # spent 2.03ms (456µs+1.58) within Moose::Meta::Class::excludes_role which was called 10 times, avg 203µs/call:
# 10 times (456µs+1.58ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 44 of Moose/Meta/Role/Application/ToClass.pm, avg 203µs/call | ||||
| 262 | 10 | 3µs | my ($self, $role_name) = @_; | ||
| 263 | |||||
| 264 | 10 | 2µs | (defined $role_name) | ||
| 265 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 266 | |||||
| 267 | 10 | 45µs | 10 | 1.17ms | foreach my $class ($self->class_precedence_list) { # spent 1.17ms making 10 calls to Class::MOP::Class::class_precedence_list, avg 117µs/call |
| 268 | 132 | 72µs | 132 | 318µs | my $meta = Class::MOP::class_of($class); # spent 318µs making 132 calls to Class::MOP::class_of, avg 2µs/call |
| 269 | # when a Moose metaclass is itself extended with a role, | ||||
| 270 | # this check needs to be done since some items in the | ||||
| 271 | # class_precedence_list might in fact be Class::MOP | ||||
| 272 | # based still. | ||||
| 273 | 132 | 242µs | 132 | 74µs | next unless $meta && $meta->can('roles'); # spent 74µs making 132 calls to UNIVERSAL::can, avg 561ns/call |
| 274 | 11 | 18µs | 11 | 15µs | foreach my $role (@{$meta->roles}) { # spent 15µs making 11 calls to Moose::Meta::Class::roles, avg 1µs/call |
| 275 | return 1 if $role->excludes_role($role_name); | ||||
| 276 | } | ||||
| 277 | } | ||||
| 278 | 10 | 17µs | return 0; | ||
| 279 | } | ||||
| 280 | |||||
| 281 | # spent 2.21ms (37µs+2.17) within Moose::Meta::Class::new_object which was called 4 times, avg 552µs/call:
# 4 times (37µs+2.17ms) by Moose::Meta::Attribute::_new at line 7 of (eval 74)[Eval/Closure.pm:135], avg 552µs/call | ||||
| 282 | 4 | 900ns | my $self = shift; | ||
| 283 | 4 | 2µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 284 | 4 | 6µs | 4 | 1.64ms | my $object = $self->SUPER::new_object($params); # spent 1.64ms making 4 calls to Class::MOP::Class::new_object, avg 410µs/call |
| 285 | |||||
| 286 | 4 | 7µs | 4 | 527µs | $self->_call_all_triggers($object, $params); # spent 527µs making 4 calls to Moose::Meta::Class::_call_all_triggers, avg 132µs/call |
| 287 | |||||
| 288 | 4 | 12µs | 4 | 6µs | $object->BUILDALL($params) if $object->can('BUILDALL'); # spent 6µs making 4 calls to UNIVERSAL::can, avg 1µs/call |
| 289 | |||||
| 290 | 4 | 7µs | return $object; | ||
| 291 | } | ||||
| 292 | |||||
| 293 | # spent 527µs (199+328) within Moose::Meta::Class::_call_all_triggers which was called 4 times, avg 132µs/call:
# 4 times (199µs+328µs) by Moose::Meta::Class::new_object at line 286, avg 132µs/call | ||||
| 294 | 4 | 1µs | my ($self, $object, $params) = @_; | ||
| 295 | |||||
| 296 | 4 | 17µs | 4 | 268µs | foreach my $attr ( $self->get_all_attributes() ) { # spent 268µs making 4 calls to Class::MOP::Class::get_all_attributes, avg 67µs/call |
| 297 | |||||
| 298 | 120 | 200µs | 128 | 59µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 52µs making 120 calls to UNIVERSAL::can, avg 429ns/call
# spent 8µs making 8 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 988ns/call |
| 299 | |||||
| 300 | my $init_arg = $attr->init_arg; | ||||
| 301 | next unless defined $init_arg; | ||||
| 302 | next unless exists $params->{$init_arg}; | ||||
| 303 | |||||
| 304 | $attr->trigger->( | ||||
| 305 | $object, | ||||
| 306 | ( | ||||
| 307 | $attr->should_coerce | ||||
| 308 | ? $attr->get_read_method_ref->($object) | ||||
| 309 | : $params->{$init_arg} | ||||
| 310 | ), | ||||
| 311 | ); | ||||
| 312 | } | ||||
| 313 | } | ||||
| 314 | |||||
| 315 | # spent 3µs within Moose::Meta::Class::_generate_fallback_constructor which was called:
# once (3µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 553 of Class/MOP/Class.pm | ||||
| 316 | 1 | 200ns | my $self = shift; | ||
| 317 | 1 | 300ns | my ($class) = @_; | ||
| 318 | 1 | 4µs | return $class . '->Moose::Object::new(@_)' | ||
| 319 | } | ||||
| 320 | |||||
| 321 | # spent 206µs (10+196) within Moose::Meta::Class::_inline_params which was called:
# once (10µs+196µs) by Class::MOP::Class::_inline_new_object at line 537 of Class/MOP/Class.pm | ||||
| 322 | 1 | 200ns | my $self = shift; | ||
| 323 | 1 | 500ns | my ($params, $class) = @_; | ||
| 324 | return ( | ||||
| 325 | 1 | 5µs | 1 | 196µs | 'my ' . $params . ' = ', # spent 196µs making 1 call to Moose::Meta::Class::_inline_BUILDARGS |
| 326 | $self->_inline_BUILDARGS($class, '@_'), | ||||
| 327 | ';', | ||||
| 328 | ); | ||||
| 329 | } | ||||
| 330 | |||||
| 331 | # spent 196µs (16+180) within Moose::Meta::Class::_inline_BUILDARGS which was called:
# once (16µs+180µs) by Moose::Meta::Class::_inline_params at line 325 | ||||
| 332 | 1 | 200ns | my $self = shift; | ||
| 333 | 1 | 700ns | my ($class, $args) = @_; | ||
| 334 | |||||
| 335 | 1 | 1µs | 1 | 119µs | my $buildargs = $self->find_method_by_name("BUILDARGS"); # spent 119µs making 1 call to Class::MOP::Class::find_method_by_name |
| 336 | |||||
| 337 | 1 | 16µs | 2 | 60µs | if ($args eq '@_' # spent 60µs making 1 call to Moose::Meta::Class::_inline_throw_error
# spent 600ns making 1 call to Class::MOP::Method::body |
| 338 | && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) { | ||||
| 339 | return ( | ||||
| 340 | 'do {', | ||||
| 341 | 'my $params;', | ||||
| 342 | 'if (scalar @_ == 1) {', | ||||
| 343 | 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {', | ||||
| 344 | $self->_inline_throw_error( | ||||
| 345 | '"Single parameters to new() must be a HASH ref"', | ||||
| 346 | 'data => $_[0]', | ||||
| 347 | ) . ';', | ||||
| 348 | '}', | ||||
| 349 | '$params = { %{ $_[0] } };', | ||||
| 350 | '}', | ||||
| 351 | 'elsif (@_ % 2) {', | ||||
| 352 | 'Carp::carp(', | ||||
| 353 | '"The new() method for ' . $class . ' expects a ' | ||||
| 354 | . 'hash reference or a key/value list. You passed an ' | ||||
| 355 | . 'odd number of arguments"', | ||||
| 356 | ');', | ||||
| 357 | '$params = {@_, undef};', | ||||
| 358 | '}', | ||||
| 359 | 'else {', | ||||
| 360 | '$params = {@_};', | ||||
| 361 | '}', | ||||
| 362 | '$params;', | ||||
| 363 | '}', | ||||
| 364 | ); | ||||
| 365 | } | ||||
| 366 | else { | ||||
| 367 | return $class . '->BUILDARGS(' . $args . ')'; | ||||
| 368 | } | ||||
| 369 | } | ||||
| 370 | |||||
| 371 | # spent 8.36ms (134µs+8.22) within Moose::Meta::Class::_inline_slot_initializer which was called 22 times, avg 380µs/call:
# 22 times (134µs+8.22ms) by Class::MOP::Class::_inline_slot_initializers at line 591 of Class/MOP/Class.pm, avg 380µs/call | ||||
| 372 | 22 | 2µs | my $self = shift; | ||
| 373 | 22 | 2µs | my ($attr, $idx) = @_; | ||
| 374 | |||||
| 375 | return ( | ||||
| 376 | 22 | 114µs | 66 | 8.22ms | '## ' . $attr->name, # spent 8.04ms making 22 calls to Class::MOP::Class::_inline_slot_initializer, avg 366µs/call
# spent 170µs making 22 calls to Moose::Meta::Class::_inline_check_required_attr, avg 8µs/call
# spent 11µs making 22 calls to Class::MOP::Mixin::AttributeCore::name, avg 495ns/call |
| 377 | $self->_inline_check_required_attr($attr), | ||||
| 378 | $self->SUPER::_inline_slot_initializer(@_), | ||||
| 379 | ); | ||||
| 380 | } | ||||
| 381 | |||||
| 382 | # spent 170µs (126+44) within Moose::Meta::Class::_inline_check_required_attr which was called 22 times, avg 8µs/call:
# 22 times (126µs+44µs) by Moose::Meta::Class::_inline_slot_initializer at line 376, avg 8µs/call | ||||
| 383 | 22 | 2µs | my $self = shift; | ||
| 384 | 22 | 2µs | my ($attr) = @_; | ||
| 385 | |||||
| 386 | 22 | 47µs | 22 | 10µs | return unless defined $attr->init_arg; # spent 10µs making 22 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 441ns/call |
| 387 | 22 | 85µs | 44 | 34µs | return unless $attr->can('is_required') && $attr->is_required; # spent 23µs making 22 calls to Moose::Meta::Mixin::AttributeCore::is_required, avg 1µs/call
# spent 12µs making 22 calls to UNIVERSAL::can, avg 532ns/call |
| 388 | return if $attr->has_default || $attr->has_builder; | ||||
| 389 | |||||
| 390 | return ( | ||||
| 391 | 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {', | ||||
| 392 | $self->_inline_throw_error( | ||||
| 393 | '"Attribute (' . quotemeta($attr->name) . ') is required"' | ||||
| 394 | ) . ';', | ||||
| 395 | '}', | ||||
| 396 | ); | ||||
| 397 | } | ||||
| 398 | |||||
| 399 | # XXX: these two are duplicated from cmop, because we have to pass the tc stuff | ||||
| 400 | # through to _inline_set_value - this should probably be fixed, but i'm not | ||||
| 401 | # quite sure how. -doy | ||||
| 402 | # spent 7.42ms (181µs+7.24) within Moose::Meta::Class::_inline_init_attr_from_constructor which was called 22 times, avg 337µs/call:
# 22 times (181µs+7.24ms) by Class::MOP::Class::_inline_slot_initializer at line 600 of Class/MOP/Class.pm, avg 337µs/call | ||||
| 403 | 22 | 2µs | my $self = shift; | ||
| 404 | 22 | 2µs | my ($attr, $idx) = @_; | ||
| 405 | |||||
| 406 | 22 | 77µs | 44 | 7.21ms | my @initial_value = $attr->_inline_set_value( # spent 7.20ms making 22 calls to Moose::Meta::Attribute::_inline_set_value, avg 327µs/call
# spent 7µs making 22 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 305ns/call |
| 407 | '$instance', | ||||
| 408 | '$params->{\'' . $attr->init_arg . '\'}', | ||||
| 409 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 410 | '$type_coercions[' . $idx . ']', | ||||
| 411 | '$type_constraint_messages[' . $idx . ']', | ||||
| 412 | 'for constructor', | ||||
| 413 | ); | ||||
| 414 | |||||
| 415 | 22 | 19µs | 22 | 24µs | push @initial_value, ( # spent 24µs making 22 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call |
| 416 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 417 | '$instance,', | ||||
| 418 | $attr->_inline_instance_get('$instance'), | ||||
| 419 | ');', | ||||
| 420 | ) if $attr->has_initializer; | ||||
| 421 | |||||
| 422 | 22 | 53µs | return @initial_value; | ||
| 423 | } | ||||
| 424 | |||||
| 425 | # spent 423µs (114+310) within Moose::Meta::Class::_inline_init_attr_from_default which was called 22 times, avg 19µs/call:
# 22 times (114µs+310µs) by Class::MOP::Class::_inline_slot_initializer at line 605 of Class/MOP/Class.pm, avg 19µs/call | ||||
| 426 | 22 | 3µs | my $self = shift; | ||
| 427 | 22 | 3µs | my ($attr, $idx) = @_; | ||
| 428 | |||||
| 429 | 22 | 82µs | 44 | 37µs | return if $attr->can('is_lazy') && $attr->is_lazy; # spent 24µs making 22 calls to Moose::Meta::Mixin::AttributeCore::is_lazy, avg 1µs/call
# spent 13µs making 22 calls to UNIVERSAL::can, avg 595ns/call |
| 430 | 3 | 6µs | 3 | 22µs | my $default = $self->_inline_default_value($attr, $idx); # spent 22µs making 3 calls to Class::MOP::Class::_inline_default_value, avg 7µs/call |
| 431 | 3 | 3µs | return unless $default; | ||
| 432 | |||||
| 433 | 1 | 4µs | 1 | 250µs | my @initial_value = ( # spent 250µs making 1 call to Moose::Meta::Attribute::_inline_set_value |
| 434 | 'my $default = ' . $default . ';', | ||||
| 435 | $attr->_inline_set_value( | ||||
| 436 | '$instance', | ||||
| 437 | '$default', | ||||
| 438 | '$type_constraint_bodies[' . $idx . ']', | ||||
| 439 | '$type_coercions[' . $idx . ']', | ||||
| 440 | '$type_constraint_messages[' . $idx . ']', | ||||
| 441 | 'for constructor', | ||||
| 442 | ), | ||||
| 443 | ); | ||||
| 444 | |||||
| 445 | 1 | 1µs | 1 | 1µs | push @initial_value, ( # spent 1µs making 1 call to Class::MOP::Mixin::AttributeCore::has_initializer |
| 446 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
| 447 | '$instance,', | ||||
| 448 | $attr->_inline_instance_get('$instance'), | ||||
| 449 | ');', | ||||
| 450 | ) if $attr->has_initializer; | ||||
| 451 | |||||
| 452 | 1 | 3µs | return @initial_value; | ||
| 453 | } | ||||
| 454 | |||||
| 455 | # spent 455µs (8+447) within Moose::Meta::Class::_inline_extra_init which was called:
# once (8µs+447µs) by Class::MOP::Class::_inline_new_object at line 537 of Class/MOP/Class.pm | ||||
| 456 | 1 | 300ns | my $self = shift; | ||
| 457 | return ( | ||||
| 458 | 1 | 4µs | 2 | 447µs | $self->_inline_triggers, # spent 344µs making 1 call to Moose::Meta::Class::_inline_triggers
# spent 103µs making 1 call to Moose::Meta::Class::_inline_BUILDALL |
| 459 | $self->_inline_BUILDALL, | ||||
| 460 | ); | ||||
| 461 | } | ||||
| 462 | |||||
| 463 | # spent 344µs (80+264) within Moose::Meta::Class::_inline_triggers which was called:
# once (80µs+264µs) by Moose::Meta::Class::_inline_extra_init at line 458 | ||||
| 464 | 1 | 200ns | my $self = shift; | ||
| 465 | 1 | 100ns | my @trigger_calls; | ||
| 466 | |||||
| 467 | 76 | 199µs | 152 | 278µs | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 203µs making 1 call to Moose::Meta::Class::CORE:sort
# spent 42µs making 150 calls to Class::MOP::Mixin::AttributeCore::name, avg 279ns/call
# spent 33µs making 1 call to Class::MOP::Class::get_all_attributes |
| 468 | 1 | 4µs | for my $i (0 .. $#attrs) { | ||
| 469 | 22 | 3µs | my $attr = $attrs[$i]; | ||
| 470 | |||||
| 471 | 22 | 54µs | 44 | 28µs | next unless $attr->can('has_trigger') && $attr->has_trigger; # spent 17µs making 22 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 755ns/call
# spent 11µs making 22 calls to UNIVERSAL::can, avg 509ns/call |
| 472 | |||||
| 473 | my $init_arg = $attr->init_arg; | ||||
| 474 | next unless defined $init_arg; | ||||
| 475 | |||||
| 476 | push @trigger_calls, | ||||
| 477 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
| 478 | '$triggers->[' . $i . ']->(', | ||||
| 479 | '$instance,', | ||||
| 480 | $attr->_inline_instance_get('$instance') . ',', | ||||
| 481 | ');', | ||||
| 482 | '}'; | ||||
| 483 | } | ||||
| 484 | |||||
| 485 | 1 | 4µs | return @trigger_calls; | ||
| 486 | } | ||||
| 487 | |||||
| 488 | # spent 103µs (11+92) within Moose::Meta::Class::_inline_BUILDALL which was called:
# once (11µs+92µs) by Moose::Meta::Class::_inline_extra_init at line 458 | ||||
| 489 | 1 | 300ns | my $self = shift; | ||
| 490 | |||||
| 491 | 1 | 4µs | 1 | 92µs | my @methods = reverse $self->find_all_methods_by_name('BUILD'); # spent 92µs making 1 call to Class::MOP::Class::find_all_methods_by_name |
| 492 | 1 | 200ns | my @BUILD_calls; | ||
| 493 | |||||
| 494 | 1 | 400ns | foreach my $method (@methods) { | ||
| 495 | 1 | 1µs | push @BUILD_calls, | ||
| 496 | '$instance->' . $method->{class} . '::BUILD($params);'; | ||||
| 497 | } | ||||
| 498 | |||||
| 499 | 1 | 4µs | return @BUILD_calls; | ||
| 500 | } | ||||
| 501 | |||||
| 502 | # spent 3.40ms (353µs+3.05) within Moose::Meta::Class::_eval_environment which was called:
# once (353µs+3.05ms) by Class::MOP::Method::Constructor::_eval_environment at line 89 of Class/MOP/Method/Constructor.pm | ||||
| 503 | 1 | 200ns | my $self = shift; | ||
| 504 | |||||
| 505 | 71 | 199µs | 142 | 274µs | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 203µs making 1 call to Moose::Meta::Class::CORE:sort
# spent 42µs making 140 calls to Class::MOP::Mixin::AttributeCore::name, avg 299ns/call
# spent 29µs making 1 call to Class::MOP::Class::get_all_attributes |
| 506 | |||||
| 507 | 22 | 47µs | 44 | 26µs | my $triggers = [ # spent 16µs making 22 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 736ns/call
# spent 9µs making 22 calls to UNIVERSAL::can, avg 427ns/call |
| 508 | 1 | 6µs | map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef } | ||
| 509 | @attrs | ||||
| 510 | ]; | ||||
| 511 | |||||
| 512 | # We need to check if the attribute ->can('type_constraint') | ||||
| 513 | # since we may be trying to immutabilize a Moose meta class, | ||||
| 514 | # which in turn has attributes which are Class::MOP::Attribute | ||||
| 515 | # objects, rather than Moose::Meta::Attribute. And | ||||
| 516 | # Class::MOP::Attribute attributes have no type constraints. | ||||
| 517 | # However we need to make sure we leave an undef value there | ||||
| 518 | # because the inlined code is using the index of the attributes | ||||
| 519 | # to determine where to find the type constraint | ||||
| 520 | |||||
| 521 | 22 | 47µs | 44 | 26µs | my @type_constraints = map { # spent 17µs making 22 calls to Moose::Meta::Mixin::AttributeCore::type_constraint, avg 782ns/call
# spent 9µs making 22 calls to UNIVERSAL::can, avg 418ns/call |
| 522 | 1 | 4µs | $_->can('type_constraint') ? $_->type_constraint : undef | ||
| 523 | } @attrs; | ||||
| 524 | |||||
| 525 | 22 | 14µs | 22 | 21µs | my @type_constraint_bodies = map { # spent 21µs making 22 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 945ns/call |
| 526 | 1 | 4µs | defined $_ ? $_->_compiled_type_constraint : undef; | ||
| 527 | } @type_constraints; | ||||
| 528 | |||||
| 529 | 22 | 14µs | 22 | 21µs | my @type_coercions = map { # spent 16µs making 21 calls to Moose::Meta::TypeConstraint::has_coercion, avg 752ns/call
# spent 5µs making 1 call to Moose::Meta::TypeConstraint::Union::has_coercion |
| 530 | 1 | 6µs | defined $_ && $_->has_coercion | ||
| 531 | ? $_->coercion->_compiled_type_coercion | ||||
| 532 | : undef | ||||
| 533 | } @type_constraints; | ||||
| 534 | |||||
| 535 | 22 | 26µs | 44 | 42µs | my @type_constraint_messages = map { # spent 24µs making 22 calls to Moose::Meta::TypeConstraint::_default_message, avg 1µs/call
# spent 18µs making 22 calls to Moose::Meta::TypeConstraint::has_message, avg 836ns/call |
| 536 | 1 | 8µs | defined $_ | ||
| 537 | ? ($_->has_message ? $_->message : $_->_default_message) | ||||
| 538 | : undef | ||||
| 539 | } @type_constraints; | ||||
| 540 | |||||
| 541 | return { | ||||
| 542 | %{ $self->SUPER::_eval_environment }, | ||||
| 543 | 44 | 36µs | 44 | 246µs | ((any { defined && $_->has_initializer } @attrs) # spent 146µs making 19 calls to Moose::Meta::TypeConstraint::inline_environment, avg 8µs/call
# spent 59µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 29µs/call
# spent 25µs making 1 call to Moose::Meta::TypeConstraint::Union::inline_environment
# spent 16µs making 22 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 745ns/call |
| 544 | ? ('$attrs' => \[@attrs]) | ||||
| 545 | : ()), | ||||
| 546 | '$triggers' => \$triggers, | ||||
| 547 | '@type_coercions' => \@type_coercions, | ||||
| 548 | '@type_constraint_bodies' => \@type_constraint_bodies, | ||||
| 549 | '@type_constraint_messages' => \@type_constraint_messages, | ||||
| 550 | 23 | 22µs | 2 | 2.45ms | ( map { defined($_) ? %{ $_->inline_environment } : () } # spent 2.40ms making 1 call to Class::MOP::Class::_eval_environment
# spent 58µs making 1 call to List::MoreUtils::any |
| 551 | @type_constraints ), | ||||
| 552 | # pretty sure this is only going to be closed over if you use a custom | ||||
| 553 | # error class at this point, but we should still get rid of this | ||||
| 554 | # at some point | ||||
| 555 | '$meta' => \$self, | ||||
| 556 | }; | ||||
| 557 | } | ||||
| 558 | |||||
| 559 | # spent 10.4ms (517µs+9.91) within Moose::Meta::Class::superclasses which was called 67 times, avg 156µs/call:
# 26 times (156µs+380µs) by Class::MOP::Class::_check_metaclass_compatibility at line 203 of Class/MOP/Class.pm, avg 21µs/call
# 13 times (70µs+-70µs) by Class::MOP::Class::_superclasses_updated at line 971 of Class/MOP/Class.pm, avg 0s/call
# 11 times (58µs+200µs) by Class::MOP::Class::class_precedence_list at line 1030 of Class/MOP/Class.pm, avg 24µs/call
# 8 times (142µs+6.52ms) by Class::MOP::Class::create at line 451 of Class/MOP/Class.pm, avg 832µs/call
# 8 times (79µs+2.36ms) by Moose::init_meta at line 221 of Moose.pm, avg 305µs/call
# once (13µs+515µs) by Moose::extends at line 62 of Moose.pm | ||||
| 560 | 67 | 7µs | my $self = shift; | ||
| 561 | 67 | 61µs | 67 | 548µs | my $supers = Data::OptList::mkopt(\@_); # spent 548µs making 67 calls to Data::OptList::mkopt, avg 8µs/call |
| 562 | 67 | 29µs | foreach my $super (@{ $supers }) { | ||
| 563 | 20 | 8µs | my ($name, $opts) = @{ $super }; | ||
| 564 | 20 | 17µs | 20 | 356µs | load_class($name, $opts); # spent 380µs making 20 calls to Class::Load::load_class, avg 19µs/call, recursion: max depth 1, sum of overlapping time 24µs |
| 565 | 20 | 18µs | 20 | 65µs | my $meta = Class::MOP::class_of($name); # spent 65µs making 20 calls to Class::MOP::class_of, avg 3µs/call |
| 566 | 20 | 69µs | 20 | 24µs | $self->throw_error("You cannot inherit from a Moose Role ($name)") # spent 24µs making 20 calls to UNIVERSAL::isa, avg 1µs/call |
| 567 | if $meta && $meta->isa('Moose::Meta::Role') | ||||
| 568 | } | ||||
| 569 | 67 | 209µs | 67 | 9.21ms | return $self->SUPER::superclasses(map { $_->[0] } @{ $supers }); # spent 9.50ms making 67 calls to Class::MOP::Class::superclasses, avg 142µs/call, recursion: max depth 1, sum of overlapping time 290µs |
| 570 | } | ||||
| 571 | |||||
| 572 | ### --------------------------------------------- | ||||
| 573 | |||||
| 574 | # spent 275ms (298µs+275) within Moose::Meta::Class::add_attribute which was called 28 times, avg 9.82ms/call:
# 19 times (186µs+206ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 10.9ms/call
# 9 times (111µs+68.2ms) by Moose::has at line 81 of Moose.pm, avg 7.59ms/call | ||||
| 575 | 28 | 4µs | my $self = shift; | ||
| 576 | 28 | 132µs | 56 | 9.26ms | my $attr = # spent 9.23ms making 9 calls to Moose::Meta::Class::_process_attribute, avg 1.03ms/call
# spent 17µs making 28 calls to Scalar::Util::blessed, avg 614ns/call
# spent 12µs making 19 calls to UNIVERSAL::isa, avg 605ns/call |
| 577 | (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute') | ||||
| 578 | ? $_[0] | ||||
| 579 | : $self->_process_attribute(@_)); | ||||
| 580 | 28 | 33µs | 28 | 265ms | $self->SUPER::add_attribute($attr); # spent 265ms making 28 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 9.47ms/call |
| 581 | # it may be a Class::MOP::Attribute, theoretically, which doesn't have | ||||
| 582 | # 'bare' and doesn't implement this method | ||||
| 583 | 28 | 92µs | 56 | 124µs | if ($attr->can('_check_associated_methods')) { # spent 98µs making 28 calls to Moose::Meta::Attribute::_check_associated_methods, avg 3µs/call
# spent 27µs making 28 calls to UNIVERSAL::can, avg 961ns/call |
| 584 | $attr->_check_associated_methods; | ||||
| 585 | } | ||||
| 586 | 28 | 42µs | return $attr; | ||
| 587 | } | ||||
| 588 | |||||
| 589 | # spent 3.20ms (141µs+3.06) within Moose::Meta::Class::add_override_method_modifier which was called 21 times, avg 152µs/call:
# 21 times (141µs+3.06ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 218 of Moose/Meta/Role/Application/ToClass.pm, avg 152µs/call | ||||
| 590 | 21 | 6µs | my ($self, $name, $method, $_super_package) = @_; | ||
| 591 | |||||
| 592 | 21 | 10µs | 21 | 298µs | (!$self->has_method($name)) # spent 298µs making 21 calls to Class::MOP::Mixin::HasMethods::has_method, avg 14µs/call |
| 593 | || $self->throw_error("Cannot add an override method if a local method is already present"); | ||||
| 594 | |||||
| 595 | 21 | 78µs | 42 | 2.76ms | $self->add_method($name => Moose::Meta::Method::Overridden->new( # spent 1.67ms making 21 calls to Moose::Meta::Method::Overridden::new, avg 80µs/call
# spent 1.09ms making 21 calls to Class::MOP::Mixin::HasMethods::add_method, avg 52µs/call |
| 596 | method => $method, | ||||
| 597 | class => $self, | ||||
| 598 | package => $_super_package, # need this for roles | ||||
| 599 | name => $name, | ||||
| 600 | )); | ||||
| 601 | } | ||||
| 602 | |||||
| 603 | sub add_augment_method_modifier { | ||||
| 604 | my ($self, $name, $method) = @_; | ||||
| 605 | (!$self->has_method($name)) | ||||
| 606 | || $self->throw_error("Cannot add an augment method if a local method is already present"); | ||||
| 607 | |||||
| 608 | $self->add_method($name => Moose::Meta::Method::Augmented->new( | ||||
| 609 | method => $method, | ||||
| 610 | class => $self, | ||||
| 611 | name => $name, | ||||
| 612 | )); | ||||
| 613 | } | ||||
| 614 | |||||
| 615 | ## Private Utility methods ... | ||||
| 616 | |||||
| 617 | sub _find_next_method_by_name_which_is_not_overridden { | ||||
| 618 | my ($self, $name) = @_; | ||||
| 619 | foreach my $method ($self->find_all_methods_by_name($name)) { | ||||
| 620 | return $method->{code} | ||||
| 621 | if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden'); | ||||
| 622 | } | ||||
| 623 | return undef; | ||||
| 624 | } | ||||
| 625 | |||||
| 626 | ## Metaclass compatibility | ||||
| 627 | |||||
| 628 | # spent 877µs (568+309) within Moose::Meta::Class::_base_metaclasses which was called 33 times, avg 27µs/call:
# 20 times (358µs+199µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333 of Class/MOP/Class.pm, avg 28µs/call
# 13 times (209µs+110µs) by Class::MOP::Class::_check_metaclass_compatibility at line 208 of Class/MOP/Class.pm, avg 25µs/call | ||||
| 629 | 33 | 4µs | my $self = shift; | ||
| 630 | 33 | 71µs | 33 | 62µs | my %metaclasses = $self->SUPER::_base_metaclasses; # spent 62µs making 33 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call |
| 631 | 33 | 31µs | for my $class (keys %metaclasses) { | ||
| 632 | 198 | 524µs | 198 | 247µs | $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/; # spent 247µs making 198 calls to Moose::Meta::Class::CORE:subst, avg 1µs/call |
| 633 | } | ||||
| 634 | return ( | ||||
| 635 | 33 | 122µs | %metaclasses, | ||
| 636 | error_class => 'Moose::Error::Default', | ||||
| 637 | ); | ||||
| 638 | } | ||||
| 639 | |||||
| 640 | sub _fix_class_metaclass_incompatibility { | ||||
| 641 | my $self = shift; | ||||
| 642 | my ($super_meta) = @_; | ||||
| 643 | |||||
| 644 | $self->SUPER::_fix_class_metaclass_incompatibility(@_); | ||||
| 645 | |||||
| 646 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
| 647 | ($self->is_pristine) | ||||
| 648 | || confess "Can't fix metaclass incompatibility for " | ||||
| 649 | . $self->name | ||||
| 650 | . " because it is not pristine."; | ||||
| 651 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 652 | my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name); | ||||
| 653 | my $new_self = $class_meta_subclass_meta_name->reinitialize( | ||||
| 654 | $self->name, | ||||
| 655 | ); | ||||
| 656 | |||||
| 657 | $self->_replace_self( $new_self, $class_meta_subclass_meta_name ); | ||||
| 658 | } | ||||
| 659 | } | ||||
| 660 | |||||
| 661 | sub _fix_single_metaclass_incompatibility { | ||||
| 662 | my $self = shift; | ||||
| 663 | my ($metaclass_type, $super_meta) = @_; | ||||
| 664 | |||||
| 665 | $self->SUPER::_fix_single_metaclass_incompatibility(@_); | ||||
| 666 | |||||
| 667 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
| 668 | ($self->is_pristine) | ||||
| 669 | || confess "Can't fix metaclass incompatibility for " | ||||
| 670 | . $self->name | ||||
| 671 | . " because it is not pristine."; | ||||
| 672 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
| 673 | my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type); | ||||
| 674 | my $new_self = $super_meta->reinitialize( | ||||
| 675 | $self->name, | ||||
| 676 | $metaclass_type => $class_specific_meta_subclass_meta_name, | ||||
| 677 | ); | ||||
| 678 | |||||
| 679 | $self->_replace_self( $new_self, $super_meta_name ); | ||||
| 680 | } | ||||
| 681 | } | ||||
| 682 | |||||
| 683 | sub _replace_self { | ||||
| 684 | my $self = shift; | ||||
| 685 | my ( $new_self, $new_class) = @_; | ||||
| 686 | |||||
| 687 | %$self = %$new_self; | ||||
| 688 | bless $self, $new_class; | ||||
| 689 | |||||
| 690 | # We need to replace the cached metaclass instance or else when it goes | ||||
| 691 | # out of scope Class::MOP::Class destroy's the namespace for the | ||||
| 692 | # metaclass's class, causing much havoc. | ||||
| 693 | my $weaken = Class::MOP::metaclass_is_weak( $self->name ); | ||||
| 694 | Class::MOP::store_metaclass_by_name( $self->name, $self ); | ||||
| 695 | Class::MOP::weaken_metaclass( $self->name ) if $weaken; | ||||
| 696 | } | ||||
| 697 | |||||
| 698 | # spent 9.23ms (60µs+9.17) within Moose::Meta::Class::_process_attribute which was called 9 times, avg 1.03ms/call:
# 9 times (60µs+9.17ms) by Moose::Meta::Class::add_attribute at line 576, avg 1.03ms/call | ||||
| 699 | 9 | 11µs | my ( $self, $name, @args ) = @_; | ||
| 700 | |||||
| 701 | 9 | 2µs | @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH'; | ||
| 702 | |||||
| 703 | 9 | 20µs | 9 | 4µs | if (($name || '') =~ /^\+(.*)/) { # spent 4µs making 9 calls to Moose::Meta::Class::CORE:match, avg 411ns/call |
| 704 | return $self->_process_inherited_attribute($1, @args); | ||||
| 705 | } | ||||
| 706 | else { | ||||
| 707 | 9 | 26µs | 9 | 9.17ms | return $self->_process_new_attribute($name, @args); # spent 9.17ms making 9 calls to Moose::Meta::Class::_process_new_attribute, avg 1.02ms/call |
| 708 | } | ||||
| 709 | } | ||||
| 710 | |||||
| 711 | # spent 9.17ms (60µs+9.11) within Moose::Meta::Class::_process_new_attribute which was called 9 times, avg 1.02ms/call:
# 9 times (60µs+9.11ms) by Moose::Meta::Class::_process_attribute at line 707, avg 1.02ms/call | ||||
| 712 | 9 | 12µs | my ( $self, $name, @args ) = @_; | ||
| 713 | |||||
| 714 | 9 | 48µs | 18 | 9.11ms | $self->attribute_metaclass->interpolate_class_and_new($name, @args); # spent 9.10ms making 9 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 1.01ms/call
# spent 6µs making 9 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 656ns/call |
| 715 | } | ||||
| 716 | |||||
| 717 | sub _process_inherited_attribute { | ||||
| 718 | my ($self, $attr_name, %options) = @_; | ||||
| 719 | my $inherited_attr = $self->find_attribute_by_name($attr_name); | ||||
| 720 | (defined $inherited_attr) | ||||
| 721 | || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name); | ||||
| 722 | if ($inherited_attr->isa('Moose::Meta::Attribute')) { | ||||
| 723 | return $inherited_attr->clone_and_inherit_options(%options); | ||||
| 724 | } | ||||
| 725 | else { | ||||
| 726 | # NOTE: | ||||
| 727 | # kind of a kludge to handle Class::MOP::Attributes | ||||
| 728 | return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options); | ||||
| 729 | } | ||||
| 730 | } | ||||
| 731 | |||||
| 732 | # reinitialization support | ||||
| 733 | |||||
| 734 | sub _restore_metaobjects_from { | ||||
| 735 | my $self = shift; | ||||
| 736 | my ($old_meta) = @_; | ||||
| 737 | |||||
| 738 | $self->SUPER::_restore_metaobjects_from($old_meta); | ||||
| 739 | |||||
| 740 | for my $role ( @{ $old_meta->roles } ) { | ||||
| 741 | $self->add_role($role); | ||||
| 742 | } | ||||
| 743 | |||||
| 744 | for my $application ( @{ $old_meta->_get_role_applications } ) { | ||||
| 745 | $application->class($self); | ||||
| 746 | $self->add_role_application ($application); | ||||
| 747 | } | ||||
| 748 | } | ||||
| 749 | |||||
| 750 | ## Immutability | ||||
| 751 | |||||
| 752 | # spent 41µs (7+34) within Moose::Meta::Class::_immutable_options which was called:
# once (7µs+34µs) by Class::MOP::Class::make_immutable at line 1287 of Class/MOP/Class.pm | ||||
| 753 | 1 | 400ns | my ( $self, @args ) = @_; | ||
| 754 | |||||
| 755 | 1 | 6µs | 1 | 34µs | $self->SUPER::_immutable_options( # spent 34µs making 1 call to Class::MOP::Class::_immutable_options |
| 756 | inline_destructor => 1, | ||||
| 757 | |||||
| 758 | # Moose always does this when an attribute is created | ||||
| 759 | inline_accessors => 0, | ||||
| 760 | |||||
| 761 | @args, | ||||
| 762 | ); | ||||
| 763 | } | ||||
| 764 | |||||
| 765 | sub _fixup_attributes_after_rebless { | ||||
| 766 | my $self = shift; | ||||
| 767 | my ($instance, $rebless_from, %params) = @_; | ||||
| 768 | |||||
| 769 | $self->SUPER::_fixup_attributes_after_rebless( | ||||
| 770 | $instance, | ||||
| 771 | $rebless_from, | ||||
| 772 | %params | ||||
| 773 | ); | ||||
| 774 | |||||
| 775 | $self->_call_all_triggers( $instance, \%params ); | ||||
| 776 | } | ||||
| 777 | |||||
| 778 | ## ------------------------------------------------- | ||||
| 779 | |||||
| 780 | 1 | 0s | our $error_level; | ||
| 781 | |||||
| 782 | sub throw_error { | ||||
| 783 | my ( $self, @args ) = @_; | ||||
| 784 | local $error_level = ($error_level || 0) + 1; | ||||
| 785 | $self->raise_error($self->create_error(@args)); | ||||
| 786 | } | ||||
| 787 | |||||
| 788 | # spent 16.9ms (692µs+16.2) within Moose::Meta::Class::_inline_throw_error which was called 148 times, avg 114µs/call:
# 147 times (687µs+16.2ms) by Moose::Meta::Attribute::_inline_throw_error at line 83 of Moose/Meta/Attribute.pm, avg 115µs/call
# once (5µs+55µs) by Moose::Meta::Class::_inline_BUILDARGS at line 337 | ||||
| 789 | 148 | 104µs | my ( $self, @args ) = @_; | ||
| 790 | 148 | 422µs | 296 | 16.2ms | $self->_inline_raise_error($self->_inline_create_error(@args)); # spent 16.0ms making 148 calls to Moose::Meta::Class::_inline_create_error, avg 108µs/call
# spent 200µs making 148 calls to Moose::Meta::Class::_inline_raise_error, avg 1µs/call |
| 791 | } | ||||
| 792 | |||||
| 793 | sub raise_error { | ||||
| 794 | my ( $self, @args ) = @_; | ||||
| 795 | die @args; | ||||
| 796 | } | ||||
| 797 | |||||
| 798 | # spent 200µs within Moose::Meta::Class::_inline_raise_error which was called 148 times, avg 1µs/call:
# 148 times (200µs+0s) by Moose::Meta::Class::_inline_throw_error at line 790, avg 1µs/call | ||||
| 799 | 148 | 34µs | my ( $self, $message ) = @_; | ||
| 800 | |||||
| 801 | 148 | 236µs | return 'die ' . $message; | ||
| 802 | } | ||||
| 803 | |||||
| 804 | sub create_error { | ||||
| 805 | my ( $self, @args ) = @_; | ||||
| 806 | |||||
| 807 | require Carp::Heavy; | ||||
| 808 | |||||
| 809 | local $error_level = ($error_level || 0 ) + 1; | ||||
| 810 | |||||
| 811 | if ( @args % 2 == 1 ) { | ||||
| 812 | unshift @args, "message"; | ||||
| 813 | } | ||||
| 814 | |||||
| 815 | my %args = ( metaclass => $self, last_error => $@, @args ); | ||||
| 816 | |||||
| 817 | $args{depth} += $error_level; | ||||
| 818 | |||||
| 819 | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; | ||||
| 820 | |||||
| 821 | load_class($class); | ||||
| 822 | |||||
| 823 | $class->new( | ||||
| 824 | Carp::caller_info($args{depth}), | ||||
| 825 | %args | ||||
| 826 | ); | ||||
| 827 | } | ||||
| 828 | |||||
| 829 | # spent 16.0ms (1.74+14.3) within Moose::Meta::Class::_inline_create_error which was called 148 times, avg 108µs/call:
# 148 times (1.74ms+14.3ms) by Moose::Meta::Class::_inline_throw_error at line 790, avg 108µs/call | ||||
| 830 | 148 | 32µs | my ( $self, $msg, $args ) = @_; | ||
| 831 | # XXX ignore $args for now, nothing currently uses it anyway | ||||
| 832 | |||||
| 833 | 148 | 42µs | require Carp::Heavy; | ||
| 834 | |||||
| 835 | 148 | 183µs | my %args = ( | ||
| 836 | metaclass => $self, | ||||
| 837 | last_error => $@, | ||||
| 838 | message => $msg, | ||||
| 839 | ); | ||||
| 840 | |||||
| 841 | 148 | 157µs | 146 | 182µs | my $class = ref $self ? $self->error_class : "Moose::Error::Default"; # spent 182µs making 146 calls to Moose::Meta::Class::error_class, avg 1µs/call |
| 842 | |||||
| 843 | 148 | 103µs | 148 | 10.8ms | load_class($class); # spent 10.9ms making 148 calls to Class::Load::load_class, avg 74µs/call, recursion: max depth 1, sum of overlapping time 82µs |
| 844 | |||||
| 845 | # don't check inheritance here - the intention is that the class needs | ||||
| 846 | # to provide a non-inherited inlining method, because falling back to | ||||
| 847 | # the default inlining method is most likely going to be wrong | ||||
| 848 | # yes, this is a huge hack, but so is the entire error system, so. | ||||
| 849 | return | ||||
| 850 | 148 | 282µs | 296 | 2.67ms | '$meta->create_error(' # spent 1.46ms making 148 calls to Class::MOP::Mixin::HasMethods::has_method, avg 10µs/call
# spent 1.22ms making 148 calls to Class::MOP::Object::meta, avg 8µs/call |
| 851 | . $msg | ||||
| 852 | . ( defined $args ? ', ' . $args : q{} ) . ');' | ||||
| 853 | unless $class->meta->has_method('_inline_new'); | ||||
| 854 | |||||
| 855 | 148 | 436µs | 148 | 539µs | $class->_inline_new( # spent 539µs making 148 calls to Moose::Error::Default::_inline_new, avg 4µs/call |
| 856 | # XXX ignore this for now too | ||||
| 857 | # Carp::caller_info($args{depth}), | ||||
| 858 | %args | ||||
| 859 | ); | ||||
| 860 | } | ||||
| 861 | |||||
| 862 | 1 | 10µs | 1; | ||
| 863 | |||||
| 864 | # ABSTRACT: The Moose metaclass | ||||
| 865 | |||||
| 866 | __END__ | ||||
# spent 4µs within Moose::Meta::Class::CORE:match which was called 9 times, avg 411ns/call:
# 9 times (4µs+0s) by Moose::Meta::Class::_process_attribute at line 703, avg 411ns/call | |||||
# spent 422µs (339+84) within Moose::Meta::Class::CORE:sort which was called 58 times, avg 7µs/call:
# 56 times (16µs+0s) by Moose::Meta::Class::_anon_cache_key at line 163, avg 282ns/call
# once (162µs+42µs) by Moose::Meta::Class::_eval_environment at line 505
# once (161µs+42µs) by Moose::Meta::Class::_inline_triggers at line 467 | |||||
# spent 247µs within Moose::Meta::Class::CORE:subst which was called 198 times, avg 1µs/call:
# 198 times (247µs+0s) by Moose::Meta::Class::_base_metaclasses at line 632, avg 1µs/call |