← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:59 2015

Filename/Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Class.pm
StatementsExecuted 58695 statements in 128ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2896211213.9ms50.0msClass::MOP::Class::::initializeClass::MOP::Class::initialize (recurses: max depth 2, inclusive time 990µs)
3958411.2ms21.8msClass::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
2712111.0ms59.8msClass::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
92216.93ms8.83msClass::MOP::Class::::CORE:sortClass::MOP::Class::CORE:sort (opcode)
469226.00ms73.9msClass::MOP::Class::::_inline_slot_initializerClass::MOP::Class::_inline_slot_initializer
390115.64ms10.7msClass::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
320114.15ms343msClass::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
679423.45ms5.34msClass::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
136553.41ms20.5msClass::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
237113.05ms35.3msClass::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
271112.66ms13.3msClass::MOP::Class::::_inline_init_attr_from_constructorClass::MOP::Class::_inline_init_attr_from_constructor
322212.65ms3.23msClass::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
405222.59ms3.94msClass::MOP::Class::::_inline_default_valueClass::MOP::Class::_inline_default_value
253552.25ms51.5msClass::MOP::Class::::new_objectClass::MOP::Class::new_object
104212.16ms30.1msClass::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 331µs)
65112.10ms15.8msClass::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
84112.07ms32.8msClass::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 421µs)
105222.04ms9.51msClass::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
9881152.03ms37.4msClass::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
1112.00ms9.26msClass::MOP::Class::::BEGIN@9Class::MOP::Class::BEGIN@9
282211.84ms7.51msClass::MOP::Class::::_inline_init_attr_from_defaultClass::MOP::Class::_inline_init_attr_from_default
46111.76ms188msClass::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
108111.75ms2.85msClass::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
46111.71ms87.2msClass::MOP::Class::::_inline_slot_initializersClass::MOP::Class::_inline_slot_initializers
70111.71ms39.8msClass::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 227µs)
7022201.70ms301msClass::MOP::Class::::make_immutableClass::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 464µs)
46221.69ms9.81msClass::MOP::Class::::_eval_environmentClass::MOP::Class::_eval_environment
1111.67ms1.86msClass::MOP::Class::::BEGIN@8Class::MOP::Class::BEGIN@8
320111.49ms5.02msClass::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
1111.40ms1.53msClass::MOP::Class::::BEGIN@7Class::MOP::Class::BEGIN@7
70221.22ms1.58msClass::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
70111.13ms3.43msClass::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
70111.07ms257msClass::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
280411.05ms3.19msClass::MOP::Class::::_method_lookup_orderClass::MOP::Class::_method_lookup_order
1111.04ms2.24msClass::MOP::Class::::BEGIN@10Class::MOP::Class::BEGIN@10
70111.01ms256msClass::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
6611992µs992µsClass::MOP::Class::::_newClass::MOP::Class::_new
4421949µs13.7msClass::MOP::Class::::__ANON__[:1082]Class::MOP::Class::__ANON__[:1082]
7011914µs40.7msClass::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 284µs)
5411895µs17.4msClass::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 198µs)
3222835µs4.23msClass::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
4611834µs100msClass::MOP::Class::::_inline_new_objectClass::MOP::Class::_inline_new_object
1611790µs13.7msClass::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
3311605µs52.7msClass::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
32211582µs582µsClass::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
9441533µs897µsClass::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
6511516µs2.05msClass::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
11932479µs479µsClass::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
711448µs4.96msClass::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
10811439µs3.29msClass::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
111422µs525µsClass::MOP::Class::::BEGIN@11Class::MOP::Class::BEGIN@11
4611405µs571µsClass::MOP::Class::::_inline_fallback_constructorClass::MOP::Class::_inline_fallback_constructor
4311386µs14.7msClass::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
4611328µs1.87msClass::MOP::Class::::_inline_create_instanceClass::MOP::Class::_inline_create_instance
4611318µs626µsClass::MOP::Class::::_inline_preserve_weak_metaclassesClass::MOP::Class::_inline_preserve_weak_metaclasses
2011284µs1.09msClass::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
4611280µs2.15msClass::MOP::Class::::_inline_generate_instanceClass::MOP::Class::_inline_generate_instance
6221250µs250µsClass::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
1811189µs370µsClass::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
822136µs459µsClass::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list (recurses: max depth 1, inclusive time 152µs)
211133µs433µsClass::MOP::Class::::remove_attributeClass::MOP::Class::remove_attribute
10343122µs122µsClass::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
1811102µs472µsClass::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
21198µs2.96msClass::MOP::Class::::createClass::MOP::Class::create
301196µs96µsClass::MOP::Class::::_inline_paramsClass::MOP::Class::_inline_params
711185µs85µsClass::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
301177µs77µsClass::MOP::Class::::_generate_fallback_constructorClass::MOP::Class::_generate_fallback_constructor
201171µs71µsClass::MOP::Class::::_superclass_metasClass::MOP::Class::_superclass_metas
201150µs50µsClass::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
301136µs36µsClass::MOP::Class::::_inline_extra_initClass::MOP::Class::_inline_extra_init
11136µs178µsClass::MOP::Class::::BEGIN@18Class::MOP::Class::BEGIN@18
11116µs37µsClass::MOP::Class::::BEGIN@4Class::MOP::Class::BEGIN@4
11114µs488µsClass::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
11114µs5.01msClass::MOP::Class::::BEGIN@20Class::MOP::Class::BEGIN@20
11114µs44µsClass::MOP::Class::::BEGIN@16Class::MOP::Class::BEGIN@16
11113µs58µsClass::MOP::Class::::BEGIN@17Class::MOP::Class::BEGIN@17
11113µs50µsClass::MOP::Class::::BEGIN@13Class::MOP::Class::BEGIN@13
11112µs28µsClass::MOP::Class::::BEGIN@14Class::MOP::Class::BEGIN@14
11111µs42µsClass::MOP::Class::::BEGIN@15Class::MOP::Class::BEGIN@15
11111µs19µsClass::MOP::Class::::BEGIN@5Class::MOP::Class::BEGIN@5
0000s0sClass::MOP::Class::::__ANON__[:210]Class::MOP::Class::__ANON__[:210]
0000s0sClass::MOP::Class::::__ANON__[:900]Class::MOP::Class::__ANON__[:900]
0000s0sClass::MOP::Class::::__ANON__[:904]Class::MOP::Class::__ANON__[:904]
0000s0sClass::MOP::Class::::_anon_cache_keyClass::MOP::Class::_anon_cache_key
0000s0sClass::MOP::Class::::_anon_package_prefixClass::MOP::Class::_anon_package_prefix
0000s0sClass::MOP::Class::::_clone_instanceClass::MOP::Class::_clone_instance
0000s0sClass::MOP::Class::::_fix_class_metaclass_incompatibilityClass::MOP::Class::_fix_class_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fix_single_metaclass_incompatibilityClass::MOP::Class::_fix_single_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fixup_attributes_after_reblessClass::MOP::Class::_fixup_attributes_after_rebless
0000s0sClass::MOP::Class::::_force_rebless_instanceClass::MOP::Class::_force_rebless_instance
0000s0sClass::MOP::Class::::_inline_clear_mop_slotClass::MOP::Class::_inline_clear_mop_slot
0000s0sClass::MOP::Class::::_inline_get_mop_slotClass::MOP::Class::_inline_get_mop_slot
0000s0sClass::MOP::Class::::_inline_rebless_instanceClass::MOP::Class::_inline_rebless_instance
0000s0sClass::MOP::Class::::_inline_set_mop_slotClass::MOP::Class::_inline_set_mop_slot
0000s0sClass::MOP::Class::::_inlined_methodsClass::MOP::Class::_inlined_methods
0000s0sClass::MOP::Class::::_rebless_as_mutableClass::MOP::Class::_rebless_as_mutable
0000s0sClass::MOP::Class::::_remove_generated_metaobjectsClass::MOP::Class::_remove_generated_metaobjects
0000s0sClass::MOP::Class::::_remove_inlined_codeClass::MOP::Class::_remove_inlined_code
0000s0sClass::MOP::Class::::_restore_metaobjects_fromClass::MOP::Class::_restore_metaobjects_from
0000s0sClass::MOP::Class::::add_after_method_modifierClass::MOP::Class::add_after_method_modifier
0000s0sClass::MOP::Class::::add_dependent_meta_instanceClass::MOP::Class::add_dependent_meta_instance
0000s0sClass::MOP::Class::::add_meta_instance_dependenciesClass::MOP::Class::add_meta_instance_dependencies
0000s0sClass::MOP::Class::::clone_objectClass::MOP::Class::clone_object
0000s0sClass::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
0000s0sClass::MOP::Class::::direct_subclassesClass::MOP::Class::direct_subclasses
0000s0sClass::MOP::Class::::get_all_method_namesClass::MOP::Class::get_all_method_names
0000s0sClass::MOP::Class::::immutable_optionsClass::MOP::Class::immutable_options
0000s0sClass::MOP::Class::::is_anon_classClass::MOP::Class::is_anon_class
0000s0sClass::MOP::Class::::is_pristineClass::MOP::Class::is_pristine
0000s0sClass::MOP::Class::::make_mutableClass::MOP::Class::make_mutable
0000s0sClass::MOP::Class::::rebless_instanceClass::MOP::Class::rebless_instance
0000s0sClass::MOP::Class::::rebless_instance_awayClass::MOP::Class::rebless_instance_away
0000s0sClass::MOP::Class::::rebless_instance_backClass::MOP::Class::rebless_instance_back
0000s0sClass::MOP::Class::::reinitializeClass::MOP::Class::reinitialize
0000s0sClass::MOP::Class::::remove_dependent_meta_instanceClass::MOP::Class::remove_dependent_meta_instance
0000s0sClass::MOP::Class::::remove_meta_instance_dependenciesClass::MOP::Class::remove_meta_instance_dependencies
0000s0sClass::MOP::Class::::subclassesClass::MOP::Class::subclasses
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::MOP::Class;
212µsour $VERSION = '2.1403';
3
4228µs258µs
# spent 37µs (16+21) within Class::MOP::Class::BEGIN@4 which was called: # once (16µs+21µs) by Class::MOP::BEGIN@18 at line 4
use strict;
# spent 37µs making 1 call to Class::MOP::Class::BEGIN@4 # spent 21µs making 1 call to strict::import
5233µs227µs
# spent 19µs (11+8) within Class::MOP::Class::BEGIN@5 which was called: # once (11µs+8µs) by Class::MOP::BEGIN@18 at line 5
use warnings;
# spent 19µs making 1 call to Class::MOP::Class::BEGIN@5 # spent 8µs making 1 call to warnings::import
6
72129µs11.53ms
# spent 1.53ms (1.40+130µs) within Class::MOP::Class::BEGIN@7 which was called: # once (1.40ms+130µs) by Class::MOP::BEGIN@18 at line 7
use Class::MOP::Instance;
# spent 1.53ms making 1 call to Class::MOP::Class::BEGIN@7
82179µs11.86ms
# spent 1.86ms (1.67+185µs) within Class::MOP::Class::BEGIN@8 which was called: # once (1.67ms+185µs) by Class::MOP::BEGIN@18 at line 8
use Class::MOP::Method::Wrapped;
# spent 1.86ms making 1 call to Class::MOP::Class::BEGIN@8
92188µs19.26ms
# spent 9.26ms (2.00+7.26) within Class::MOP::Class::BEGIN@9 which was called: # once (2.00ms+7.26ms) by Class::MOP::BEGIN@18 at line 9
use Class::MOP::Method::Accessor;
# spent 9.26ms making 1 call to Class::MOP::Class::BEGIN@9
102201µs12.24ms
# spent 2.24ms (1.04+1.19) within Class::MOP::Class::BEGIN@10 which was called: # once (1.04ms+1.19ms) by Class::MOP::BEGIN@18 at line 10
use Class::MOP::Method::Constructor;
# spent 2.24ms making 1 call to Class::MOP::Class::BEGIN@10
112164µs1525µs
# spent 525µs (422+103) within Class::MOP::Class::BEGIN@11 which was called: # once (422µs+103µs) by Class::MOP::BEGIN@18 at line 11
use Class::MOP::MiniTrait;
# spent 525µs making 1 call to Class::MOP::Class::BEGIN@11
12
13240µs288µs
# spent 50µs (13+37) within Class::MOP::Class::BEGIN@13 which was called: # once (13µs+37µs) by Class::MOP::BEGIN@18 at line 13
use Carp 'confess';
# spent 50µs making 1 call to Class::MOP::Class::BEGIN@13 # spent 37µs making 1 call to Exporter::import
14236µs245µs
# spent 28µs (12+17) within Class::MOP::Class::BEGIN@14 which was called: # once (12µs+17µs) by Class::MOP::BEGIN@18 at line 14
use Module::Runtime 'use_package_optimistically';
# spent 28µs making 1 call to Class::MOP::Class::BEGIN@14 # spent 17µs making 1 call to Module::Runtime::import
15237µs273µs
# spent 42µs (11+31) within Class::MOP::Class::BEGIN@15 which was called: # once (11µs+31µs) by Class::MOP::BEGIN@18 at line 15
use Scalar::Util 'blessed';
# spent 42µs making 1 call to Class::MOP::Class::BEGIN@15 # spent 31µs making 1 call to Exporter::import
16240µs275µs
# spent 44µs (14+31) within Class::MOP::Class::BEGIN@16 which was called: # once (14µs+31µs) by Class::MOP::BEGIN@18 at line 16
use Sub::Name 'subname';
# spent 44µs making 1 call to Class::MOP::Class::BEGIN@16 # spent 30µs making 1 call to Exporter::import
17245µs2102µs
# spent 58µs (13+44) within Class::MOP::Class::BEGIN@17 which was called: # once (13µs+44µs) by Class::MOP::BEGIN@18 at line 17
use Try::Tiny;
# spent 58µs making 1 call to Class::MOP::Class::BEGIN@17 # spent 44µs making 1 call to Exporter::import
18392µs3216µs
# spent 178µs (36+142) within Class::MOP::Class::BEGIN@18 which was called: # once (36µs+142µs) by Class::MOP::BEGIN@18 at line 18
use List::Util 1.33 'all';
# spent 178µs making 1 call to Class::MOP::Class::BEGIN@18 # spent 22µs making 1 call to UNIVERSAL::VERSION # spent 16µs making 1 call to List::Util::import
19
201600ns
# spent 5.01ms (14µs+4.99) within Class::MOP::Class::BEGIN@20 which was called: # once (14µs+4.99ms) by Class::MOP::BEGIN@18 at line 23
use parent 'Class::MOP::Module',
21 'Class::MOP::Mixin::HasAttributes',
22 'Class::MOP::Mixin::HasMethods',
2318.81ms210.0ms 'Class::MOP::Mixin::HasOverloads';
# spent 5.01ms making 1 call to Class::MOP::Class::BEGIN@20 # spent 4.99ms making 1 call to parent::import
24
25# Creation
26
27
# spent 50.0ms (13.9+36.1) within Class::MOP::Class::initialize which was called 2896 times, avg 17µs/call: # 1185 times (5.16ms+1.17ms) by Class::MOP::Class::get_all_attributes at line 936, avg 5µs/call # 445 times (2.28ms+4.13ms) by Bio::Roary::AnalyseGroups::meta or Bio::Roary::AnnotateGroups::meta or Bio::Roary::CommandLine::RoaryPostAnalysis::meta or Bio::Roary::ContigsToGeneIDsFromGFF::meta or Bio::Roary::External::ProteinMuscleAlignmentFromNucleotides::meta or Bio::Roary::GeneNamesFromGFF::meta or Bio::Roary::GroupLabels::meta or Bio::Roary::GroupStatistics::meta or Bio::Roary::InflateClusters::meta or Bio::Roary::OrderGenes::meta or Bio::Roary::Output::EmblGroups::meta or Bio::Roary::Output::GroupsMultifastaNucleotide::meta or Bio::Roary::Output::GroupsMultifastasNucleotide::meta or Bio::Roary::Output::NumberOfGroups::meta or Bio::Roary::PostAnalysis::meta or Bio::Roary::SplitGroups::meta or Class::MOP::Mixin::meta or Class::MOP::Object::meta or Moose::Meta::Role::Application::RoleSummation::meta or Moose::Meta::Role::Application::ToClass::meta or Moose::Meta::Role::Application::ToInstance::meta or Moose::Meta::Role::Application::ToRole::meta or Moose::Meta::Role::Application::meta or Moose::Meta::Role::Composite::meta or Moose::Meta::Role::Method::Required::meta or Moose::Meta::Role::meta or Moose::Meta::TypeCoercion::Union::meta or Moose::Meta::TypeCoercion::meta or Moose::Meta::TypeConstraint::Class::meta or Moose::Meta::TypeConstraint::DuckType::meta or Moose::Meta::TypeConstraint::Enum::meta or Moose::Meta::TypeConstraint::Parameterizable::meta or Moose::Meta::TypeConstraint::Parameterized::meta or Moose::Meta::TypeConstraint::Registry::meta or Moose::Meta::TypeConstraint::Role::meta or Moose::Meta::TypeConstraint::Union::meta or Moose::Meta::TypeConstraint::meta at line 42 of Class/MOP/Method/Meta.pm, avg 14µs/call # 439 times (2.07ms+664µs) by Class::MOP::Class::find_method_by_name at line 1133, avg 6µs/call # 207 times (912µs+842µs) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 8µs/call # 182 times (904µs+233µs) by Class::MOP::Class::find_next_method_by_name at line 1181, avg 6µs/call # 98 times (404µs+118µs) by Class::MOP::Class::find_all_methods_by_name at line 1164, avg 5µs/call # 70 times (357µs+85µs) by Class::MOP::Class::find_attribute_by_name at line 926, avg 6µs/call # 65 times (329µs+-203µs) by Class::MOP::Class::_fix_metaclass_incompatibility at line 291, avg 2µs/call # 59 times (479µs+9.36ms) by Class::MOP::Mixin::meta at line 12 of Class/MOP/Mixin.pm, avg 167µs/call # 24 times (104µs+975µs) by Class::MOP::Method::_new at line 55 of Class/MOP/Method.pm, avg 45µs/call # 20 times (79µs+37µs) by Moose::Meta::Method::_new at line 7 of (eval 25)[Eval/Closure.pm:125], avg 6µs/call # 19 times (169µs+1.64ms) by metaclass::import at line 38 of metaclass.pm, avg 95µs/call # 18 times (204µs+13.6ms) by Moose::Meta::Class::initialize at line 64 of Moose/Meta/Class.pm, avg 767µs/call # 15 times (83µs+21µs) by Class::MOP::Class::get_all_methods at line 1144, avg 7µs/call # 12 times (118µs+2.64ms) by Class::MOP::MiniTrait::apply at line 14 of Class/MOP/MiniTrait.pm, avg 230µs/call # 12 times (59µs+12µs) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 6µs/call # 12 times (51µs+17µs) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 6µs/call # 7 times (50µs+519µs) by Moose::BEGIN@43 at line 12 of Moose/Meta/Attribute/Native.pm, avg 81µs/call # 4 times (20µs+8µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 7µs/call # 2 times (22µs+249µs) by Class::MOP::Package::create at line 67 of Class/MOP/Package.pm, avg 135µs/call # once (4µs+1µs) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm
sub initialize {
282896870µs my $class = shift;
29
302896289µs my $package_name;
31
3228961.53ms if ( @_ % 2 ) {
33 $package_name = shift;
34 } else {
35 my %options = @_;
36 $package_name = $options{package};
37 }
38
392896527µs ($package_name && !ref($package_name))
40 || ($class||__PACKAGE__)->_throw_exception( InitializeTakesUnBlessedPackageName => package_name => $package_name );
4128968.69ms298036.7ms return Class::MOP::get_metaclass_by_name($package_name)
# spent 33.3ms making 84 calls to Class::MOP::Class::_construct_class_instance, avg 396µs/call, recursion: max depth 1, sum of overlapping time 421µs # spent 3.85ms making 2896 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call
42 || $class->_construct_class_instance(package => $package_name, @_);
43}
44
45sub reinitialize {
46 my ( $class, @args ) = @_;
47 unshift @args, "package" if @args % 2;
48 my %options = @args;
49 my $old_metaclass = blessed($options{package})
50 ? $options{package}
51 : Class::MOP::get_metaclass_by_name($options{package});
52 $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name)
53 if !exists $options{weaken}
54 && blessed($old_metaclass)
55 && $old_metaclass->isa('Class::MOP::Class');
56 $old_metaclass->_remove_generated_metaobjects
57 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
58 my $new_metaclass = $class->SUPER::reinitialize(%options);
59 $new_metaclass->_restore_metaobjects_from($old_metaclass)
60 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
61 return $new_metaclass;
62}
63
64# NOTE: (meta-circularity)
65# this is a special form of _construct_instance
66# (see below), which is used to construct class
67# meta-object instances for any Class::MOP::*
68# class. All other classes will use the more
69# normal &construct_instance.
70
# spent 32.8ms (2.07+30.8) within Class::MOP::Class::_construct_class_instance which was called 84 times, avg 391µs/call: # 84 times (2.07ms+30.8ms) by Class::MOP::Class::initialize at line 41, avg 391µs/call
sub _construct_class_instance {
718442µs my $class = shift;
7284189µs my $options = @_ == 1 ? $_[0] : {@_};
738451µs my $package_name = $options->{package};
748419µs (defined $package_name && $package_name)
75 || $class->_throw_exception("ConstructClassInstanceTakesPackageName");
76 # NOTE:
77 # return the metaclass if we have it cached,
78 # and it is still defined (it has not been
79 # reaped by DESTROY yet, which can happen
80 # annoyingly enough during global destruction)
81
8284114µs8490µs if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) {
# spent 90µs making 84 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call
83 return $meta;
84 }
85
86 $class
878445µs9152µs = ref $class
# spent 152µs making 9 calls to Class::MOP::Class::_real_ref_name, avg 17µs/call
88 ? $class->_real_ref_name
89 : $class;
90
91 # now create the metaclass
928414µs my $meta;
9384240µs66992µs if ($class eq 'Class::MOP::Class') {
# spent 992µs making 66 calls to Class::MOP::Class::_new, avg 15µs/call
94 $meta = $class->_new($options);
95 }
96 else {
97 # NOTE:
98 # it is safe to use meta here because
99 # class will always be a subclass of
100 # Class::MOP::Class, which defines meta
10118103µs3611.3ms $meta = $class->meta->_construct_instance($options)
# spent 11.1ms making 18 calls to Class::MOP::Class::_construct_instance, avg 616µs/call # spent 249µs making 18 calls to Class::MOP::Object::meta, avg 14µs/call
102 }
103
104 # and check the metaclass compatibility
10584320µs8418.1ms $meta->_check_metaclass_compatibility();
# spent 18.4ms making 84 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 219µs/call, recursion: max depth 1, sum of overlapping time 331µs
106
10784164µs84242µs Class::MOP::store_metaclass_by_name($package_name, $meta);
# spent 242µs making 84 calls to Class::MOP::store_metaclass_by_name, avg 3µs/call
108
109 # NOTE:
110 # we need to weaken any anon classes
111 # so that they can call DESTROY properly
1128443µs Class::MOP::weaken_metaclass($package_name) if $options->{weaken};
113
11484322µs $meta;
115}
116
117
# spent 897µs (533+364) within Class::MOP::Class::_real_ref_name which was called 94 times, avg 10µs/call: # 65 times (397µs+244µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 336, avg 10µs/call # 18 times (64µs+13µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 250, avg 4µs/call # 9 times (58µs+95µs) by Class::MOP::Class::_construct_class_instance at line 87, avg 17µs/call # 2 times (15µs+12µs) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 14µs/call
sub _real_ref_name {
1189425µs my $self = shift;
119
120 # NOTE: we need to deal with the possibility of class immutability here,
121 # and then get the name of the class appropriately
12294436µs117364µs return $self->is_immutable
# spent 218µs making 23 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 10µs/call # spent 85µs making 71 calls to Class::MOP::Class::is_immutable, avg 1µs/call # spent 61µs making 23 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 3µs/call
123 ? $self->_get_mutable_metaclass_name()
124 : ref $self;
125}
126
127
# spent 992µs within Class::MOP::Class::_new which was called 66 times, avg 15µs/call: # 66 times (992µs+0s) by Class::MOP::Class::_construct_class_instance at line 93, avg 15µs/call
sub _new {
1286627µs my $class = shift;
129
1306623µs return Class::MOP::Class->initialize($class)->new_object(@_)
131 if $class ne __PACKAGE__;
132
1336636µs my $options = @_ == 1 ? $_[0] : {@_};
134
13566954µs return bless {
136 # inherited from Class::MOP::Package
137 'package' => $options->{package},
138
139 # NOTE:
140 # since the following attributes will
141 # actually be loaded from the symbol
142 # table, and actually bypass the instance
143 # entirely, we can just leave these things
144 # listed here for reference, because they
145 # should not actually have a value associated
146 # with the slot.
147 'namespace' => \undef,
148 'methods' => {},
149
150 # inherited from Class::MOP::Module
151 'version' => \undef,
152 'authority' => \undef,
153
154 # defined in Class::MOP::Class
155 'superclasses' => \undef,
156
157 'attributes' => {},
158 'attribute_metaclass' =>
159 ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ),
160 'method_metaclass' =>
161 ( $options->{'method_metaclass'} || 'Class::MOP::Method' ),
162 'wrapped_method_metaclass' => (
163 $options->{'wrapped_method_metaclass'}
164 || 'Class::MOP::Method::Wrapped'
165 ),
166 'instance_metaclass' =>
167 ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ),
168 'immutable_trait' => (
169 $options->{'immutable_trait'}
170 || 'Class::MOP::Class::Immutable::Trait'
171 ),
172 'constructor_name' => ( $options->{constructor_name} || 'new' ),
173 'constructor_class' => (
174 $options->{constructor_class} || 'Class::MOP::Method::Constructor'
175 ),
176 'destructor_class' => $options->{destructor_class},
177 }, $class;
178}
179
180## Metaclass compatibility
181{
18228µs my %base_metaclass = (
183 attribute_metaclass => 'Class::MOP::Attribute',
184 method_metaclass => 'Class::MOP::Method',
185 wrapped_method_metaclass => 'Class::MOP::Method::Wrapped',
186 instance_metaclass => 'Class::MOP::Instance',
187 constructor_class => 'Class::MOP::Method::Constructor',
188 destructor_class => 'Class::MOP::Method::Destructor',
189 );
190
191119594µs
# spent 479µs within Class::MOP::Class::_base_metaclasses which was called 119 times, avg 4µs/call: # 47 times (224µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324, avg 5µs/call # 36 times (131µs+0s) by Moose::Meta::Class::_base_metaclasses at line 628 of Moose/Meta/Class.pm, avg 4µs/call # 36 times (123µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 202, avg 3µs/call
sub _base_metaclasses { %base_metaclass }
192}
193
194
# spent 30.1ms (2.16+28.0) within Class::MOP::Class::_check_metaclass_compatibility which was called 104 times, avg 290µs/call: # 84 times (1.05ms+17.0ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 215µs/call # 20 times (1.11ms+11.0ms) by Class::MOP::Class::superclasses at line 966, avg 603µs/call
sub _check_metaclass_compatibility {
19510436µs my $self = shift;
196
197104378µs1044.47ms my @superclasses = $self->superclasses
# spent 3.02ms making 68 calls to Class::MOP::Class::superclasses, avg 44µs/call, recursion: max depth 1, sum of overlapping time 36µs # spent 2.14ms making 36 calls to Moose::Meta::Class::superclasses, avg 59µs/call, recursion: max depth 2, sum of overlapping time 656µs
198 or return;
199
20054130µs5417.4ms $self->_fix_metaclass_incompatibility(@superclasses);
# spent 17.6ms making 54 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 325µs/call, recursion: max depth 1, sum of overlapping time 198µs
201
20254191µs54739µs my %base_metaclass = $self->_base_metaclasses;
# spent 616µs making 18 calls to Moose::Meta::Class::_base_metaclasses, avg 34µs/call # spent 123µs making 36 calls to Class::MOP::Class::_base_metaclasses, avg 3µs/call
203
204 # this is always okay ...
205 return
206 if ref($self) eq 'Class::MOP::Class'
207 && all {
208216687µs216158µs my $meta = $self->$_;
# spent 31µs making 36 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 850ns/call # spent 29µs making 36 calls to Class::MOP::Class::instance_metaclass, avg 806ns/call # spent 26µs making 36 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 714ns/call # spent 25µs making 36 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 697ns/call # spent 24µs making 36 calls to Class::MOP::Class::constructor_class, avg 681ns/call # spent 23µs making 36 calls to Class::MOP::Class::destructor_class, avg 639ns/call
209216335µs !defined($meta) || $meta eq $base_metaclass{$_};
210 }
21154296µs36966µs keys %base_metaclass;
# spent 966µs making 36 calls to List::Util::all, avg 27µs/call
212
2131815µs for my $superclass (@superclasses) {
2141855µs18472µs $self->_check_class_metaclass_compatibility($superclass);
# spent 472µs making 18 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 26µs/call
215 }
216
2171883µs for my $metaclass_type ( keys %base_metaclass ) {
218108262µs108110µs next unless defined $self->$metaclass_type;
# spent 31µs making 18 calls to Moose::Meta::Class::constructor_class, avg 2µs/call # spent 28µs making 18 calls to Moose::Meta::Class::destructor_class, avg 2µs/call # spent 14µs making 18 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 750ns/call # spent 13µs making 18 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 722ns/call # spent 12µs making 18 calls to Class::MOP::Class::instance_metaclass, avg 689ns/call # spent 12µs making 18 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 667ns/call
21910873µs for my $superclass (@superclasses) {
220108211µs1083.29ms $self->_check_single_metaclass_compatibility( $metaclass_type,
# spent 3.29ms making 108 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 30µs/call
221 $superclass );
222 }
223 }
224}
225
226
# spent 472µs (102+370) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 18 times, avg 26µs/call: # 18 times (102µs+370µs) by Class::MOP::Class::_check_metaclass_compatibility at line 214, avg 26µs/call
sub _check_class_metaclass_compatibility {
227188µs my $self = shift;
2281814µs my ( $superclass_name ) = @_;
229
2301864µs18370µs if (!$self->_class_metaclass_is_compatible($superclass_name)) {
# spent 370µs making 18 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 21µs/call
231 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
232
233 my $super_meta_type = $super_meta->_real_ref_name;
234
235 $self->_throw_exception( IncompatibleMetaclassOfSuperclass => class_name => $self->name,
236 class_meta_type => ref( $self ),
237 superclass_name => $superclass_name,
238 superclass_meta_type => $super_meta_type
239 );
240 }
241}
242
243
# spent 370µs (189+181) within Class::MOP::Class::_class_metaclass_is_compatible which was called 18 times, avg 21µs/call: # 18 times (189µs+181µs) by Class::MOP::Class::_check_class_metaclass_compatibility at line 230, avg 21µs/call
sub _class_metaclass_is_compatible {
244188µs my $self = shift;
2451811µs my ( $superclass_name ) = @_;
246
2471823µs1822µs my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 22µs making 18 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call
248 || return 1;
249
2501832µs1877µs my $super_meta_name = $super_meta->_real_ref_name;
# spent 77µs making 18 calls to Class::MOP::Class::_real_ref_name, avg 4µs/call
251
2521864µs1883µs return $self->_is_compatible_with($super_meta_name);
# spent 83µs making 18 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call
253}
254
255
# spent 3.29ms (439µs+2.85) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 108 times, avg 30µs/call: # 108 times (439µs+2.85ms) by Class::MOP::Class::_check_metaclass_compatibility at line 220, avg 30µs/call
sub _check_single_metaclass_compatibility {
25610829µs my $self = shift;
25710861µs my ( $metaclass_type, $superclass_name ) = @_;
258
259108290µs1082.85ms if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) {
# spent 2.85ms making 108 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 26µs/call
260 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
261
262 $self->_throw_exception( MetaclassTypeIncompatible => class_name => $self->name,
263 superclass_name => $superclass_name,
264 metaclass_type => $metaclass_type
265 );
266 }
267}
268
269
# spent 2.85ms (1.75+1.10) within Class::MOP::Class::_single_metaclass_is_compatible which was called 108 times, avg 26µs/call: # 108 times (1.75ms+1.10ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 259, avg 26µs/call
sub _single_metaclass_is_compatible {
27010818µs my $self = shift;
27110848µs my ( $metaclass_type, $superclass_name ) = @_;
272
27310893µs108100µs my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 100µs making 108 calls to Class::MOP::get_metaclass_by_name, avg 930ns/call
274 || return 1;
275
276 # for instance, Moose::Meta::Class has a error_class attribute, but
277 # Class::MOP::Class doesn't - this shouldn't be an error
278108289µs10884µs return 1 unless $super_meta->can($metaclass_type);
# spent 84µs making 108 calls to UNIVERSAL::can, avg 782ns/call
279 # for instance, Moose::Meta::Class has a destructor_class, but
280 # Class::MOP::Class doesn't - this shouldn't be an error
281108222µs10893µs return 1 unless defined $super_meta->$metaclass_type;
# spent 27µs making 18 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 26µs making 18 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 11µs making 18 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 606ns/call # spent 10µs making 18 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 567ns/call # spent 10µs making 18 calls to Class::MOP::Class::instance_metaclass, avg 556ns/call # spent 9µs making 18 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 517ns/call
282 # if metaclass is defined in superclass but not here, it's not compatible
283 # this is a really odd case
284108208µs10885µs return 0 unless defined $self->$metaclass_type;
# spent 27µs making 18 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 25µs making 18 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 9µs making 18 calls to Class::MOP::Class::instance_metaclass, avg 506ns/call # spent 8µs making 18 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 467ns/call # spent 8µs making 18 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 461ns/call # spent 8µs making 18 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 422ns/call
285
286108759µs324733µs return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type);
# spent 570µs making 108 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call # spent 50µs making 36 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 49µs making 36 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 17µs making 36 calls to Class::MOP::Class::instance_metaclass, avg 472ns/call # spent 16µs making 36 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 450ns/call # spent 16µs making 36 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 431ns/call # spent 15µs making 36 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 417ns/call
287}
288
289
# spent 17.4ms (895µs+16.5) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 54 times, avg 321µs/call: # 54 times (895µs+16.5ms) by Class::MOP::Class::_check_metaclass_compatibility at line 200, avg 321µs/call
sub _fix_metaclass_incompatibility {
2905423µs my $self = shift;
291119316µs65126µs my @supers = map { Class::MOP::Class->initialize($_) } @_;
# spent 851µs making 65 calls to Class::MOP::Class::initialize, avg 13µs/call, recursion: max depth 2, sum of overlapping time 725µs
292
2935417µs my $necessary = 0;
2945452µs for my $super (@supers) {
29565175µs6515.8ms $necessary = 1
# spent 15.8ms making 65 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 243µs/call
296 if $self->_can_fix_metaclass_incompatibility($super);
297 }
29854150µs return unless $necessary;
299
300 for my $super (@supers) {
301 if (!$self->_class_metaclass_is_compatible($super->name)) {
302 $self->_fix_class_metaclass_incompatibility($super);
303 }
304 }
305
306 my %base_metaclass = $self->_base_metaclasses;
307 for my $metaclass_type (keys %base_metaclass) {
308 for my $super (@supers) {
309 if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) {
310 $self->_fix_single_metaclass_incompatibility(
311 $metaclass_type, $super
312 );
313 }
314 }
315 }
316}
317
318
# spent 15.8ms (2.10+13.7) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 65 times, avg 243µs/call: # 65 times (2.10ms+13.7ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 295, avg 243µs/call
sub _can_fix_metaclass_incompatibility {
3196525µs my $self = shift;
3206537µs my ($super_meta) = @_;
321
32265147µs652.05ms return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta);
# spent 2.05ms making 65 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 32µs/call
323
32465259µs651.00ms my %base_metaclass = $self->_base_metaclasses;
# spent 778µs making 18 calls to Moose::Meta::Class::_base_metaclasses, avg 43µs/call # spent 224µs making 47 calls to Class::MOP::Class::_base_metaclasses, avg 5µs/call
32565109µs for my $metaclass_type (keys %base_metaclass) {
326390729µs39010.7ms return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type);
# spent 10.7ms making 390 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 27µs/call
327 }
328
32965246µs return;
330}
331
332
# spent 2.05ms (516µs+1.53) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 65 times, avg 32µs/call: # 65 times (516µs+1.53ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 322, avg 32µs/call
sub _class_metaclass_can_be_made_compatible {
3336521µs my $self = shift;
3346527µs my ($super_meta) = @_;
335
33665417µs1301.53ms return $self->_can_be_made_compatible_with($super_meta->_real_ref_name);
# spent 894µs making 65 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 14µs/call # spent 641µs making 65 calls to Class::MOP::Class::_real_ref_name, avg 10µs/call
337}
338
339
# spent 10.7ms (5.64+5.01) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 390 times, avg 27µs/call: # 390 times (5.64ms+5.01ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 326, avg 27µs/call
sub _single_metaclass_can_be_made_compatible {
340390105µs my $self = shift;
341390233µs my ($super_meta, $metaclass_type) = @_;
342
3433901.59ms390452µs my $specific_meta = $self->$metaclass_type;
# spent 69µs making 65 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 1µs/call # spent 66µs making 65 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 1µs/call # spent 64µs making 18 calls to Moose::Meta::Class::constructor_class, avg 4µs/call # spent 64µs making 65 calls to Class::MOP::Class::instance_metaclass, avg 985ns/call # spent 61µs making 65 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 943ns/call # spent 49µs making 18 calls to Moose::Meta::Class::destructor_class, avg 3µs/call # spent 41µs making 47 calls to Class::MOP::Class::constructor_class, avg 872ns/call # spent 38µs making 47 calls to Class::MOP::Class::destructor_class, avg 817ns/call
344
3453901.25ms390393µs return unless $super_meta->can($metaclass_type);
# spent 393µs making 390 calls to UNIVERSAL::can, avg 1µs/call
3463901.17ms390341µs my $super_specific_meta = $super_meta->$metaclass_type;
# spent 56µs making 65 calls to Class::MOP::Class::instance_metaclass, avg 855ns/call # spent 55µs making 65 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 845ns/call # spent 50µs making 65 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 777ns/call # spent 46µs making 65 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 712ns/call # spent 38µs making 47 calls to Class::MOP::Class::constructor_class, avg 817ns/call # spent 37µs making 47 calls to Class::MOP::Class::destructor_class, avg 781ns/call # spent 29µs making 18 calls to Moose::Meta::Class::constructor_class, avg 2µs/call # spent 29µs making 18 calls to Moose::Meta::Class::destructor_class, avg 2µs/call
347
348 # for instance, Moose::Meta::Class has a destructor_class, but
349 # Class::MOP::Class doesn't - this shouldn't be an error
350390164µs return unless defined $super_specific_meta;
351
352 # if metaclass is defined in superclass but not here, it's fixable
353 # this is a really odd case
35434312µs return 1 unless defined $specific_meta;
355
3563431.85ms3433.82ms return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta);
# spent 3.82ms making 343 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 11µs/call
357}
358
359sub _fix_class_metaclass_incompatibility {
360 my $self = shift;
361 my ( $super_meta ) = @_;
362
363 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
364 ($self->is_pristine)
365 || $self->_throw_exception( CannotFixMetaclassCompatibility => class_name => $self->name,
366 superclass => $super_meta
367 );
368
369 my $super_meta_name = $super_meta->_real_ref_name;
370
371 $self->_make_compatible_with($super_meta_name);
372 }
373}
374
375sub _fix_single_metaclass_incompatibility {
376 my $self = shift;
377 my ( $metaclass_type, $super_meta ) = @_;
378
379 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
380 ($self->is_pristine)
381 || $self->_throw_exception( CannotFixMetaclassCompatibility => class_name => $self->name,
382 superclass => $super_meta,
383 metaclass_type => $metaclass_type
384 );
385
386 my $new_metaclass = $self->$metaclass_type
387 ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type)
388 : $super_meta->$metaclass_type;
389 $self->{$metaclass_type} = $new_metaclass;
390 }
391}
392
393sub _restore_metaobjects_from {
394 my $self = shift;
395 my ($old_meta) = @_;
396
397 $self->_restore_metamethods_from($old_meta);
398 $self->_restore_metaattributes_from($old_meta);
399}
400
401sub _remove_generated_metaobjects {
402 my $self = shift;
403
404 for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) {
405 $attr->remove_accessors;
406 }
407}
408
409# creating classes with MOP ...
410
411
# spent 2.96ms (98µs+2.86) within Class::MOP::Class::create which was called 2 times, avg 1.48ms/call: # 2 times (98µs+2.86ms) by Class::MOP::Class::_immutable_metaclass at line 1366, avg 1.48ms/call
sub create {
41221µs my $class = shift;
41323µs my @args = @_;
414
41524µs unshift @args, 'package' if @args % 2 == 1;
41624µs my %options = @args;
417
41824µs (ref $options{superclasses} eq 'ARRAY')
419 || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfSuperclasses => class => $class,
420 params => \%options
421 )
422 if exists $options{superclasses};
423
42421µs (ref $options{attributes} eq 'ARRAY')
425 || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfAttributes => class => $class,
426 params => \%options
427 )
428 if exists $options{attributes};
429
4302900ns (ref $options{methods} eq 'HASH')
431 || __PACKAGE__->_throw_exception( CreateMOPClassTakesHashRefOfMethods => class => $class,
432 params => \%options
433 )
434 if exists $options{methods};
435
43623µs my $package = delete $options{package};
43721µs my $superclasses = delete $options{superclasses};
4382500ns my $attributes = delete $options{attributes};
4392600ns my $methods = delete $options{methods};
44022µs my $meta_name = exists $options{meta_name}
441 ? delete $options{meta_name}
442 : 'meta';
443
444234µs2475µs my $meta = $class->SUPER::create($package => %options);
# spent 475µs making 2 calls to Class::MOP::Module::create, avg 238µs/call
445
446211µs21.40ms $meta->_add_meta_method($meta_name)
# spent 1.40ms making 2 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 700µs/call
447 if defined $meta_name;
448
44924µs2986µs $meta->superclasses(@{$superclasses})
# spent 986µs making 2 calls to Class::MOP::Class::superclasses, avg 493µs/call
450 if defined $superclasses;
451 # NOTE:
452 # process attributes first, so that they can
453 # install accessors, but locally defined methods
454 # can then overwrite them. It is maybe a little odd, but
455 # I think this should be the order of things.
4562700ns if (defined $attributes) {
457 foreach my $attr (@{$attributes}) {
458 $meta->add_attribute($attr);
459 }
460 }
4612500ns if (defined $methods) {
462 foreach my $method_name (keys %{$methods}) {
463 $meta->add_method($method_name, $methods->{$method_name});
464 }
465 }
466210µs return $meta;
467}
468
469# XXX: something more intelligent here?
470sub _anon_package_prefix { 'Class::MOP::Class::__ANON__::SERIAL::' }
471
472sub create_anon_class { shift->create_anon(@_) }
473sub is_anon_class { shift->is_anon(@_) }
474
475sub _anon_cache_key {
476 my $class = shift;
477 my %options = @_;
478 # Makes something like Super::Class|Super::Class::2
479 return join '=' => (
480 join( '|', sort @{ $options{superclasses} || [] } ),
481 );
482}
483
484# Instance Construction & Cloning
485
486
# spent 51.5ms (2.25+49.3) within Class::MOP::Class::new_object which was called 253 times, avg 204µs/call: # 207 times (1.78ms+38.8ms) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 196µs/call # 24 times (228µs+4.71ms) by Class::MOP::Method::_new at line 55 of Class/MOP/Method.pm, avg 206µs/call # 20 times (215µs+4.79ms) by Moose::Meta::Method::_new at line 7 of (eval 25)[Eval/Closure.pm:125], avg 250µs/call # once (15µs+661µs) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm # once (14µs+284µs) by Class::MOP::Object::_new at line 23 of Class/MOP/Object.pm
sub new_object {
487253100µs my $class = shift;
488
489 # NOTE:
490 # we need to protect the integrity of the
491 # Class::MOP::Class singletons here, so we
492 # delegate this to &construct_class_instance
493 # which will deal with the singletons
4942531.81ms506527µs return $class->_construct_class_instance(@_)
# spent 382µs making 253 calls to UNIVERSAL::isa, avg 2µs/call # spent 146µs making 253 calls to Class::MOP::Package::name, avg 575ns/call
495 if $class->name->isa('Class::MOP::Class');
496253811µs25348.8ms return $class->_construct_instance(@_);
# spent 48.8ms making 253 calls to Class::MOP::Class::_construct_instance, avg 193µs/call
497}
498
499
# spent 59.8ms (11.0+48.9) within Class::MOP::Class::_construct_instance which was called 271 times, avg 221µs/call: # 253 times (9.68ms+39.1ms) by Class::MOP::Class::new_object at line 496, avg 193µs/call # 18 times (1.30ms+9.78ms) by Class::MOP::Class::_construct_class_instance at line 101, avg 616µs/call
sub _construct_instance {
50027187µs my $class = shift;
501271123µs my $params = @_ == 1 ? $_[0] : {@_};
502271452µs2713.79ms my $meta_instance = $class->get_meta_instance();
# spent 2.43ms making 242 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 10µs/call # spent 1.36ms making 29 calls to Class::MOP::Class::get_meta_instance, avg 47µs/call
503 # FIXME:
504 # the code below is almost certainly incorrect
505 # but this is foreign inheritance, so we might
506 # have to kludge it in the end.
50727146µs my $instance;
5082711.54ms271325µs if (my $instance_class = blessed($params->{__INSTANCE__})) {
# spent 325µs making 271 calls to Scalar::Util::blessed, avg 1µs/call
509 ($instance_class eq $class->name)
510 || $class->_throw_exception( InstanceBlessedIntoWrongClass => class_name => $class->name,
511 params => $params,
512 instance => $params->{__INSTANCE__}
513 );
514 $instance = $params->{__INSTANCE__};
515 }
516 elsif (exists $params->{__INSTANCE__}) {
517 $class->_throw_exception( InstanceMustBeABlessedReference => class_name => $class->name,
518 params => $params,
519 instance => $params->{__INSTANCE__}
520 );
521 }
522 else {
523271597µs2714.04ms $instance = $meta_instance->create_instance();
# spent 4.04ms making 271 calls to Class::MOP::Instance::create_instance, avg 15µs/call
524 }
525271644µs2715.00ms foreach my $attr ($class->get_all_attributes()) {
# spent 2.53ms making 29 calls to Class::MOP::Class::get_all_attributes, avg 87µs/call # spent 2.47ms making 242 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 10µs/call
52624373.53ms243734.3ms $attr->initialize_instance_slot($meta_instance, $instance, $params);
# spent 34.3ms making 2437 calls to Class::MOP::Attribute::initialize_instance_slot, avg 14µs/call
527 }
5282711.04ms5421.40ms if (Class::MOP::metaclass_is_weak($class->name)) {
# spent 1.22ms making 271 calls to Class::MOP::metaclass_is_weak, avg 5µs/call # spent 172µs making 271 calls to Class::MOP::Package::name, avg 633ns/call
529 $meta_instance->_set_mop_slot($instance, $class);
530 }
531271561µs return $instance;
532}
533
534
# spent 100ms (834µs+99.3) within Class::MOP::Class::_inline_new_object which was called 46 times, avg 2.18ms/call: # 46 times (834µs+99.3ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 98 of Class/MOP/Method/Constructor.pm, avg 2.18ms/call
sub _inline_new_object {
5354616µs my $self = shift;
536
537 return (
53846631µs27699.3ms 'my $class = shift;',
# spent 87.2ms making 46 calls to Class::MOP::Class::_inline_slot_initializers, avg 1.90ms/call # spent 6.48ms making 16 calls to Moose::Meta::Class::_inline_extra_init, avg 405µs/call # spent 2.15ms making 46 calls to Class::MOP::Class::_inline_generate_instance, avg 47µs/call # spent 2.09ms making 16 calls to Moose::Meta::Class::_inline_params, avg 131µs/call # spent 626µs making 46 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 14µs/call # spent 571µs making 46 calls to Class::MOP::Class::_inline_fallback_constructor, avg 12µs/call # spent 96µs making 30 calls to Class::MOP::Class::_inline_params, avg 3µs/call # spent 36µs making 30 calls to Class::MOP::Class::_inline_extra_init, avg 1µs/call
539 '$class = Scalar::Util::blessed($class) || $class;',
540 $self->_inline_fallback_constructor('$class'),
541 $self->_inline_params('$params', '$class'),
542 $self->_inline_generate_instance('$instance', '$class'),
543 $self->_inline_slot_initializers,
544 $self->_inline_preserve_weak_metaclasses,
545 $self->_inline_extra_init,
546 'return $instance',
547 );
548}
549
550
# spent 571µs (405+166) within Class::MOP::Class::_inline_fallback_constructor which was called 46 times, avg 12µs/call: # 46 times (405µs+166µs) by Class::MOP::Class::_inline_new_object at line 538, avg 12µs/call
sub _inline_fallback_constructor {
5514614µs my $self = shift;
5524627µs my ($class) = @_;
553 return (
55446350µs92166µs 'return ' . $self->_generate_fallback_constructor($class),
# spent 77µs making 30 calls to Class::MOP::Class::_generate_fallback_constructor, avg 3µs/call # spent 59µs making 16 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 4µs/call # spent 30µs making 46 calls to Class::MOP::Package::name, avg 663ns/call
555 'if ' . $class . ' ne \'' . $self->name . '\';',
556 );
557}
558
559
# spent 77µs within Class::MOP::Class::_generate_fallback_constructor which was called 30 times, avg 3µs/call: # 30 times (77µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554, avg 3µs/call
sub _generate_fallback_constructor {
560309µs my $self = shift;
5613010µs my ($class) = @_;
5623091µs return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)',
563}
564
565
# spent 96µs within Class::MOP::Class::_inline_params which was called 30 times, avg 3µs/call: # 30 times (96µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 3µs/call
sub _inline_params {
5663012µs my $self = shift;
5673023µs my ($params, $class) = @_;
568 return (
5693078µs 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};',
570 );
571}
572
573
# spent 2.15ms (280µs+1.87) within Class::MOP::Class::_inline_generate_instance which was called 46 times, avg 47µs/call: # 46 times (280µs+1.87ms) by Class::MOP::Class::_inline_new_object at line 538, avg 47µs/call
sub _inline_generate_instance {
5744614µs my $self = shift;
5754641µs my ($inst, $class) = @_;
576 return (
57746197µs461.87ms 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';',
# spent 1.87ms making 46 calls to Class::MOP::Class::_inline_create_instance, avg 41µs/call
578 );
579}
580
581
# spent 1.87ms (328µs+1.54) within Class::MOP::Class::_inline_create_instance which was called 46 times, avg 41µs/call: # 46 times (328µs+1.54ms) by Class::MOP::Class::_inline_generate_instance at line 577, avg 41µs/call
sub _inline_create_instance {
582469µs my $self = shift;
583
58446242µs921.54ms return $self->get_meta_instance->inline_create_instance(@_);
# spent 1.40ms making 46 calls to Class::MOP::Class::get_meta_instance, avg 30µs/call # spent 142µs making 46 calls to Class::MOP::Instance::inline_create_instance, avg 3µs/call
585}
586
587
# spent 87.2ms (1.71+85.5) within Class::MOP::Class::_inline_slot_initializers which was called 46 times, avg 1.90ms/call: # 46 times (1.71ms+85.5ms) by Class::MOP::Class::_inline_new_object at line 538, avg 1.90ms/call
sub _inline_slot_initializers {
5884613µs my $self = shift;
589
5904613µs my $idx = 0;
591
59216914.87ms291379.3ms return map { $self->_inline_slot_initializer($_, $idx++) }
# spent 54.1ms making 187 calls to Moose::Meta::Class::_inline_slot_initializer, avg 289µs/call # spent 24.3ms making 282 calls to Class::MOP::Class::_inline_slot_initializer, avg 86µs/call # spent 912µs making 2444 calls to Class::MOP::Mixin::AttributeCore::name, avg 373ns/call
59346543µs927.17ms sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 4.33ms making 46 calls to Class::MOP::Class::CORE:sort, avg 94µs/call # spent 2.84ms making 46 calls to Class::MOP::Class::get_all_attributes, avg 62µs/call
594}
595
596
# spent 73.9ms (6.00+67.9) within Class::MOP::Class::_inline_slot_initializer which was called 469 times, avg 158µs/call: # 282 times (3.31ms+21.0ms) by Class::MOP::Class::_inline_slot_initializers at line 592, avg 86µs/call # 187 times (2.69ms+47.0ms) by Moose::Meta::Class::_inline_slot_initializer at line 365 of Moose/Meta/Class.pm, avg 266µs/call
sub _inline_slot_initializer {
597469100µs my $self = shift;
598469167µs my ($attr, $idx) = @_;
599
6004691.36ms4801.23ms if (defined(my $init_arg = $attr->init_arg)) {
# spent 932µs making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 85µs/call # spent 301µs making 469 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 642ns/call
6014581.08ms45844.0ms my @source = (
# spent 30.7ms making 187 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 164µs/call # spent 13.3ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 49µs/call
602 'if (exists $params->{\'' . $init_arg . '\'}) {',
603 $self->_inline_init_attr_from_constructor($attr, $idx),
604 '}',
605 );
606458926µs45822.7ms if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
# spent 16.1ms making 187 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 86µs/call # spent 6.57ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 24µs/call
607 push @source, (
608 'else {',
609 @default,
610 '}',
611 );
612 }
6134581.95ms return @source;
614 }
615 elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
616 return (
617 '{',
618 @default,
619 '}',
620 );
621 }
622 else {
62314µs return ();
624 }
625}
626
627
# spent 13.3ms (2.66+10.6) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 271 times, avg 49µs/call: # 271 times (2.66ms+10.6ms) by Class::MOP::Class::_inline_slot_initializer at line 601, avg 49µs/call
sub _inline_init_attr_from_constructor {
62827142µs my $self = shift;
62927194µs my ($attr, $idx) = @_;
630
6312711.12ms54210.1ms my @initial_value = $attr->_inline_set_value(
# spent 9.27ms making 269 calls to Class::MOP::Attribute::_inline_set_value, avg 34µs/call # spent 732µs making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 366µs/call # spent 121µs making 271 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 446ns/call
632 '$instance', '$params->{\'' . $attr->init_arg . '\'}',
633 );
634
635271389µs271485µs push @initial_value, (
# spent 485µs making 271 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call
636 '$attrs->[' . $idx . ']->set_initial_value(',
637 '$instance,',
638 $attr->_inline_instance_get('$instance'),
639 ');',
640 ) if $attr->has_initializer;
641
642271694µs return @initial_value;
643}
644
645
# spent 7.51ms (1.84+5.67) within Class::MOP::Class::_inline_init_attr_from_default which was called 282 times, avg 27µs/call: # 271 times (1.73ms+4.85ms) by Class::MOP::Class::_inline_slot_initializer at line 606, avg 24µs/call # 11 times (111µs+822µs) by Class::MOP::Class::_inline_slot_initializer at line 600, avg 85µs/call
sub _inline_init_attr_from_default {
64628264µs my $self = shift;
64728298µs my ($attr, $idx) = @_;
648
649282404µs2822.64ms my $default = $self->_inline_default_value($attr, $idx);
# spent 2.64ms making 282 calls to Class::MOP::Class::_inline_default_value, avg 9µs/call
650282327µs return unless $default;
651
65299190µs992.86ms my @initial_value = $attr->_inline_set_value('$instance', $default);
# spent 2.86ms making 99 calls to Class::MOP::Attribute::_inline_set_value, avg 29µs/call
653
65499141µs99166µs push @initial_value, (
# spent 166µs making 99 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 2µs/call
655 '$attrs->[' . $idx . ']->set_initial_value(',
656 '$instance,',
657 $attr->_inline_instance_get('$instance'),
658 ');',
659 ) if $attr->has_initializer;
660
66199251µs return @initial_value;
662}
663
664
# spent 3.94ms (2.59+1.36) within Class::MOP::Class::_inline_default_value which was called 405 times, avg 10µs/call: # 282 times (1.71ms+931µs) by Class::MOP::Class::_inline_init_attr_from_default at line 649, avg 9µs/call # 123 times (878µs+425µs) by Moose::Meta::Class::_inline_init_attr_from_default at line 422 of Moose/Meta/Class.pm, avg 11µs/call
sub _inline_default_value {
66540572µs my $self = shift;
666405122µs my ($attr, $index) = @_;
667
6684051.00ms8101.36ms if ($attr->has_default) {
# spent 524µs making 405 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 1µs/call # spent 504µs making 178 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 3µs/call # spent 327µs making 227 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 1µs/call
669 # NOTE:
670 # default values can either be CODE refs
671 # in which case we need to call them. Or
672 # they can be scalars (strings/numbers)
673 # in which case we can just deal with them
674 # in the code we eval.
675 if ($attr->is_default_a_coderef) {
676 return '$defaults->[' . $index . ']->($instance)';
677 }
678 else {
67999265µs return '$defaults->[' . $index . ']';
680 }
681 }
682 elsif ($attr->has_builder) {
683 return '$instance->' . $attr->builder;
684 }
685 else {
686227424µs return;
687 }
688}
689
690
# spent 626µs (318+308) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 46 times, avg 14µs/call: # 46 times (318µs+308µs) by Class::MOP::Class::_inline_new_object at line 538, avg 14µs/call
sub _inline_preserve_weak_metaclasses {
6914619µs my $self = shift;
69246226µs92308µs if (Class::MOP::metaclass_is_weak($self->name)) {
# spent 268µs making 46 calls to Class::MOP::metaclass_is_weak, avg 6µs/call # spent 40µs making 46 calls to Class::MOP::Package::name, avg 861ns/call
693 return (
694 $self->_inline_set_mop_slot(
695 '$instance', 'Class::MOP::class_of($class)'
696 ) . ';'
697 );
698 }
699 else {
70046102µs return ();
701 }
702}
703
7043053µs
# spent 36µs within Class::MOP::Class::_inline_extra_init which was called 30 times, avg 1µs/call: # 30 times (36µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 1µs/call
sub _inline_extra_init { }
705
706
# spent 9.81ms (1.69+8.12) within Class::MOP::Class::_eval_environment which was called 46 times, avg 213µs/call: # 30 times (999µs+5.18ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 206µs/call # 16 times (688µs+2.94ms) by Moose::Meta::Class::_eval_environment at line 542 of Moose/Meta/Class.pm, avg 227µs/call
sub _eval_environment {
7074617µs my $self = shift;
708
70912684.58ms25368.28ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 4.50ms making 46 calls to Class::MOP::Class::CORE:sort, avg 98µs/call # spent 2.80ms making 46 calls to Class::MOP::Class::get_all_attributes, avg 61µs/call # spent 982µs making 2444 calls to Class::MOP::Mixin::AttributeCore::name, avg 402ns/call
710
711515717µs469827µs my $defaults = [map { $_->default } @attrs];
# spent 827µs making 469 calls to Class::MOP::Mixin::AttributeCore::default, avg 2µs/call
712
713 return {
71446179µs '$defaults' => \$defaults,
715 };
716}
717
718
719
# spent 37.4ms (2.03+35.3) within Class::MOP::Class::get_meta_instance which was called 988 times, avg 38µs/call: # 523 times (883µs+9.43ms) by Class::MOP::Attribute::_inline_instance_set at line 301 of Class/MOP/Attribute.pm, avg 20µs/call # 266 times (779µs+20.9ms) by Class::MOP::Attribute::_inline_instance_get at line 324 of Class/MOP/Attribute.pm, avg 81µs/call # 87 times (115µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 345 of Class/MOP/Attribute.pm, avg 1µs/call # 46 times (82µs+1.32ms) by Class::MOP::Class::_inline_create_instance at line 584, avg 30µs/call # 29 times (83µs+1.27ms) by Class::MOP::Class::_construct_instance at line 502, avg 47µs/call # 22 times (63µs+2.25ms) by Class::MOP::Class:::around at line 77 of Class/MOP/Class/Immutable/Trait.pm, avg 105µs/call # 8 times (11µs+0s) by Class::MOP::Attribute::_inline_instance_clear at line 366 of Class/MOP/Attribute.pm, avg 1µs/call # 3 times (5µs+0s) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 2µs/call # 2 times (3µs+0s) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 2µs/call # once (5µs+201µs) by Moose::Exporter::BEGIN@8 at line 733 of Class/MOP.pm # once (1µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 737 of Moose/Meta/Attribute.pm
sub get_meta_instance {
720988219µs my $self = shift;
7219882.24ms23735.3ms $self->{'_meta_instance'} ||= $self->_create_meta_instance();
# spent 35.3ms making 237 calls to Class::MOP::Class::_create_meta_instance, avg 149µs/call
722}
723
724
# spent 35.3ms (3.05+32.3) within Class::MOP::Class::_create_meta_instance which was called 237 times, avg 149µs/call: # 237 times (3.05ms+32.3ms) by Class::MOP::Class::get_meta_instance at line 721, avg 149µs/call
sub _create_meta_instance {
72523745µs my $self = shift;
726
7272371.76ms71132.0ms my $instance = $self->instance_metaclass->new(
# spent 20.1ms making 237 calls to Class::MOP::Instance::new, avg 85µs/call # spent 10.6ms making 225 calls to Class::MOP::Class::get_all_attributes, avg 47µs/call # spent 1.13ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 94µs/call # spent 142µs making 237 calls to Class::MOP::Class::instance_metaclass, avg 600ns/call
728 associated_metaclass => $self,
729 attributes => [ $self->get_all_attributes() ],
730 );
731
732237421µs237286µs $self->add_meta_instance_dependencies()
# spent 286µs making 237 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 1µs/call
733 if $instance->is_dependent_on_superclasses();
734
735237560µs return $instance;
736}
737
738# TODO: this is actually not being used!
739sub _inline_rebless_instance {
740 my $self = shift;
741
742 return $self->get_meta_instance->inline_rebless_instance_structure(@_);
743}
744
745sub _inline_get_mop_slot {
746 my $self = shift;
747
748 return $self->get_meta_instance->_inline_get_mop_slot(@_);
749}
750
751sub _inline_set_mop_slot {
752 my $self = shift;
753
754 return $self->get_meta_instance->_inline_set_mop_slot(@_);
755}
756
757sub _inline_clear_mop_slot {
758 my $self = shift;
759
760 return $self->get_meta_instance->_inline_clear_mop_slot(@_);
761}
762
763sub clone_object {
764 my $class = shift;
765 my $instance = shift;
766 (blessed($instance) && $instance->isa($class->name))
767 || $class->_throw_exception( CloneObjectExpectsAnInstanceOfMetaclass => class_name => $class->name,
768 instance => $instance,
769 );
770 # NOTE:
771 # we need to protect the integrity of the
772 # Class::MOP::Class singletons here, they
773 # should not be cloned.
774 return $instance if $instance->isa('Class::MOP::Class');
775 $class->_clone_instance($instance, @_);
776}
777
778sub _clone_instance {
779 my ($class, $instance, %params) = @_;
780 (blessed($instance))
781 || $class->_throw_exception( OnlyInstancesCanBeCloned => class_name => $class->name,
782 instance => $instance,
783 params => \%params
784 );
785 my $meta_instance = $class->get_meta_instance();
786 my $clone = $meta_instance->clone_instance($instance);
787 foreach my $attr ($class->get_all_attributes()) {
788 if ( defined( my $init_arg = $attr->init_arg ) ) {
789 if (exists $params{$init_arg}) {
790 $attr->set_value($clone, $params{$init_arg});
791 }
792 }
793 }
794 return $clone;
795}
796
797sub _force_rebless_instance {
798 my ($self, $instance, %params) = @_;
799 my $old_metaclass = Class::MOP::class_of($instance);
800
801 $old_metaclass->rebless_instance_away($instance, $self, %params)
802 if $old_metaclass;
803
804 my $meta_instance = $self->get_meta_instance;
805
806 if (Class::MOP::metaclass_is_weak($old_metaclass->name)) {
807 $meta_instance->_clear_mop_slot($instance);
808 }
809
810 # rebless!
811 # we use $_[1] here because of t/cmop/rebless_overload.t regressions
812 # on 5.8.8
813 $meta_instance->rebless_instance_structure($_[1], $self);
814
815 $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params);
816
817 if (Class::MOP::metaclass_is_weak($self->name)) {
818 $meta_instance->_set_mop_slot($instance, $self);
819 }
820}
821
822sub rebless_instance {
823 my ($self, $instance, %params) = @_;
824 my $old_metaclass = Class::MOP::class_of($instance);
825
826 my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance);
827 $self->name->isa($old_class)
828 || $self->_throw_exception( CanReblessOnlyIntoASubclass => class_name => $self->name,
829 instance => $instance,
830 instance_class => blessed( $instance ),
831 params => \%params,
832 );
833
834 $self->_force_rebless_instance($_[1], %params);
835
836 return $instance;
837}
838
839sub rebless_instance_back {
840 my ( $self, $instance ) = @_;
841 my $old_metaclass = Class::MOP::class_of($instance);
842 my $old_class
843 = $old_metaclass ? $old_metaclass->name : blessed($instance);
844 $old_class->isa( $self->name )
845 || $self->_throw_exception( CanReblessOnlyIntoASuperclass => class_name => $self->name,
846 instance => $instance,
847 instance_class => blessed( $instance ),
848 );
849
850 $self->_force_rebless_instance($_[1]);
851
852 return $instance;
853}
854
855sub rebless_instance_away {
856 # this intentionally does nothing, it is just a hook
857}
858
859sub _fixup_attributes_after_rebless {
860 my $self = shift;
861 my ($instance, $rebless_from, %params) = @_;
862 my $meta_instance = $self->get_meta_instance;
863
864 for my $attr ( $rebless_from->get_all_attributes ) {
865 next if $self->find_attribute_by_name( $attr->name );
866 $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots;
867 }
868
869 foreach my $attr ( $self->get_all_attributes ) {
870 if ( $attr->has_value($instance) ) {
871 if ( defined( my $init_arg = $attr->init_arg ) ) {
872 $params{$init_arg} = $attr->get_value($instance)
873 unless exists $params{$init_arg};
874 }
875 else {
876 $attr->set_value($instance, $attr->get_value($instance));
877 }
878 }
879 }
880
881 foreach my $attr ($self->get_all_attributes) {
882 $attr->initialize_instance_slot($meta_instance, $instance, \%params);
883 }
884}
885
886
# spent 5.02ms (1.49+3.53) within Class::MOP::Class::_attach_attribute which was called 320 times, avg 16µs/call: # 320 times (1.49ms+3.53ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 22 of Class/MOP/Mixin/HasAttributes.pm, avg 16µs/call
sub _attach_attribute {
887320277µs my ($self, $attribute) = @_;
8883201.06ms3203.53ms $attribute->attach_to_class($self);
# spent 3.53ms making 320 calls to Class::MOP::Attribute::attach_to_class, avg 11µs/call
889}
890
891
# spent 343ms (4.15+339) within Class::MOP::Class::_post_add_attribute which was called 320 times, avg 1.07ms/call: # 320 times (4.15ms+339ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 39 of Class/MOP/Mixin/HasAttributes.pm, avg 1.07ms/call
sub _post_add_attribute {
892320225µs my ( $self, $attribute ) = @_;
893
894320532µs3203.21ms $self->invalidate_meta_instances;
# spent 3.21ms making 320 calls to Class::MOP::Class::invalidate_meta_instances, avg 10µs/call
895
896 # invalidate package flag here
897 try {
898320640µs local $SIG{__DIE__};
8993201.39ms320324ms $attribute->install_accessors;
# spent 283ms making 190 calls to Moose::Meta::Attribute::install_accessors, avg 1.49ms/call # spent 41.7ms making 130 calls to Class::MOP::Attribute::install_accessors, avg 321µs/call
900 }
901 catch {
902 $self->remove_attribute( $attribute->name );
903 die $_;
9043202.57ms640336ms };
# spent 335ms making 320 calls to Try::Tiny::try, avg 1.05ms/call # spent 1.26ms making 320 calls to Try::Tiny::catch, avg 4µs/call
905}
906
907
# spent 433µs (133+300) within Class::MOP::Class::remove_attribute which was called 2 times, avg 216µs/call: # 2 times (133µs+300µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 26 of Class/MOP/Mixin/HasAttributes.pm, avg 216µs/call
sub remove_attribute {
9082600ns my $self = shift;
909
910217µs221µs my $removed_attribute = $self->SUPER::remove_attribute(@_)
# spent 21µs making 2 calls to Class::MOP::Mixin::HasAttributes::remove_attribute, avg 11µs/call
911 or return;
912
91323µs220µs $self->invalidate_meta_instances;
# spent 20µs making 2 calls to Class::MOP::Class::invalidate_meta_instances, avg 10µs/call
914
91523µs2255µs $removed_attribute->remove_accessors;
# spent 255µs making 2 calls to Moose::Meta::Attribute::remove_accessors, avg 128µs/call
91625µs24µs $removed_attribute->detach_from_class;
# spent 4µs making 2 calls to Class::MOP::Attribute::detach_from_class, avg 2µs/call
917
918290µs return$removed_attribute;
919}
920
921
# spent 3.43ms (1.13+2.30) within Class::MOP::Class::find_attribute_by_name which was called 70 times, avg 49µs/call: # 70 times (1.13ms+2.30ms) by Class::MOP::Class::_immutable_metaclass at line 1343, avg 49µs/call
sub find_attribute_by_name {
9227057µs my ( $self, $attr_name ) = @_;
923
92470159µs70907µs foreach my $class ( $self->linearized_isa ) {
# spent 865µs making 66 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 13µs/call # spent 41µs making 4 calls to Class::MOP::Class::linearized_isa, avg 10µs/call
925 # fetch the meta-class ...
92670206µs70442µs my $meta = Class::MOP::Class->initialize($class);
# spent 442µs making 70 calls to Class::MOP::Class::initialize, avg 6µs/call
92770464µs140955µs return $meta->get_attribute($attr_name)
# spent 513µs making 70 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 7µs/call # spent 442µs making 70 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 6µs/call
928 if $meta->has_attribute($attr_name);
929 }
930
931 return;
932}
933
934
# spent 21.8ms (11.2+10.6) within Class::MOP::Class::get_all_attributes which was called 395 times, avg 55µs/call: # 225 times (5.51ms+5.13ms) by Class::MOP::Class::_create_meta_instance at line 727, avg 47µs/call # 46 times (1.50ms+1.34ms) by Class::MOP::Class::_inline_slot_initializers at line 593, avg 62µs/call # 46 times (1.42ms+1.38ms) by Class::MOP::Class::_eval_environment at line 709, avg 61µs/call # 29 times (1.28ms+1.24ms) by Class::MOP::Class::_construct_instance at line 525, avg 87µs/call # 16 times (610µs+846µs) by Class::MOP::Class:::around at line 71 of Class/MOP/Class/Immutable/Trait.pm, avg 91µs/call # 16 times (457µs+372µs) by Moose::Meta::Class::_inline_triggers at line 459 of Moose/Meta/Class.pm, avg 52µs/call # 16 times (334µs+290µs) by Moose::Meta::Class::_eval_environment at line 497 of Moose/Meta/Class.pm, avg 39µs/call # once (58µs+41µs) by Moose::Meta::Attribute::new at line 58 of Moose/Meta/Attribute.pm
sub get_all_attributes {
93539595µs my $self = shift;
93627658.79ms276510.5ms my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } }
# spent 6.49ms making 1185 calls to Class::MOP::Class::initialize, avg 5µs/call, recursion: max depth 1, sum of overlapping time 163µs # spent 2.99ms making 379 calls to Class::MOP::Class::linearized_isa, avg 8µs/call # spent 808µs making 1185 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 682ns/call # spent 347µs making 16 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 22µs/call
937 reverse $self->linearized_isa;
9383951.42ms return values %attrs;
939}
940
941# Inheritance
942
943sub superclasses {
94416944µs my $self = shift;
945
946169406µs1694.29ms my $isa = $self->get_or_add_package_symbol('@ISA');
# spent 4.29ms making 169 calls to Class::MOP::Package::get_or_add_package_symbol, avg 25µs/call
947
94816952µs if (@_) {
9492022µs my @supers = @_;
95020262µs @{$isa} = @supers;
951
952 # NOTE:
953 # on 5.8 and below, we need to call
954 # a method to get Perl to detect
955 # a cycle in the class hierarchy
9562087µs2019µs my $class = $self->name;
# spent 19µs making 20 calls to Class::MOP::Package::name, avg 945ns/call
95720178µs2024µs $class->isa($class);
# spent 24µs making 20 calls to UNIVERSAL::isa, avg 1µs/call
958
959 # NOTE:
960 # we need to check the metaclass
961 # compatibility here so that we can
962 # be sure that the superclass is
963 # not potentially creating an issues
964 # we don't know about
965
9662048µs2012.1ms $self->_check_metaclass_compatibility();
# spent 12.1ms making 20 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 603µs/call
9672056µs201.09ms $self->_superclasses_updated();
# spent 1.09ms making 20 calls to Class::MOP::Class::_superclasses_updated, avg 54µs/call
968 }
969
970169453µs return @{$isa};
971}
972
973
# spent 1.09ms (284µs+805µs) within Class::MOP::Class::_superclasses_updated which was called 20 times, avg 54µs/call: # 20 times (284µs+805µs) by Class::MOP::Class::superclasses at line 967, avg 54µs/call
sub _superclasses_updated {
974205µs my $self = shift;
9752040µs2050µs $self->update_meta_instance_dependencies();
# spent 50µs making 20 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 3µs/call
976 # keep strong references to all our parents, so they don't disappear if
977 # they are anon classes and don't have any direct instances
9782032µs2095µs $self->_superclass_metas(
# spent 95µs making 20 calls to Class::MOP::class_of, avg 5µs/call
97920138µs4071µs map { Class::MOP::class_of($_) } $self->superclasses
# spent 71µs making 20 calls to Class::MOP::Class::_superclass_metas, avg 4µs/call # spent 35µs making 2 calls to Class::MOP::Class::superclasses, avg 18µs/call, recursion: max depth 1, sum of overlapping time 35µs # spent 554µs making 18 calls to Moose::Meta::Class::superclasses, avg 31µs/call, recursion: max depth 2, sum of overlapping time 554µs
980 );
981}
982
983
# spent 71µs within Class::MOP::Class::_superclass_metas which was called 20 times, avg 4µs/call: # 20 times (71µs+0s) by Class::MOP::Class::_superclasses_updated at line 979, avg 4µs/call
sub _superclass_metas {
984208µs my $self = shift;
9852074µs $self->{_superclass_metas} = [@_];
986}
987
988sub subclasses {
989 my $self = shift;
990 my $super_class = $self->name;
991
992 return @{ $super_class->mro::get_isarev() };
993}
994
995sub direct_subclasses {
996 my $self = shift;
997 my $super_class = $self->name;
998
999 return grep {
1000 grep {
1001 $_ eq $super_class
1002 } Class::MOP::Class->initialize($_)->superclasses
1003 } $self->subclasses;
1004}
1005
1006
# spent 5.34ms (3.45+1.89) within Class::MOP::Class::linearized_isa which was called 679 times, avg 8µs/call: # 379 times (1.92ms+1.07ms) by Class::MOP::Class::get_all_attributes at line 936, avg 8µs/call # 280 times (1.39ms+756µs) by Class::MOP::Class::_method_lookup_order at line 1045, avg 8µs/call # 16 times (109µs+52µs) by Class::MOP::Class:::around at line 53 of Class/MOP/Class/Immutable/Trait.pm, avg 10µs/call # 4 times (28µs+13µs) by Class::MOP::Class::find_attribute_by_name at line 924, avg 10µs/call
sub linearized_isa {
10076795.98ms13581.89ms return @{ mro::get_linear_isa( (shift)->name ) };
# spent 1.55ms making 679 calls to mro::get_linear_isa, avg 2µs/call # spent 347µs making 679 calls to Class::MOP::Package::name, avg 510ns/call
1008}
1009
1010
# spent 459µs (136+323) within Class::MOP::Class::class_precedence_list which was called 8 times, avg 57µs/call: # 4 times (99µs+359µs) by Moose::Meta::Class::excludes_role at line 257 of Moose/Meta/Class.pm, avg 115µs/call # 4 times (36µs+-36µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 0s/call
sub class_precedence_list {
101183µs my $self = shift;
1012824µs85µs my $name = $self->name;
# spent 5µs making 8 calls to Class::MOP::Package::name, avg 575ns/call
1013
1014822µs86µs unless (Class::MOP::IS_RUNNING_ON_5_10()) {
# spent 6µs making 8 calls to Class::MOP::__ANON__, avg 700ns/call
1015 # NOTE:
1016 # We need to check for circular inheritance here
1017 # if we are not on 5.10, cause 5.8 detects it late.
1018 # This will do nothing if all is well, and blow up
1019 # otherwise. Yes, it's an ugly hack, better
1020 # suggestions are welcome.
1021 # - SL
1022 ($name || return)->isa('This is a test for circular inheritance')
1023 }
1024
1025 # if our mro is c3, we can
1026 # just grab the linear_isa
1027845µs822µs if (mro::get_mro($name) eq 'c3') {
# spent 22µs making 8 calls to mro::get_mro, avg 3µs/call
1028 return @{ mro::get_linear_isa($name) }
1029 }
1030 else {
1031 # NOTE:
1032 # we can't grab the linear_isa for dfs
1033 # since it has all the duplicates
1034 # already removed.
1035 return (
1036419µs828µs $name,
# spent 28µs making 4 calls to Class::MOP::Class::initialize, avg 7µs/call # spent 152µs making 4 calls to Class::MOP::Class::class_precedence_list, avg 38µs/call, recursion: max depth 1, sum of overlapping time 152µs
1037 map {
1038840µs8263µs Class::MOP::Class->initialize($_)->class_precedence_list()
# spent 263µs making 8 calls to Moose::Meta::Class::superclasses, avg 33µs/call
1039 } $self->superclasses()
1040 );
1041 }
1042}
1043
1044
# spent 3.19ms (1.05+2.14) within Class::MOP::Class::_method_lookup_order which was called 280 times, avg 11µs/call: # 136 times (526µs+1.08ms) by Class::MOP::Class::find_method_by_name at line 1132, avg 12µs/call # 105 times (382µs+771µs) by Class::MOP::Class::find_next_method_by_name at line 1178, avg 11µs/call # 32 times (104µs+194µs) by Class::MOP::Class::find_all_methods_by_name at line 1162, avg 9µs/call # 7 times (37µs+95µs) by Class::MOP::Class::get_all_methods at line 1143, avg 19µs/call
sub _method_lookup_order {
1045280875µs2802.14ms return (shift->linearized_isa, 'UNIVERSAL');
# spent 2.14ms making 280 calls to Class::MOP::Class::linearized_isa, avg 8µs/call
1046}
1047
1048## Methods
1049
1050{
10511400ns
# spent 13.7ms (949µs+12.8) within Class::MOP::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Class.pm:1082] which was called 44 times, avg 312µs/call: # 43 times (920µs+12.3ms) by Class::MOP::Class::add_around_method_modifier at line 1108, avg 309µs/call # once (29µs+428µs) by Class::MOP::Class::add_before_method_modifier at line 1088
my $fetch_and_prepare_method = sub {
10524421µs my ($self, $method_name) = @_;
105344150µs4432µs my $wrapped_metaclass = $self->wrapped_method_metaclass;
# spent 32µs making 44 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 739ns/call
1054 # fetch it locally
10554454µs441.14ms my $method = $self->get_method($method_name);
# spent 1.14ms making 44 calls to Class::MOP::Mixin::HasMethods::get_method, avg 26µs/call
1056 # if we don't have local ...
10574431µs unless ($method) {
1058 # try to find the next method
10594376µs434.73ms $method = $self->find_next_method_by_name($method_name);
# spent 4.73ms making 43 calls to Class::MOP::Class::find_next_method_by_name, avg 110µs/call
1060 # die if it does not exist
1061438µs (defined $method)
1062 || $self->_throw_exception( MethodNameNotFoundInInheritanceHierarchy => class_name => $self->name,
1063 method_name => $method_name
1064 );
1065 # and now make sure to wrap it
1066 # even if it is already wrapped
1067 # because we need a new sub ref
106843279µs863.17ms $method = $wrapped_metaclass->wrap($method,
# spent 3.13ms making 43 calls to Class::MOP::Method::Wrapped::wrap, avg 73µs/call # spent 36µs making 43 calls to Class::MOP::Package::name, avg 847ns/call
1069 package_name => $self->name,
1070 name => $method_name,
1071 );
1072 }
1073 else {
1074 # now make sure we wrap it properly
1075114µs3130µs $method = $wrapped_metaclass->wrap($method,
# spent 128µs making 1 call to Class::MOP::Method::Wrapped::wrap # spent 2µs making 1 call to UNIVERSAL::isa # spent 600ns making 1 call to Class::MOP::Package::name
1076 package_name => $self->name,
1077 name => $method_name,
1078 ) unless $method->isa($wrapped_metaclass);
1079 }
10804476µs443.57ms $self->add_method($method_name => $method);
# spent 3.57ms making 44 calls to Class::MOP::Mixin::HasMethods::add_method, avg 81µs/call
108144112µs return $method;
108215µs };
1083
1084
# spent 488µs (14+473) within Class::MOP::Class::add_before_method_modifier which was called: # once (14µs+473µs) by Moose::Util::add_method_modifier at line 285 of Moose/Util.pm
sub add_before_method_modifier {
108511µs my ($self, $method_name, $method_modifier) = @_;
10861800ns (defined $method_name && length $method_name)
1087 || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
108813µs1457µs my $method = $fetch_and_prepare_method->($self, $method_name);
1089111µs217µs $method->add_before_modifier(
# spent 14µs making 1 call to Class::MOP::Method::Wrapped::add_before_modifier # spent 2µs making 1 call to Sub::Name::subname
1090 subname(':before' => $method_modifier)
1091 );
1092 }
1093
1094 sub add_after_method_modifier {
1095 my ($self, $method_name, $method_modifier) = @_;
1096 (defined $method_name && length $method_name)
1097 || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
1098 my $method = $fetch_and_prepare_method->($self, $method_name);
1099 $method->add_after_modifier(
1100 subname(':after' => $method_modifier)
1101 );
1102 }
1103
1104
# spent 14.7ms (386µs+14.3) within Class::MOP::Class::add_around_method_modifier which was called 43 times, avg 341µs/call: # 43 times (386µs+14.3ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 341µs/call
sub add_around_method_modifier {
11054335µs my ($self, $method_name, $method_modifier) = @_;
11064312µs (defined $method_name && length $method_name)
1107 || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
11084370µs4313.3ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 13.3ms making 43 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1082], avg 309µs/call
110943320µs861.02ms $method->add_around_modifier(
# spent 913µs making 43 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 21µs/call # spent 107µs making 43 calls to Sub::Name::subname, avg 2µs/call
1110 subname(':around' => $method_modifier)
1111 );
1112 }
1113
1114 # NOTE:
1115 # the methods above used to be named like this:
1116 # ${pkg}::${method}:(before|after|around)
1117 # but this proved problematic when using one modifier
1118 # to wrap multiple methods (something which is likely
1119 # to happen pretty regularly IMO). So instead of naming
1120 # it like this, I have chosen to just name them purely
1121 # with their modifier names, like so:
1122 # :(before|after|around)
1123 # The fact is that in a stack trace, it will be fairly
1124 # evident from the context what method they are attached
1125 # to, and so don't need the fully qualified name.
1126}
1127
1128
# spent 20.5ms (3.41+17.1) within Class::MOP::Class::find_method_by_name which was called 136 times, avg 151µs/call: # 56 times (1.85ms+11.1ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 231µs/call # 41 times (805µs+3.21ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 19 of Class/MOP/Mixin/HasMethods.pm, avg 98µs/call # 16 times (339µs+1.28ms) by Moose::Meta::Class::_inline_BUILDARGS at line 325 of Moose/Meta/Class.pm, avg 101µs/call # 16 times (304µs+1.06ms) by Moose::Meta::Method::Destructor::is_needed at line 66 of Moose/Meta/Method/Destructor.pm, avg 85µs/call # 7 times (112µs+475µs) by Moose::BEGIN@43 at line 16 of Moose/Meta/Attribute/Native.pm, avg 84µs/call
sub find_method_by_name {
1129136115µs my ($self, $method_name) = @_;
113013662µs (defined $method_name && length $method_name)
1131 || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1132136295µs1361.61ms foreach my $class ($self->_method_lookup_order) {
# spent 1.61ms making 136 calls to Class::MOP::Class::_method_lookup_order, avg 12µs/call
11334391.48ms87815.5ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 12.8ms making 439 calls to Class::MOP::Mixin::HasMethods::get_method, avg 29µs/call # spent 2.74ms making 439 calls to Class::MOP::Class::initialize, avg 6µs/call
1134439405µs return $method if defined $method;
1135 }
113659131µs return;
1137}
1138
1139
# spent 4.96ms (448µs+4.52) within Class::MOP::Class::get_all_methods which was called 7 times, avg 709µs/call: # 7 times (448µs+4.52ms) by Class::MOP::MiniTrait::apply at line 17 of Class/MOP/MiniTrait.pm, avg 709µs/call
sub get_all_methods {
114074µs my $self = shift;
1141
114272µs my %methods;
1143723µs7132µs for my $class ( reverse $self->_method_lookup_order ) {
# spent 132µs making 7 calls to Class::MOP::Class::_method_lookup_order, avg 19µs/call
11441542µs15104µs my $meta = Class::MOP::Class->initialize($class);
# spent 104µs making 15 calls to Class::MOP::Class::initialize, avg 7µs/call
1145
114615356µs1014.28ms $methods{ $_->name } = $_ for $meta->_get_local_methods;
# spent 4.22ms making 15 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 281µs/call # spent 62µs making 86 calls to Class::MOP::Method::name, avg 720ns/call
1147 }
1148
1149739µs return values %methods;
1150}
1151
1152sub get_all_method_names {
1153 my $self = shift;
1154 map { $_->name } $self->get_all_methods;
1155}
1156
1157
# spent 4.23ms (835µs+3.40) within Class::MOP::Class::find_all_methods_by_name which was called 32 times, avg 132µs/call: # 16 times (442µs+1.98ms) by Moose::Meta::Class::_inline_BUILDALL at line 483 of Moose/Meta/Class.pm, avg 152µs/call # 16 times (393µs+1.41ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 116 of Moose/Meta/Method/Destructor.pm, avg 113µs/call
sub find_all_methods_by_name {
11583235µs my ($self, $method_name) = @_;
11593217µs (defined $method_name && length $method_name)
1160 || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1161327µs my @methods;
11623284µs32298µs foreach my $class ($self->_method_lookup_order) {
# spent 298µs making 32 calls to Class::MOP::Class::_method_lookup_order, avg 9µs/call
1163 # fetch the meta-class ...
116498210µs98522µs my $meta = Class::MOP::Class->initialize($class);
# spent 522µs making 98 calls to Class::MOP::Class::initialize, avg 5µs/call
116598179µs1012.58ms push @methods => {
# spent 2.26ms making 98 calls to Class::MOP::Mixin::HasMethods::has_method, avg 23µs/call # spent 312µs making 3 calls to Class::MOP::Mixin::HasMethods::get_method, avg 104µs/call
1166 name => $method_name,
1167 class => $class,
1168 code => $meta->get_method($method_name)
1169 } if $meta->has_method($method_name);
1170 }
11713288µs return @methods;
1172}
1173
1174
# spent 9.51ms (2.04+7.47) within Class::MOP::Class::find_next_method_by_name which was called 105 times, avg 91µs/call: # 62 times (1.05ms+3.72ms) by Class::MOP::Method::Inlined::can_be_inlined at line 34 of Class/MOP/Method/Inlined.pm, avg 77µs/call # 43 times (981µs+3.75ms) by Class::MOP::Class::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Class.pm:1082] at line 1059, avg 110µs/call
sub find_next_method_by_name {
117510591µs my ($self, $method_name) = @_;
117610559µs (defined $method_name && length $method_name)
1177 || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1178105316µs1051.15ms my @cpl = ($self->_method_lookup_order);
# spent 1.15ms making 105 calls to Class::MOP::Class::_method_lookup_order, avg 11µs/call
117910527µs shift @cpl; # discard ourselves
118010568µs foreach my $class (@cpl) {
1181182682µs3646.32ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 5.18ms making 182 calls to Class::MOP::Mixin::HasMethods::get_method, avg 28µs/call # spent 1.14ms making 182 calls to Class::MOP::Class::initialize, avg 6µs/call
1182182364µs return $method if defined $method;
1183 }
118424µs return;
1185}
1186
1187
# spent 50µs within Class::MOP::Class::update_meta_instance_dependencies which was called 20 times, avg 3µs/call: # 20 times (50µs+0s) by Class::MOP::Class::_superclasses_updated at line 975, avg 3µs/call
sub update_meta_instance_dependencies {
1188207µs my $self = shift;
1189
11902057µs if ( $self->{meta_instance_dependencies} ) {
1191 return $self->add_meta_instance_dependencies;
1192 }
1193}
1194
1195sub add_meta_instance_dependencies {
1196 my $self = shift;
1197
1198 $self->remove_meta_instance_dependencies;
1199
1200 my @attrs = $self->get_all_attributes();
1201
1202 my %seen;
1203 my @classes = grep { not $seen{ $_->name }++ }
1204 map { $_->associated_class } @attrs;
1205
1206 foreach my $class (@classes) {
1207 $class->add_dependent_meta_instance($self);
1208 }
1209
1210 $self->{meta_instance_dependencies} = \@classes;
1211}
1212
1213sub remove_meta_instance_dependencies {
1214 my $self = shift;
1215
1216 if ( my $classes = delete $self->{meta_instance_dependencies} ) {
1217 foreach my $class (@$classes) {
1218 $class->remove_dependent_meta_instance($self);
1219 }
1220
1221 return $classes;
1222 }
1223
1224 return;
1225
1226}
1227
1228sub add_dependent_meta_instance {
1229 my ( $self, $metaclass ) = @_;
1230 push @{ $self->{dependent_meta_instances} }, $metaclass;
1231}
1232
1233sub remove_dependent_meta_instance {
1234 my ( $self, $metaclass ) = @_;
1235 my $name = $metaclass->name;
1236 @$_ = grep { $_->name ne $name } @$_
1237 for $self->{dependent_meta_instances};
1238}
1239
1240
# spent 3.23ms (2.65+582µs) within Class::MOP::Class::invalidate_meta_instances which was called 322 times, avg 10µs/call: # 320 times (2.63ms+579µs) by Class::MOP::Class::_post_add_attribute at line 894, avg 10µs/call # 2 times (17µs+2µs) by Class::MOP::Class::remove_attribute at line 913, avg 10µs/call
sub invalidate_meta_instances {
1241322133µs my $self = shift;
1242 $_->invalidate_meta_instance()
12433222.32ms322582µs for $self, @{ $self->{dependent_meta_instances} };
# spent 582µs making 322 calls to Class::MOP::Class::invalidate_meta_instance, avg 2µs/call
1244}
1245
1246
# spent 582µs within Class::MOP::Class::invalidate_meta_instance which was called 322 times, avg 2µs/call: # 322 times (582µs+0s) by Class::MOP::Class::invalidate_meta_instances at line 1243, avg 2µs/call
sub invalidate_meta_instance {
124732264µs my $self = shift;
1248322834µs undef $self->{_meta_instance};
1249}
1250
1251# check if we can reinitialize
1252sub is_pristine {
1253 my $self = shift;
1254
1255 # if any local attr is defined
1256 return if $self->get_attribute_list;
1257
1258 # or any non-declared methods
1259 for my $method ( map { $self->get_method($_) } $self->get_method_list ) {
1260 return if $method->isa("Class::MOP::Method::Generated");
1261 # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass );
1262 }
1263
1264 return 1;
1265}
1266
1267## Class closing
1268
1269103214µs
# spent 122µs within Class::MOP::Class::is_mutable which was called 103 times, avg 1µs/call: # 70 times (97µs+0s) by Class::MOP::Class::make_immutable at line 1293, avg 1µs/call # 21 times (14µs+0s) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 238 of Moose.pm, avg 643ns/call # 9 times (9µs+0s) by Moose::Meta::Attribute::BEGIN@16 at line 712 of Moose/Util/TypeConstraints.pm, avg 956ns/call # 3 times (2µs+0s) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 274 of Moose.pm, avg 833ns/call
sub is_mutable { 1 }
127071174µs
# spent 85µs within Class::MOP::Class::is_immutable which was called 71 times, avg 1µs/call: # 71 times (85µs+0s) by Class::MOP::Class::_real_ref_name at line 122, avg 1µs/call
sub is_immutable { 0 }
1271
1272sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1273
1274
# spent 1.58ms (1.22+363µs) within Class::MOP::Class::_immutable_options which was called 70 times, avg 23µs/call: # 54 times (917µs+191µs) by Class::MOP::Class::make_immutable at line 1297, avg 21µs/call # 16 times (299µs+172µs) by Moose::Meta::Class::_immutable_options at line 757 of Moose/Meta/Class.pm, avg 29µs/call
sub _immutable_options {
127570120µs my ( $self, @args ) = @_;
1276
1277 return (
1278701.30ms280363µs inline_accessors => 1,
# spent 75µs making 70 calls to Class::MOP::Class::constructor_name, avg 1µs/call # spent 56µs making 16 calls to Moose::Meta::Class::immutable_trait, avg 4µs/call # spent 56µs making 54 calls to Class::MOP::Class::immutable_trait, avg 1µs/call # spent 48µs making 16 calls to Moose::Meta::Class::destructor_class, avg 3µs/call # spent 46µs making 16 calls to Moose::Meta::Class::constructor_class, avg 3µs/call # spent 44µs making 54 calls to Class::MOP::Class::constructor_class, avg 820ns/call # spent 37µs making 54 calls to Class::MOP::Class::destructor_class, avg 693ns/call
1279 inline_constructor => 1,
1280 inline_destructor => 0,
1281 debug => 0,
1282 immutable_trait => $self->immutable_trait,
1283 constructor_name => $self->constructor_name,
1284 constructor_class => $self->constructor_class,
1285 destructor_class => $self->destructor_class,
1286 @args,
1287 );
1288}
1289
1290
# spent 301ms (1.70+299) within Class::MOP::Class::make_immutable which was called 70 times, avg 4.29ms/call: # 21 times (469µs+75.7ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 243 of Moose.pm, avg 3.63ms/call # 14 times (349µs+21.9ms) by Moose::Exporter::BEGIN@8 at line 748 of Class/MOP.pm, avg 1.59ms/call # 9 times (220µs+40.9ms) by Moose::Meta::Attribute::BEGIN@16 at line 717 of Moose/Util/TypeConstraints.pm, avg 4.57ms/call # 5 times (114µs+793µs) by Moose::Exporter::BEGIN@8 at line 775 of Class/MOP.pm, avg 181µs/call # 3 times (46µs+8.02ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@11 at line 279 of Moose.pm, avg 2.69ms/call # 2 times (62µs+-62µs) by Class::MOP::Class::_immutable_metaclass at line 1373, avg 0s/call # once (34µs+20.9ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@13 at line 226 of lib/Bio/Roary/PostAnalysis.pm # once (31µs+20.2ms) by Bio::Roary::PostAnalysis::BEGIN@13 at line 107 of lib/Bio/Roary/InflateClusters.pm # once (25µs+15.3ms) by Bio::Roary::Main::RoaryPostAnalysis::BEGIN@17 at line 187 of lib/Bio/Roary/CommandLine/RoaryPostAnalysis.pm # once (27µs+10.4ms) by Bio::Roary::PostAnalysis::BEGIN@19 at line 117 of lib/Bio/Roary/Output/NumberOfGroups.pm # once (25µs+9.27ms) by Bio::Roary::PostAnalysis::BEGIN@22 at line 319 of lib/Bio/Roary/SplitGroups.pm # once (26µs+9.18ms) by Bio::Roary::CommandLine::RoaryPostAnalysis::BEGIN@15 at line 89 of lib/Bio/Roary/External/ProteinMuscleAlignmentFromNucleotides.pm # once (33µs+8.80ms) by Bio::Roary::PostAnalysis::BEGIN@17 at line 203 of lib/Bio/Roary/GroupStatistics.pm # once (26µs+8.11ms) by Bio::Roary::PostAnalysis::BEGIN@16 at line 326 of lib/Bio/Roary/AnnotateGroups.pm # once (24µs+7.19ms) by Bio::Roary::PostAnalysis::BEGIN@21 at line 240 of lib/Bio/Roary/Output/EmblGroups.pm # once (28µs+7.11ms) by Bio::Roary::PostAnalysis::BEGIN@18 at line 76 of lib/Bio/Roary/Output/GroupsMultifastasNucleotide.pm # once (34µs+7.04ms) by Bio::Roary::PostAnalysis::BEGIN@20 at line 353 of lib/Bio/Roary/OrderGenes.pm # once (25µs+6.64ms) by Bio::Roary::OrderGenes::BEGIN@21 at line 143 of lib/Bio/Roary/ContigsToGeneIDsFromGFF.pm # once (23µs+6.00ms) by Bio::Roary::PostAnalysis::BEGIN@14 at line 143 of lib/Bio/Roary/AnalyseGroups.pm # once (27µs+5.79ms) by Bio::Roary::Output::GroupsMultifastasNucleotide::BEGIN@23 at line 149 of lib/Bio/Roary/Output/GroupsMultifastaNucleotide.pm # once (25µs+5.43ms) by Bio::Roary::AnnotateGroups::BEGIN@21 at line 66 of lib/Bio/Roary/GeneNamesFromGFF.pm # once (25µs+4.29ms) by Bio::Roary::PostAnalysis::BEGIN@15 at line 60 of lib/Bio/Roary/GroupLabels.pm
sub make_immutable {
129170134µs my ( $self, @args ) = @_;
1292
129370150µs7097µs return $self unless $self->is_mutable;
# spent 97µs making 70 calls to Class::MOP::Class::is_mutable, avg 1µs/call
1294
129570182µs my ($file, $line) = (caller)[1..2];
1296
129770564µs140258ms $self->_initialize_immutable(
# spent 257ms making 70 calls to Class::MOP::Class::_initialize_immutable, avg 3.67ms/call # spent 1.11ms making 54 calls to Class::MOP::Class::_immutable_options, avg 21µs/call # spent 622µs making 16 calls to Moose::Meta::Class::_immutable_options, avg 39µs/call
1298 file => $file,
1299 line => $line,
1300 $self->_immutable_options(@args),
1301 );
130270198µs7040.7ms $self->_rebless_as_immutable(@args);
# spent 41.0ms making 70 calls to Class::MOP::Class::_rebless_as_immutable, avg 585µs/call, recursion: max depth 1, sum of overlapping time 284µs
1303
130470292µs return $self;
1305}
1306
1307sub make_mutable {
1308 my $self = shift;
1309
1310 if ( $self->is_immutable ) {
1311 my @args = $self->immutable_options;
1312 $self->_rebless_as_mutable();
1313 $self->_remove_inlined_code(@args);
1314 delete $self->{__immutable};
1315 return $self;
1316 }
1317 else {
1318 return;
1319 }
1320}
1321
1322
# spent 40.7ms (914µs+39.8) within Class::MOP::Class::_rebless_as_immutable which was called 70 times, avg 581µs/call: # 70 times (914µs+39.8ms) by Class::MOP::Class::make_immutable at line 1302, avg 581µs/call
sub _rebless_as_immutable {
132370134µs my ( $self, @args ) = @_;
1324
13257089µs $self->{__immutable}{original_class} = ref $self;
1326
132770646µs7039.8ms bless $self => $self->_immutable_metaclass(@args);
# spent 40.1ms making 70 calls to Class::MOP::Class::_immutable_metaclass, avg 572µs/call, recursion: max depth 1, sum of overlapping time 227µs
1328}
1329
1330
# spent 39.8ms (1.71+38.1) within Class::MOP::Class::_immutable_metaclass which was called 70 times, avg 569µs/call: # 70 times (1.71ms+38.1ms) by Class::MOP::Class::_rebless_as_immutable at line 1327, avg 569µs/call
sub _immutable_metaclass {
133170108µs my ( $self, %args ) = @_;
1332
13337038µs if ( my $class = $args{immutable_metaclass} ) {
1334 return $class;
1335 }
1336
133770304µs70109µs my $trait = $args{immutable_trait} = $self->immutable_trait
# spent 58µs making 16 calls to Moose::Meta::Class::immutable_trait, avg 4µs/call # spent 50µs making 54 calls to Class::MOP::Class::immutable_trait, avg 928ns/call
1338 || $self->_throw_exception( NoImmutableTraitSpecifiedForClass => class_name => $self->name,
1339 params => \%args
1340 );
1341
134270164µs70992µs my $meta = $self->meta;
# spent 992µs making 70 calls to Class::MOP::Object::meta, avg 14µs/call
134370202µs703.43ms my $meta_attr = $meta->find_attribute_by_name("immutable_trait");
# spent 3.43ms making 70 calls to Class::MOP::Class::find_attribute_by_name, avg 49µs/call
1344
13457010µs my $class_name;
1346
134770226µs70234µs if ( $meta_attr and $trait eq $meta_attr->default ) {
# spent 234µs making 70 calls to Class::MOP::Mixin::AttributeCore::default, avg 3µs/call
1348 # if the trait is the same as the default we try and pick a
1349 # predictable name for the immutable metaclass
1350 $class_name = 'Class::MOP::Class::Immutable::' . ref($self);
1351 }
1352 else {
1353 $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait',
1354 $trait, 'ForMetaClass', ref($self);
1355 }
1356
135770395µs70210µs return $class_name
# spent 210µs making 70 calls to Class::MOP::does_metaclass_exist, avg 3µs/call
1358 if Class::MOP::does_metaclass_exist($class_name);
1359
1360 # If the metaclass is a subclass of CMOP::Class which has had
1361 # metaclass roles applied (via Moose), then we want to make sure
1362 # that we preserve that anonymous class (see Fey::ORM for an
1363 # example of where this matters).
136426µs227µs my $meta_name = $meta->_real_ref_name;
# spent 27µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 14µs/call
1365
1366211µs22.96ms my $immutable_meta = $meta_name->create(
# spent 2.96ms making 2 calls to Class::MOP::Class::create, avg 1.48ms/call
1367 $class_name,
1368 superclasses => [ ref $self ],
1369 );
1370
137129µs229.9ms Class::MOP::MiniTrait::apply( $immutable_meta, $trait );
# spent 29.9ms making 2 calls to Class::MOP::MiniTrait::apply, avg 15.0ms/call
1372
137329µs20s $immutable_meta->make_immutable(
# spent 464µs making 2 calls to Class::MOP::Class::make_immutable, avg 232µs/call, recursion: max depth 1, sum of overlapping time 464µs
1374 inline_constructor => 0,
1375 inline_accessors => 0,
1376 );
1377
1378212µs return $class_name;
1379}
1380
1381sub _remove_inlined_code {
1382 my $self = shift;
1383
1384 $self->remove_method( $_->name ) for $self->_inlined_methods;
1385
1386 delete $self->{__immutable}{inlined_methods};
1387}
1388
1389sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } }
1390
1391
# spent 250µs within Class::MOP::Class::_add_inlined_method which was called 62 times, avg 4µs/call: # 46 times (207µs+0s) by Class::MOP::Class::_inline_constructor at line 1468, avg 4µs/call # 16 times (43µs+0s) by Class::MOP::Class::_inline_destructor at line 1510, avg 3µs/call
sub _add_inlined_method {
13926248µs my ( $self, $method ) = @_;
1393
139462255µs push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1395}
1396
1397
# spent 257ms (1.07+256) within Class::MOP::Class::_initialize_immutable which was called 70 times, avg 3.67ms/call: # 70 times (1.07ms+256ms) by Class::MOP::Class::make_immutable at line 1297, avg 3.67ms/call
sub _initialize_immutable {
139870420µs my ( $self, %args ) = @_;
1399
140070149µs $self->{__immutable}{options} = \%args;
140170451µs70256ms $self->_install_inlined_code(%args);
# spent 256ms making 70 calls to Class::MOP::Class::_install_inlined_code, avg 3.65ms/call
1402}
1403
1404
# spent 256ms (1.01+255) within Class::MOP::Class::_install_inlined_code which was called 70 times, avg 3.65ms/call: # 70 times (1.01ms+255ms) by Class::MOP::Class::_initialize_immutable at line 1401, avg 3.65ms/call
sub _install_inlined_code {
140570225µs my ( $self, %args ) = @_;
1406
1407 # FIXME
140870134µs3352.7ms $self->_inline_accessors(%args) if $args{inline_accessors};
# spent 52.7ms making 33 calls to Class::MOP::Class::_inline_accessors, avg 1.60ms/call
140970216µs46188ms $self->_inline_constructor(%args) if $args{inline_constructor};
# spent 188ms making 46 calls to Class::MOP::Class::_inline_constructor, avg 4.09ms/call
141070398µs1613.7ms $self->_inline_destructor(%args) if $args{inline_destructor};
# spent 13.7ms making 16 calls to Class::MOP::Class::_inline_destructor, avg 855µs/call
1411}
1412
1413sub _rebless_as_mutable {
1414 my $self = shift;
1415
1416 bless $self, $self->_get_mutable_metaclass_name;
1417
1418 return $self;
1419}
1420
1421
# spent 52.7ms (605µs+52.1) within Class::MOP::Class::_inline_accessors which was called 33 times, avg 1.60ms/call: # 33 times (605µs+52.1ms) by Class::MOP::Class::_install_inlined_code at line 1408, avg 1.60ms/call
sub _inline_accessors {
14223314µs my $self = shift;
1423
142433169µs33201µs foreach my $attr_name ( $self->get_attribute_list ) {
# spent 201µs making 33 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 6µs/call
142576266µs15251.9ms $self->get_attribute($attr_name)->install_accessors(1);
# spent 50.2ms making 75 calls to Class::MOP::Attribute::install_accessors, avg 670µs/call # spent 1.25ms making 1 call to Moose::Meta::Attribute::install_accessors # spent 424µs making 76 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 6µs/call
1426 }
1427}
1428
1429
# spent 188ms (1.76+186) within Class::MOP::Class::_inline_constructor which was called 46 times, avg 4.09ms/call: # 46 times (1.76ms+186ms) by Class::MOP::Class::_install_inlined_code at line 1409, avg 4.09ms/call
sub _inline_constructor {
143046177µs my ( $self, %args ) = @_;
1431
14324635µs my $name = $args{constructor_name};
1433 # A class may not even have a constructor, and that's okay.
14344611µs return unless defined $name;
1435
14364686µs461.33ms if ( $self->has_method($name) && !$args{replace_constructor} ) {
# spent 1.33ms making 46 calls to Class::MOP::Mixin::HasMethods::has_method, avg 29µs/call
1437 my $class = $self->name;
1438 warn "Not inlining a constructor for $class since it defines"
1439 . " its own constructor.\n"
1440 . "If you are certain you don't need to inline your"
1441 . " constructor, specify inline_constructor => 0 in your"
1442 . " call to $class->meta->make_immutable\n";
1443 return;
1444 }
1445
14464621µs my $constructor_class = $args{constructor_class};
1447
1448 {
14499226µs local $@;
145046111µs463.23ms use_package_optimistically($constructor_class);
# spent 3.23ms making 46 calls to Module::Runtime::use_package_optimistically, avg 70µs/call
1451 }
1452
145346583µs138172ms my $constructor = $constructor_class->new(
# spent 115ms making 16 calls to Moose::Meta::Method::Constructor::new, avg 7.16ms/call # spent 57.1ms making 30 calls to Class::MOP::Method::Constructor::new, avg 1.90ms/call # spent 60µs making 92 calls to Class::MOP::Package::name, avg 658ns/call
1454 options => \%args,
1455 metaclass => $self,
1456 is_inline => 1,
1457 package_name => $self->name,
1458 name => $name,
1459 definition_context => {
1460 description => "constructor " . $self->name . "::" . $name,
1461 file => $args{file},
1462 line => $args{line},
1463 },
1464 );
1465
146646293µs465.75ms if ( $args{replace_constructor} or $constructor->can_be_inlined ) {
# spent 5.75ms making 46 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 125µs/call
14674691µs464.08ms $self->add_method( $name => $constructor );
# spent 4.08ms making 46 calls to Class::MOP::Mixin::HasMethods::add_method, avg 89µs/call
146846112µs46207µs $self->_add_inlined_method($constructor);
# spent 207µs making 46 calls to Class::MOP::Class::_add_inlined_method, avg 4µs/call
1469 }
1470}
1471
1472
# spent 13.7ms (790µs+12.9) within Class::MOP::Class::_inline_destructor which was called 16 times, avg 855µs/call: # 16 times (790µs+12.9ms) by Class::MOP::Class::_install_inlined_code at line 1410, avg 855µs/call
sub _inline_destructor {
147316100µs my ( $self, %args ) = @_;
1474
14751621µs ( exists $args{destructor_class} && defined $args{destructor_class} )
1476 || $self->_throw_exception( NoDestructorClassSpecified => class_name => $self->name,
1477 params => \%args,
1478 );
1479
14801642µs16423µs if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) {
# spent 423µs making 16 calls to Class::MOP::Mixin::HasMethods::has_method, avg 26µs/call
1481 my $class = $self->name;
1482 warn "Not inlining a destructor for $class since it defines"
1483 . " its own destructor.\n";
1484 return;
1485 }
1486
14871612µs my $destructor_class = $args{destructor_class};
1488
1489 {
14903213µs local $@;
14911655µs161.16ms use_package_optimistically($destructor_class);
# spent 1.16ms making 16 calls to Module::Runtime::use_package_optimistically, avg 73µs/call
1492 }
1493
149416130µs161.60ms return unless $destructor_class->is_needed($self);
# spent 1.60ms making 16 calls to Moose::Meta::Method::Destructor::is_needed, avg 100µs/call
1495
149616198µs487.31ms my $destructor = $destructor_class->new(
# spent 7.29ms making 16 calls to Moose::Meta::Method::Destructor::new, avg 456µs/call # spent 18µs making 32 calls to Class::MOP::Package::name, avg 566ns/call
1497 options => \%args,
1498 metaclass => $self,
1499 package_name => $self->name,
1500 name => 'DESTROY',
1501 definition_context => {
1502 description => "destructor " . $self->name . "::DESTROY",
1503 file => $args{file},
1504 line => $args{line},
1505 },
1506 );
1507
15081684µs161.14ms if ( $args{replace_destructor} or $destructor->can_be_inlined ) {
# spent 1.14ms making 16 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 72µs/call
15091628µs161.20ms $self->add_method( 'DESTROY' => $destructor );
# spent 1.20ms making 16 calls to Class::MOP::Mixin::HasMethods::add_method, avg 75µs/call
15101625µs1643µs $self->_add_inlined_method($destructor);
# spent 43µs making 16 calls to Class::MOP::Class::_add_inlined_method, avg 3µs/call
1511 }
1512}
1513
1514114µs1;
1515
1516# ABSTRACT: Class Meta Object
1517
1518__END__
 
# spent 8.83ms (6.93+1.89) within Class::MOP::Class::CORE:sort which was called 92 times, avg 96µs/call: # 46 times (3.51ms+982µs) by Class::MOP::Class::_eval_environment at line 709, avg 98µs/call # 46 times (3.42ms+912µs) by Class::MOP::Class::_inline_slot_initializers at line 593, avg 94µs/call
sub Class::MOP::Class::CORE:sort; # opcode