← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm
StatementsExecuted 6235905 statements in 7.68s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
123544224148.55s10.7sClass::MOP::Class::::initializeClass::MOP::Class::initialize (recurses: max depth 2, inclusive time 670µs)
5169416.6ms27.8msClass::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
3172114.5ms88.4msClass::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
6421113.7ms18.1msClass::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
1162112.6ms13.6msClass::MOP::Class::::CORE:sortClass::MOP::Class::CORE:sort (opcode)
271119.34ms24.5msClass::MOP::Class::::_inline_init_attr_from_constructorClass::MOP::Class::_inline_init_attr_from_constructor
82226.19ms6.52msClass::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
107116.18ms28.6msClass::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
240116.09ms537msClass::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
58114.99ms5.25msClass::MOP::Class::::_inline_preserve_weak_metaclassesClass::MOP::Class::_inline_preserve_weak_metaclasses
360113.89ms5.94msClass::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
468223.89ms81.1msClass::MOP::Class::::_inline_slot_initializerClass::MOP::Class::_inline_slot_initializer
969423.84ms5.88msClass::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
159213.02ms52.4msClass::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility (recurses: max depth 1, inclusive time 205µs)
207662.83ms30.6msClass::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
200432.05ms11.6msClass::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
278771.98ms71.6msClass::MOP::Class::::new_objectClass::MOP::Class::new_object
453221.90ms2.79msClass::MOP::Class::::_inline_default_valueClass::MOP::Class::_inline_default_value
105111.73ms42.6msClass::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance (recurses: max depth 1, inclusive time 249µs)
160111.65ms22.7msClass::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
58111.57ms220msClass::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
8481051.32ms24.1msClass::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
82111.30ms31.5msClass::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass (recurses: max depth 1, inclusive time 130µs)
58111.28ms91.3msClass::MOP::Class::::_inline_slot_initializersClass::MOP::Class::_inline_slot_initializers
58221.28ms14.1msClass::MOP::Class::::_eval_environmentClass::MOP::Class::_eval_environment
241211.25ms1.55msClass::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
1111.15ms1.26msClass::MOP::Class::::BEGIN@7Class::MOP::Class::BEGIN@7
8234321.12ms342msClass::MOP::Class::::make_immutableClass::MOP::Class::make_immutable (recurses: max depth 1, inclusive time 233µs)
282211.09ms7.81msClass::MOP::Class::::_inline_init_attr_from_defaultClass::MOP::Class::_inline_init_attr_from_default
56221.05ms9.86msClass::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
111994µs2.63msClass::MOP::Class::::BEGIN@9Class::MOP::Class::BEGIN@9
47041989µs3.91msClass::MOP::Class::::_method_lookup_orderClass::MOP::Class::_method_lookup_order
2811984µs32.5msClass::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
111947µs1.08msClass::MOP::Class::::BEGIN@8Class::MOP::Class::BEGIN@8
6621903µs12.2msClass::MOP::Class::::__ANON__[:1082]Class::MOP::Class::__ANON__[:1082]
36011890µs6.84msClass::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
8811825µs29.9msClass::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility (recurses: max depth 1, inclusive time 128µs)
5811807µs114msClass::MOP::Class::::_inline_new_objectClass::MOP::Class::_inline_new_object
8322785µs2.84msClass::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
8211778µs302msClass::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
8211771µs303msClass::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
5033732µs3.03msClass::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list (recurses: max depth 4, inclusive time 1.67ms)
17841677µs1.90msClass::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
24011646µs2.62msClass::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
5411574µs2.16msClass::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
6611563µs563µsClass::MOP::Class::::_newClass::MOP::Class::_new
10711554µs2.61msClass::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
111520µs1.13msClass::MOP::Class::::BEGIN@10Class::MOP::Class::BEGIN@10
8211498µs31.9msClass::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable (recurses: max depth 1, inclusive time 145µs)
13222453µs95.2msClass::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
6011427µs1.13msClass::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
6222408µs12.8msClass::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
3311401µs48.8msClass::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
19532400µs400µsClass::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
5811398µs546µsClass::MOP::Class::::_inline_fallback_constructorClass::MOP::Class::_inline_fallback_constructor
24111295µs295µsClass::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
5811273µs1.71msClass::MOP::Class::::_inline_create_instanceClass::MOP::Class::_inline_create_instance
711270µs2.47msClass::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
8621250µs250µsClass::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
5811250µs1.96msClass::MOP::Class::::_inline_generate_instanceClass::MOP::Class::_inline_generate_instance
1222248µs23.3msClass::MOP::Class::::createClass::MOP::Class::create
6011221µs1.35msClass::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
111211µs260µsClass::MOP::Class::::BEGIN@11Class::MOP::Class::BEGIN@11
5411123µs123µsClass::MOP::Class::::_superclass_metasClass::MOP::Class::_superclass_metas
541194µs94µsClass::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
1154371µs71µsClass::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
911163µs63µsClass::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
301156µs56µsClass::MOP::Class::::_inline_paramsClass::MOP::Class::_inline_params
301148µs48µsClass::MOP::Class::::_generate_fallback_constructorClass::MOP::Class::_generate_fallback_constructor
11144µs279µsClass::MOP::Class::::remove_attributeClass::MOP::Class::remove_attribute
41132µs923µsClass::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
301118µs18µsClass::MOP::Class::::_inline_extra_initClass::MOP::Class::_inline_extra_init
11117µs52µsClass::MOP::Class::::BEGIN@18Class::MOP::Class::BEGIN@18
11116µs20µsClass::MOP::Class::::BEGIN@5Class::MOP::Class::BEGIN@5
1118µs17µsClass::MOP::Class::::BEGIN@4Class::MOP::Class::BEGIN@4
1116µs27µsClass::MOP::Class::::BEGIN@13Class::MOP::Class::BEGIN@13
1116µs15µsClass::MOP::Class::::BEGIN@14Class::MOP::Class::BEGIN@14
1116µs22µsClass::MOP::Class::::BEGIN@16Class::MOP::Class::BEGIN@16
1116µs2.83msClass::MOP::Class::::BEGIN@20Class::MOP::Class::BEGIN@20
1115µs27µsClass::MOP::Class::::BEGIN@17Class::MOP::Class::BEGIN@17
1115µs22µsClass::MOP::Class::::BEGIN@15Class::MOP::Class::BEGIN@15
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::::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;
21600nsour $VERSION = '2.1604';
3
4228µs227µs
# spent 17µs (8+9) within Class::MOP::Class::BEGIN@4 which was called: # once (8µs+9µs) by Class::MOP::BEGIN@18 at line 4
use strict;
# spent 17µs making 1 call to Class::MOP::Class::BEGIN@4 # spent 9µs making 1 call to strict::import
5219µs223µs
# spent 20µs (16+4) within Class::MOP::Class::BEGIN@5 which was called: # once (16µs+4µs) by Class::MOP::BEGIN@18 at line 5
use warnings;
# spent 20µs making 1 call to Class::MOP::Class::BEGIN@5 # spent 4µs making 1 call to warnings::import
6
7294µs11.26ms
# spent 1.26ms (1.15+107µs) within Class::MOP::Class::BEGIN@7 which was called: # once (1.15ms+107µs) by Class::MOP::BEGIN@18 at line 7
use Class::MOP::Instance;
# spent 1.26ms making 1 call to Class::MOP::Class::BEGIN@7
82125µs11.08ms
# spent 1.08ms (947µs+135µs) within Class::MOP::Class::BEGIN@8 which was called: # once (947µs+135µs) by Class::MOP::BEGIN@18 at line 8
use Class::MOP::Method::Wrapped;
# spent 1.08ms making 1 call to Class::MOP::Class::BEGIN@8
9288µs12.63ms
# spent 2.63ms (994µs+1.64) within Class::MOP::Class::BEGIN@9 which was called: # once (994µs+1.64ms) by Class::MOP::BEGIN@18 at line 9
use Class::MOP::Method::Accessor;
# spent 2.63ms making 1 call to Class::MOP::Class::BEGIN@9
10288µs11.13ms
# spent 1.13ms (520µs+605µs) within Class::MOP::Class::BEGIN@10 which was called: # once (520µs+605µs) by Class::MOP::BEGIN@18 at line 10
use Class::MOP::Method::Constructor;
# spent 1.13ms making 1 call to Class::MOP::Class::BEGIN@10
11278µs1260µs
# spent 260µs (211+50) within Class::MOP::Class::BEGIN@11 which was called: # once (211µs+50µs) by Class::MOP::BEGIN@18 at line 11
use Class::MOP::MiniTrait;
# spent 260µs making 1 call to Class::MOP::Class::BEGIN@11
12
13221µs248µs
# spent 27µs (6+21) within Class::MOP::Class::BEGIN@13 which was called: # once (6µs+21µs) by Class::MOP::BEGIN@18 at line 13
use Carp 'confess';
# spent 27µs making 1 call to Class::MOP::Class::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14219µs224µs
# spent 15µs (6+9) within Class::MOP::Class::BEGIN@14 which was called: # once (6µs+9µs) by Class::MOP::BEGIN@18 at line 14
use Module::Runtime 'use_package_optimistically';
# spent 15µs making 1 call to Class::MOP::Class::BEGIN@14 # spent 9µs making 1 call to Module::Runtime::import
15219µs239µs
# spent 22µs (5+17) within Class::MOP::Class::BEGIN@15 which was called: # once (5µs+17µs) by Class::MOP::BEGIN@18 at line 15
use Scalar::Util 'blessed';
# spent 22µs making 1 call to Class::MOP::Class::BEGIN@15 # spent 17µs making 1 call to Exporter::import
16218µs238µs
# spent 22µs (6+16) within Class::MOP::Class::BEGIN@16 which was called: # once (6µs+16µs) by Class::MOP::BEGIN@18 at line 16
use Sub::Name 'subname';
# spent 22µs making 1 call to Class::MOP::Class::BEGIN@16 # spent 16µs making 1 call to Exporter::import
17223µs248µs
# spent 27µs (5+21) within Class::MOP::Class::BEGIN@17 which was called: # once (5µs+21µs) by Class::MOP::BEGIN@18 at line 17
use Try::Tiny;
# spent 27µs making 1 call to Class::MOP::Class::BEGIN@17 # spent 21µs making 1 call to Exporter::import
18346µs371µs
# spent 52µs (17+34) within Class::MOP::Class::BEGIN@18 which was called: # once (17µs+34µs) by Class::MOP::BEGIN@18 at line 18
use List::Util 1.33 'all';
# spent 52µs making 1 call to Class::MOP::Class::BEGIN@18 # spent 11µs making 1 call to UNIVERSAL::VERSION # spent 8µs making 1 call to List::Util::import
19
2014µs12.82ms
# spent 2.83ms (6µs+2.82) within Class::MOP::Class::BEGIN@20 which was called: # once (6µs+2.82ms) by Class::MOP::BEGIN@18 at line 23
use parent 'Class::MOP::Module',
# spent 2.82ms making 1 call to parent::import
21 'Class::MOP::Mixin::HasAttributes',
22 'Class::MOP::Mixin::HasMethods',
2314.64ms12.83ms 'Class::MOP::Mixin::HasOverloads';
# spent 2.83ms making 1 call to Class::MOP::Class::BEGIN@20
24
25# Creation
26
27
# spent 10.7s (8.55+2.13) within Class::MOP::Class::initialize which was called 1235442 times, avg 9µs/call: # 1230964 times (8.54s+2.09s) by Moose::Object::does at line 120 of Moose/Object.pm, avg 9µs/call # 2210 times (5.46ms+1.20ms) by Class::MOP::Class::get_all_attributes at line 936, avg 3µs/call # 566 times (1.54ms+397µs) by Class::MOP::Class::find_method_by_name at line 1133, avg 3µs/call # 495 times (1.77ms+7.59ms) by Class::MOP::Mixin::meta or Class::MOP::Object::meta or Moose::Meta::Class::__ANON__::SERIAL::1::meta or Moose::Meta::Class::__ANON__::SERIAL::7::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 or PONAPI::Builder::Document::meta or PONAPI::Builder::Errors::meta or PONAPI::Builder::Links::meta or PONAPI::Builder::Relationship::meta or PONAPI::Builder::Resource::Identifier::meta or PONAPI::Builder::Resource::Null::meta or PONAPI::Builder::Resource::meta or PONAPI::DAO::Request::Create::meta or PONAPI::DAO::Request::CreateRelationships::meta or PONAPI::DAO::Request::Delete::meta or PONAPI::DAO::Request::DeleteRelationships::meta or PONAPI::DAO::Request::Retrieve::meta or PONAPI::DAO::Request::RetrieveAll::meta or PONAPI::DAO::Request::RetrieveByRelationship::meta or PONAPI::DAO::Request::RetrieveRelationships::meta or PONAPI::DAO::Request::Update::meta or PONAPI::DAO::Request::UpdateRelationships::meta or PONAPI::DAO::Request::meta or PONAPI::DAO::meta or PONAPI::Exception::meta or PONAPI::Server::ConfigReader::meta or Test::PONAPI::Repository::MockDB::Loader::meta or Test::PONAPI::Repository::MockDB::Table::Articles::meta or Test::PONAPI::Repository::MockDB::Table::Comments::meta or Test::PONAPI::Repository::MockDB::Table::People::meta or Test::PONAPI::Repository::MockDB::Table::Relationships::meta or Test::PONAPI::Repository::MockDB::Table::meta or Test::PONAPI::Repository::MockDB::meta at line 42 of Class/MOP/Method/Meta.pm, avg 19µs/call # 275 times (807µs+216µs) by Class::MOP::Class::find_next_method_by_name at line 1181, avg 4µs/call # 196 times (497µs+119µs) by Class::MOP::Class::find_all_methods_by_name at line 1164, avg 3µs/call # 146 times (497µs+511µs) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 7µs/call # 107 times (320µs+-86µs) by Class::MOP::Class::_fix_metaclass_incompatibility at line 291, avg 2µs/call # 105 times (278µs+81µs) by Moose::Meta::Attribute::_new or Moose::Meta::Method::_new at line 7 of (eval 45)[Eval/Closure.pm:144], avg 3µs/call # 83 times (217µs+45µs) by Class::MOP::Class::find_attribute_by_name at line 926, avg 3µs/call # 59 times (203µs+3.93ms) by Class::MOP::Mixin::meta at line 12 of Class/MOP/Mixin.pm, avg 70µs/call # 52 times (189µs+52µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 5µs/call # 40 times (99µs+21µs) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 3µs/call # 39 times (265µs+23.2ms) by Moose::Meta::Class::initialize at line 64 of Moose/Meta/Class.pm, avg 601µs/call # 24 times (65µs+521µs) by Class::MOP::Method::_new at line 59 of Class/MOP/Method.pm, avg 24µs/call # 23 times (57µs+13µs) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 3µs/call # 19 times (120µs+1.19ms) by metaclass::import at line 38 of metaclass.pm, avg 69µs/call # 15 times (39µs+9µs) by Class::MOP::Class::get_all_methods at line 1144, avg 3µs/call # 12 times (69µs+5.74ms) by Class::MOP::MiniTrait::apply at line 14 of Class/MOP/MiniTrait.pm, avg 484µs/call # 7 times (33µs+326µs) by Moose::BEGIN@43 at line 12 of Moose/Meta/Attribute/Native.pm, avg 51µs/call # 2 times (12µs+140µs) by Class::MOP::Package::create at line 67 of Class/MOP/Package.pm, avg 76µs/call # once (3µs+700ns) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm # once (3µs+600ns) by Class::MOP::Attribute::set_initial_value at line 275 of Class/MOP/Attribute.pm # once (3µs+700ns) by Moose::Meta::Attribute::_weaken_value at line 796 of Moose/Meta/Attribute.pm
sub initialize {
281235442397ms my $class = shift;
29
301235442190ms my $package_name;
31
321235442752ms if ( @_ % 2 ) {
33 $package_name = shift;
34 } else {
35 my %options = @_;
36 $package_name = $options{package};
37 }
38
391235442474ms ($package_name && !ref($package_name))
40 || ($class||__PACKAGE__)->_throw_exception( InitializeTakesUnBlessedPackageName => package_name => $package_name );
4112354425.73s12355472.13s return Class::MOP::get_metaclass_by_name($package_name)
# spent 2.09s making 1235442 calls to Class::MOP::get_metaclass_by_name, avg 2µs/call # spent 42.8ms making 105 calls to Class::MOP::Class::_construct_class_instance, avg 408µs/call, recursion: max depth 1, sum of overlapping time 249µs
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 42.6ms (1.73+40.9) within Class::MOP::Class::_construct_class_instance which was called 105 times, avg 406µs/call: # 105 times (1.73ms+40.9ms) by Class::MOP::Class::initialize at line 41, avg 406µs/call
sub _construct_class_instance {
7110542µs my $class = shift;
72105205µs my $options = @_ == 1 ? $_[0] : {@_};
7310552µs my $package_name = $options->{package};
7410541µ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
8210588µs10562µs if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) {
# spent 62µs making 105 calls to Class::MOP::get_metaclass_by_name, avg 593ns/call
83 return $meta;
84 }
85
86 $class
8710550µs9175µs = ref $class
# spent 175µs making 9 calls to Class::MOP::Class::_real_ref_name, avg 19µs/call
88 ? $class->_real_ref_name
89 : $class;
90
91 # now create the metaclass
9210512µs my $meta;
93105133µs66563µs if ($class eq 'Class::MOP::Class') {
# spent 563µs making 66 calls to Class::MOP::Class::_new, avg 9µ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
10139139µs7819.9ms $meta = $class->meta->_construct_instance($options)
# spent 19.5ms making 39 calls to Class::MOP::Class::_construct_instance, avg 499µs/call # spent 418µs making 39 calls to Class::MOP::Object::meta, avg 11µs/call
102 }
103
104 # and check the metaclass compatibility
105105203µs10520.0ms $meta->_check_metaclass_compatibility();
# spent 20.2ms making 105 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 193µs/call, recursion: max depth 1, sum of overlapping time 205µs
106
107105146µs105200µs Class::MOP::store_metaclass_by_name($package_name, $meta);
# spent 200µs making 105 calls to Class::MOP::store_metaclass_by_name, avg 2µs/call
108
109 # NOTE:
110 # we need to weaken any anon classes
111 # so that they can call DESTROY properly
11210549µs Class::MOP::weaken_metaclass($package_name) if $options->{weaken};
113
114105248µs $meta;
115}
116
117
# spent 1.90ms (677µs+1.23) within Class::MOP::Class::_real_ref_name which was called 178 times, avg 11µs/call: # 107 times (451µs+765µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 336, avg 11µs/call # 60 times (173µs+313µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 250, avg 8µs/call # 9 times (43µs+132µs) by Class::MOP::Class::_construct_class_instance at line 87, avg 19µs/call # 2 times (10µs+15µs) by Class::MOP::Class::_immutable_metaclass at line 1364, avg 13µs/call
sub _real_ref_name {
11817834µ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
122178608µs2651.23ms return $self->is_immutable
# spent 654µs making 59 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 11µs/call # spent 358µs making 28 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 13µs/call # spent 152µs making 87 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 2µs/call # spent 63µs making 91 calls to Class::MOP::Class::is_immutable, avg 690ns/call
123 ? $self->_get_mutable_metaclass_name()
124 : ref $self;
125}
126
127
# spent 563µs within Class::MOP::Class::_new which was called 66 times, avg 9µs/call: # 66 times (563µs+0s) by Class::MOP::Class::_construct_class_instance at line 93, avg 9µs/call
sub _new {
1286617µs my $class = shift;
129
1306614µs return Class::MOP::Class->initialize($class)->new_object(@_)
131 if $class ne __PACKAGE__;
132
1336622µs my $options = @_ == 1 ? $_[0] : {@_};
134
13566578µ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{
18224µ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
191195609µs
# spent 400µs within Class::MOP::Class::_base_metaclasses which was called 195 times, avg 2µs/call: # 112 times (242µs+0s) by Moose::Meta::Class::_base_metaclasses at line 628 of Moose/Meta/Class.pm, avg 2µs/call # 47 times (106µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 324, avg 2µs/call # 36 times (52µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 202, avg 1µs/call
sub _base_metaclasses { %base_metaclass }
192}
193
194
# spent 52.4ms (3.02+49.3) within Class::MOP::Class::_check_metaclass_compatibility which was called 159 times, avg 329µs/call: # 105 times (755µs+19.3ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 191µs/call # 54 times (2.26ms+30.1ms) by Class::MOP::Class::superclasses at line 966, avg 599µs/call
sub _check_metaclass_compatibility {
19515931µs my $self = shift;
196
197159424µs1593.09ms my @superclasses = $self->superclasses
# spent 1.94ms making 68 calls to Class::MOP::Class::superclasses, avg 28µs/call, recursion: max depth 1, sum of overlapping time 28µs # spent 3.36ms making 91 calls to Moose::Meta::Class::superclasses, avg 37µs/call, recursion: max depth 2, sum of overlapping time 2.18ms
198 or return;
199
20088130µs8829.9ms $self->_fix_metaclass_incompatibility(@superclasses);
# spent 30.1ms making 88 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 342µs/call, recursion: max depth 1, sum of overlapping time 128µs
201
20288213µs881.11ms my %base_metaclass = $self->_base_metaclasses;
# spent 1.05ms making 52 calls to Moose::Meta::Class::_base_metaclasses, avg 20µs/call # spent 52µs making 36 calls to Class::MOP::Class::_base_metaclasses, avg 1µs/call
203
204 # this is always okay ...
205 return
206 if ref($self) eq 'Class::MOP::Class'
207 && all {
2082164.54ms21678µs my $meta = $self->$_;
# spent 14µs making 36 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 386ns/call # spent 13µs making 36 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 372ns/call # spent 13µs making 36 calls to Class::MOP::Class::constructor_class, avg 364ns/call # spent 13µs making 36 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 358ns/call # spent 12µs making 36 calls to Class::MOP::Class::destructor_class, avg 344ns/call # spent 12µs making 36 calls to Class::MOP::Class::instance_metaclass, avg 333ns/call
209216212µs !defined($meta) || $meta eq $base_metaclass{$_};
210 }
21188200µs364.68ms keys %base_metaclass;
# spent 4.68ms making 36 calls to List::Util::all, avg 130µs/call
212
2135235µs for my $superclass (@superclasses) {
21460115µs601.35ms $self->_check_class_metaclass_compatibility($superclass);
# spent 1.35ms making 60 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 22µs/call
215 }
216
21752190µs for my $metaclass_type ( keys %base_metaclass ) {
218312601µs312200µs next unless defined $self->$metaclass_type;
# spent 54µs making 52 calls to Moose::Meta::Class::destructor_class, avg 1µs/call # spent 53µs making 52 calls to Moose::Meta::Class::constructor_class, avg 1µs/call # spent 26µs making 52 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 500ns/call # spent 23µs making 52 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 438ns/call # spent 23µs making 52 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 435ns/call # spent 22µs making 52 calls to Class::MOP::Class::instance_metaclass, avg 419ns/call
219312146µs for my $superclass (@superclasses) {
220360420µs3606.84ms $self->_check_single_metaclass_compatibility( $metaclass_type,
# spent 6.84ms making 360 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 19µs/call
221 $superclass );
222 }
223 }
224}
225
226
# spent 1.35ms (221µs+1.13) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 60 times, avg 22µs/call: # 60 times (221µs+1.13ms) by Class::MOP::Class::_check_metaclass_compatibility at line 214, avg 22µs/call
sub _check_class_metaclass_compatibility {
2276019µs my $self = shift;
2286023µs my ( $superclass_name ) = @_;
229
23060168µs601.13ms if (!$self->_class_metaclass_is_compatible($superclass_name)) {
# spent 1.13ms making 60 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 19µ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 1.13ms (427µs+700µs) within Class::MOP::Class::_class_metaclass_is_compatible which was called 60 times, avg 19µs/call: # 60 times (427µs+700µs) by Class::MOP::Class::_check_class_metaclass_compatibility at line 230, avg 19µs/call
sub _class_metaclass_is_compatible {
2446015µs my $self = shift;
2456016µs my ( $superclass_name ) = @_;
246
2476063µs6042µs my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 42µs making 60 calls to Class::MOP::get_metaclass_by_name, avg 692ns/call
248 || return 1;
249
2506059µs60486µs my $super_meta_name = $super_meta->_real_ref_name;
# spent 486µs making 60 calls to Class::MOP::Class::_real_ref_name, avg 8µs/call
251
25260151µs60172µs return $self->_is_compatible_with($super_meta_name);
# spent 172µs making 60 calls to Class::MOP::Object::_is_compatible_with, avg 3µs/call
253}
254
255
# spent 6.84ms (890µs+5.94) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 360 times, avg 19µs/call: # 360 times (890µs+5.94ms) by Class::MOP::Class::_check_metaclass_compatibility at line 220, avg 19µs/call
sub _check_single_metaclass_compatibility {
25636061µs my $self = shift;
257360105µs my ( $metaclass_type, $superclass_name ) = @_;
258
259360689µs3605.94ms if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) {
# spent 5.94ms making 360 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 17µ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 5.94ms (3.89+2.05) within Class::MOP::Class::_single_metaclass_is_compatible which was called 360 times, avg 17µs/call: # 360 times (3.89ms+2.05ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 259, avg 17µs/call
sub _single_metaclass_is_compatible {
27036037µs my $self = shift;
27136067µs my ( $metaclass_type, $superclass_name ) = @_;
272
273360195µs360200µs my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 200µs making 360 calls to Class::MOP::get_metaclass_by_name, avg 556ns/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
278360704µs360197µs return 1 unless $super_meta->can($metaclass_type);
# spent 197µs making 360 calls to UNIVERSAL::can, avg 548ns/call
279 # for instance, Moose::Meta::Class has a destructor_class, but
280 # Class::MOP::Class doesn't - this shouldn't be an error
281360611µs360173µs return 1 unless defined $super_meta->$metaclass_type;
# spent 34µs making 42 calls to Moose::Meta::Class::constructor_class, avg 802ns/call # spent 33µs making 60 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 557ns/call # spent 33µs making 42 calls to Moose::Meta::Class::destructor_class, avg 788ns/call # spent 22µs making 60 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 367ns/call # spent 19µs making 60 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 313ns/call # spent 19µs making 60 calls to Class::MOP::Class::instance_metaclass, avg 312ns/call # spent 6µs making 18 calls to Class::MOP::Class::constructor_class, avg 361ns/call # spent 6µs making 18 calls to Class::MOP::Class::destructor_class, avg 361ns/call
282 # if metaclass is defined in superclass but not here, it's not compatible
283 # this is a really odd case
284342502µs342155µs return 0 unless defined $self->$metaclass_type;
# spent 55µs making 60 calls to Moose::Meta::Class::constructor_class, avg 913ns/call # spent 30µs making 42 calls to Moose::Meta::Class::destructor_class, avg 702ns/call # spent 18µs making 60 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 303ns/call # spent 18µs making 60 calls to Class::MOP::Class::instance_metaclass, avg 295ns/call # spent 18µs making 60 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 295ns/call # spent 17µs making 60 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 290ns/call
285
2863421.62ms10261.33ms return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type);
# spent 1.06ms making 342 calls to Class::MOP::Object::_is_compatible_with, avg 3µs/call # spent 70µs making 102 calls to Moose::Meta::Class::constructor_class, avg 686ns/call # spent 60µs making 84 calls to Moose::Meta::Class::destructor_class, avg 713ns/call # spent 35µs making 120 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 291ns/call # spent 33µs making 120 calls to Class::MOP::Class::instance_metaclass, avg 276ns/call # spent 33µs making 120 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 273ns/call # spent 32µs making 120 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 268ns/call # spent 6µs making 18 calls to Class::MOP::Class::constructor_class, avg 339ns/call
287}
288
289
# spent 29.9ms (825µs+29.1) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 88 times, avg 340µs/call: # 88 times (825µs+29.1ms) by Class::MOP::Class::_check_metaclass_compatibility at line 200, avg 340µs/call
sub _fix_metaclass_incompatibility {
2908821µs my $self = shift;
291195265µs107235µs my @supers = map { Class::MOP::Class->initialize($_) } @_;
# spent 652µs making 107 calls to Class::MOP::Class::initialize, avg 6µs/call, recursion: max depth 2, sum of overlapping time 417µs
292
2938829µs my $necessary = 0;
2948854µs for my $super (@supers) {
295107169µs10728.6ms $necessary = 1
# spent 28.6ms making 107 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 267µs/call
296 if $self->_can_fix_metaclass_incompatibility($super);
297 }
29888173µ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 28.6ms (6.18+22.4) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 107 times, avg 267µs/call: # 107 times (6.18ms+22.4ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 295, avg 267µs/call
sub _can_fix_metaclass_incompatibility {
31910729µs my $self = shift;
32010728µs my ($super_meta) = @_;
321
322107135µs1072.61ms return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta);
# spent 2.61ms making 107 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 24µs/call
323
324107274µs1071.72ms my %base_metaclass = $self->_base_metaclasses;
# spent 1.62ms making 60 calls to Moose::Meta::Class::_base_metaclasses, avg 27µs/call # spent 106µs making 47 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call
325107119µs for my $metaclass_type (keys %base_metaclass) {
326642666µs64218.1ms return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type);
# spent 18.1ms making 642 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 28µs/call
327 }
328
329107237µs return;
330}
331
332
# spent 2.61ms (554µs+2.05) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 107 times, avg 24µs/call: # 107 times (554µs+2.05ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 322, avg 24µs/call
sub _class_metaclass_can_be_made_compatible {
33310721µs my $self = shift;
33410721µs my ($super_meta) = @_;
335
336107452µs2142.05ms return $self->_can_be_made_compatible_with($super_meta->_real_ref_name);
# spent 1.22ms making 107 calls to Class::MOP::Class::_real_ref_name, avg 11µs/call # spent 837µs making 107 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 8µs/call
337}
338
339
# spent 18.1ms (13.7+4.40) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 642 times, avg 28µs/call: # 642 times (13.7ms+4.40ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 326, avg 28µs/call
sub _single_metaclass_can_be_made_compatible {
340642100µs my $self = shift;
341642130µs my ($super_meta, $metaclass_type) = @_;
342
3436421.62ms642497µs my $specific_meta = $self->$metaclass_type;
# spent 117µs making 60 calls to Moose::Meta::Class::constructor_class, avg 2µs/call # spent 110µs making 60 calls to Moose::Meta::Class::destructor_class, avg 2µs/call # spent 68µs making 107 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 636ns/call # spent 56µs making 107 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 521ns/call # spent 56µs making 107 calls to Class::MOP::Class::instance_metaclass, avg 519ns/call # spent 53µs making 107 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 494ns/call # spent 19µs making 47 calls to Class::MOP::Class::destructor_class, avg 413ns/call # spent 18µs making 47 calls to Class::MOP::Class::constructor_class, avg 391ns/call
344
3456421.34ms642398µs return unless $super_meta->can($metaclass_type);
# spent 398µs making 642 calls to UNIVERSAL::can, avg 619ns/call
3466421.21ms642294µs my $super_specific_meta = $super_meta->$metaclass_type;
# spent 41µs making 42 calls to Moose::Meta::Class::constructor_class, avg 976ns/call # spent 41µs making 107 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 379ns/call # spent 39µs making 107 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 366ns/call # spent 38µs making 107 calls to Class::MOP::Class::instance_metaclass, avg 358ns/call # spent 37µs making 42 calls to Moose::Meta::Class::destructor_class, avg 886ns/call # spent 36µs making 107 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 336ns/call # spent 34µs making 65 calls to Class::MOP::Class::constructor_class, avg 523ns/call # spent 27µs making 65 calls to Class::MOP::Class::destructor_class, avg 420ns/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
350642172µ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
35457739µs return 1 unless defined $specific_meta;
355
3565771.41ms5773.21ms return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta);
# spent 3.21ms making 577 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 6µ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 23.3ms (248µs+23.1) within Class::MOP::Class::create which was called 12 times, avg 1.94ms/call: # 10 times (204µs+21.5ms) by Moose::Meta::Class::create at line 87 of Moose/Meta/Class.pm, avg 2.17ms/call # 2 times (44µs+1.58ms) by Class::MOP::Class::_immutable_metaclass at line 1366, avg 815µs/call
sub create {
412125µs my $class = shift;
413129µs my @args = @_;
414
4151211µs unshift @args, 'package' if @args % 2 == 1;
4161215µs my %options = @args;
417
4181213µs (ref $options{superclasses} eq 'ARRAY')
419 || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfSuperclasses => class => $class,
420 params => \%options
421 )
422 if exists $options{superclasses};
423
424127µs (ref $options{attributes} eq 'ARRAY')
425 || __PACKAGE__->_throw_exception( CreateMOPClassTakesArrayRefOfAttributes => class => $class,
426 params => \%options
427 )
428 if exists $options{attributes};
429
430126µs (ref $options{methods} eq 'HASH')
431 || __PACKAGE__->_throw_exception( CreateMOPClassTakesHashRefOfMethods => class => $class,
432 params => \%options
433 )
434 if exists $options{methods};
435
4361210µs my $package = delete $options{package};
437126µs my $superclasses = delete $options{superclasses};
438125µs my $attributes = delete $options{attributes};
439127µs my $methods = delete $options{methods};
440127µs my $meta_name = exists $options{meta_name}
441 ? delete $options{meta_name}
442 : 'meta';
443
4441234µs129.71ms my $meta = $class->SUPER::create($package => %options);
# spent 9.71ms making 12 calls to Class::MOP::Module::create, avg 809µs/call
445
4461226µs124.30ms $meta->_add_meta_method($meta_name)
# spent 4.30ms making 12 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 359µs/call
447 if defined $meta_name;
448
4491221µs12566µs $meta->superclasses(@{$superclasses})
# spent 566µs making 2 calls to Class::MOP::Class::superclasses, avg 283µs/call # spent 8.51ms making 10 calls to Moose::Meta::Class::superclasses, avg 851µs/call, recursion: max depth 1, sum of overlapping time 8.51ms
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.
456125µs if (defined $attributes) {
457 foreach my $attr (@{$attributes}) {
458 $meta->add_attribute($attr);
459 }
460 }
461123µs if (defined $methods) {
462 foreach my $method_name (keys %{$methods}) {
463 $meta->add_method($method_name, $methods->{$method_name});
464 }
465 }
4661238µs return $meta;
467}
468
469# XXX: something more intelligent here?
470sub _anon_package_prefix { 'Class::MOP::Class::__ANON__::SERIAL::' }
471
472132444µs13294.8ms
# spent 95.2ms (453µs+94.8) within Class::MOP::Class::create_anon_class which was called 132 times, avg 721µs/call: # 100 times (333µs+75.2ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 136 of Moose/Meta/Attribute/Native/Trait.pm, avg 755µs/call # 32 times (120µs+19.6ms) by Moose::Meta::Attribute::interpolate_class at line 158 of Moose/Meta/Attribute.pm, avg 617µs/call
sub create_anon_class { shift->create_anon(@_) }
# spent 94.8ms making 132 calls to Class::MOP::Package::create_anon, avg 718µs/call
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 71.6ms (1.98+69.7) within Class::MOP::Class::new_object which was called 278 times, avg 258µs/call: # 146 times (949µs+31.9ms) by Class::MOP::Method::Accessor::_new at line 51 of Class/MOP/Method/Accessor.pm, avg 225µs/call # 73 times (579µs+10.9ms) by Moose::Meta::Method::_new at line 7 of (eval 45)[Eval/Closure.pm:144], avg 157µs/call # 32 times (235µs+22.6ms) by Moose::Meta::Class::new_object at line 274 of Moose/Meta/Class.pm, avg 713µs/call # 24 times (174µs+3.40ms) by Class::MOP::Method::_new at line 59 of Class/MOP/Method.pm, avg 149µs/call # once (14µs+458µs) by Class::MOP::Attribute::_new at line 69 of Class/MOP/Attribute.pm # once (10µs+249µs) by Moose::Meta::TypeCoercion::new at line 35 of Moose/Meta/TypeCoercion.pm # once (13µs+237µs) by Class::MOP::Object::_new at line 23 of Class/MOP/Object.pm
sub new_object {
48727876µ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
4942781.85ms556774µs return $class->_construct_class_instance(@_)
# spent 628µs making 278 calls to UNIVERSAL::isa, avg 2µs/call # spent 146µs making 278 calls to Class::MOP::Package::name, avg 525ns/call
495 if $class->name->isa('Class::MOP::Class');
496278818µs27868.9ms return $class->_construct_instance(@_);
# spent 68.9ms making 278 calls to Class::MOP::Class::_construct_instance, avg 248µs/call
497}
498
499
# spent 88.4ms (14.5+73.9) within Class::MOP::Class::_construct_instance which was called 317 times, avg 279µs/call: # 278 times (8.89ms+60.0ms) by Class::MOP::Class::new_object at line 496, avg 248µs/call # 39 times (5.59ms+13.9ms) by Class::MOP::Class::_construct_class_instance at line 101, avg 499µs/call
sub _construct_instance {
50031765µs my $class = shift;
501317133µs my $params = @_ == 1 ? $_[0] : {@_};
502317421µs3173.97ms my $meta_instance = $class->get_meta_instance();
# spent 2.85ms making 203 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 14µs/call # spent 1.12ms making 114 calls to Class::MOP::Class::get_meta_instance, avg 10µ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.
50731744µs my $instance;
5083171.46ms317345µs if (my $instance_class = blessed($params->{__INSTANCE__})) {
# spent 345µs making 317 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 {
523317523µs3171.74ms $instance = $meta_instance->create_instance();
# spent 1.74ms making 317 calls to Class::MOP::Instance::create_instance, avg 5µs/call
524 }
525317698µs31713.5ms foreach my $attr ($class->get_all_attributes()) {
# spent 10.8ms making 114 calls to Class::MOP::Class::get_all_attributes, avg 95µs/call # spent 2.76ms making 203 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 14µs/call
52634623.46ms346253.0ms $attr->initialize_instance_slot($meta_instance, $instance, $params);
# spent 52.6ms making 3429 calls to Class::MOP::Attribute::initialize_instance_slot, avg 15µs/call # spent 439µs making 33 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 13µs/call
527 }
5283171.01ms6341.25ms if (Class::MOP::metaclass_is_weak($class->name)) {
# spent 1.10ms making 317 calls to Class::MOP::metaclass_is_weak, avg 3µs/call # spent 148µs making 317 calls to Class::MOP::Package::name, avg 465ns/call
529 $meta_instance->_set_mop_slot($instance, $class);
530 }
531317649µs return $instance;
532}
533
534
# spent 114ms (807µs+113) within Class::MOP::Class::_inline_new_object which was called 58 times, avg 1.96ms/call: # 58 times (807µs+113ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 98 of Class/MOP/Method/Constructor.pm, avg 1.96ms/call
sub _inline_new_object {
5355813µs my $self = shift;
536
537 return (
53858592µs348113ms 'my $class = shift;',
# spent 91.3ms making 58 calls to Class::MOP::Class::_inline_slot_initializers, avg 1.57ms/call # spent 10.9ms making 28 calls to Moose::Meta::Class::_inline_extra_init, avg 389µs/call # spent 5.25ms making 58 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 90µs/call # spent 2.96ms making 28 calls to Moose::Meta::Class::_inline_params, avg 106µs/call # spent 1.96ms making 58 calls to Class::MOP::Class::_inline_generate_instance, avg 34µs/call # spent 546µs making 58 calls to Class::MOP::Class::_inline_fallback_constructor, avg 9µs/call # spent 56µs making 30 calls to Class::MOP::Class::_inline_params, avg 2µs/call # spent 18µs making 30 calls to Class::MOP::Class::_inline_extra_init, avg 617ns/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 546µs (398+149) within Class::MOP::Class::_inline_fallback_constructor which was called 58 times, avg 9µs/call: # 58 times (398µs+149µs) by Class::MOP::Class::_inline_new_object at line 538, avg 9µs/call
sub _inline_fallback_constructor {
5515816µs my $self = shift;
5525825µs my ($class) = @_;
553 return (
55458367µs116148µs 'return ' . $self->_generate_fallback_constructor($class),
# spent 74µs making 28 calls to Moose::Meta::Class::_generate_fallback_constructor, avg 3µs/call # spent 48µs making 30 calls to Class::MOP::Class::_generate_fallback_constructor, avg 2µs/call # spent 26µs making 58 calls to Class::MOP::Package::name, avg 452ns/call
555 'if ' . $class . ' ne \'' . $self->name . '\';',
556 );
557}
558
559
# spent 48µs within Class::MOP::Class::_generate_fallback_constructor which was called 30 times, avg 2µs/call: # 30 times (48µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 554, avg 2µs/call
sub _generate_fallback_constructor {
560304µs my $self = shift;
561307µs my ($class) = @_;
5623063µs return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)',
563}
564
565
# spent 56µs within Class::MOP::Class::_inline_params which was called 30 times, avg 2µs/call: # 30 times (56µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 2µs/call
sub _inline_params {
566307µs my $self = shift;
5673010µs my ($params, $class) = @_;
568 return (
5693063µs 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};',
570 );
571}
572
573
# spent 1.96ms (250µs+1.71) within Class::MOP::Class::_inline_generate_instance which was called 58 times, avg 34µs/call: # 58 times (250µs+1.71ms) by Class::MOP::Class::_inline_new_object at line 538, avg 34µs/call
sub _inline_generate_instance {
5745814µs my $self = shift;
5755825µs my ($inst, $class) = @_;
576 return (
57758202µs581.71ms 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';',
# spent 1.71ms making 58 calls to Class::MOP::Class::_inline_create_instance, avg 29µs/call
578 );
579}
580
581
# spent 1.71ms (273µs+1.43) within Class::MOP::Class::_inline_create_instance which was called 58 times, avg 29µs/call: # 58 times (273µs+1.43ms) by Class::MOP::Class::_inline_generate_instance at line 577, avg 29µs/call
sub _inline_create_instance {
5825810µs my $self = shift;
583
58458224µs1161.43ms return $self->get_meta_instance->inline_create_instance(@_);
# spent 1.31ms making 58 calls to Class::MOP::Class::get_meta_instance, avg 23µs/call # spent 118µs making 58 calls to Class::MOP::Instance::inline_create_instance, avg 2µs/call
585}
586
587
# spent 91.3ms (1.28+90.0) within Class::MOP::Class::_inline_slot_initializers which was called 58 times, avg 1.57ms/call: # 58 times (1.28ms+90.0ms) by Class::MOP::Class::_inline_new_object at line 538, avg 1.57ms/call
sub _inline_slot_initializers {
5885816µs my $self = shift;
589
5905814µs my $idx = 0;
591
59215813.68ms269485.2ms return map { $self->_inline_slot_initializer($_, $idx++) }
# spent 50.2ms making 186 calls to Moose::Meta::Class::_inline_slot_initializer, avg 270µs/call # spent 34.5ms making 282 calls to Class::MOP::Class::_inline_slot_initializer, avg 122µs/call # spent 536µs making 2226 calls to Class::MOP::Mixin::AttributeCore::name, avg 241ns/call
59358446µs1165.37ms sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 3.22ms making 58 calls to Class::MOP::Class::CORE:sort, avg 55µs/call # spent 2.15ms making 58 calls to Class::MOP::Class::get_all_attributes, avg 37µs/call
594}
595
596
# spent 81.1ms (3.89+77.2) within Class::MOP::Class::_inline_slot_initializer which was called 468 times, avg 173µs/call: # 282 times (2.10ms+32.4ms) by Class::MOP::Class::_inline_slot_initializers at line 592, avg 122µs/call # 186 times (1.79ms+44.8ms) by Moose::Meta::Class::_inline_slot_initializer at line 365 of Moose/Meta/Class.pm, avg 250µs/call
sub _inline_slot_initializer {
59746874µs my $self = shift;
598468101µs my ($attr, $idx) = @_;
599
6004681.06ms4961.63ms if (defined(my $init_arg = $attr->init_arg)) {
# spent 918µs making 17 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 54µs/call # spent 537µs making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 49µs/call # spent 174µs making 468 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 372ns/call
601440656µs44059.2ms my @source = (
# spent 34.7ms making 169 calls to Moose::Meta::Class::_inline_init_attr_from_constructor, avg 205µs/call # spent 24.5ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 90µs/call
602 'if (exists $params->{\'' . $init_arg . '\'}) {',
603 $self->_inline_init_attr_from_constructor($attr, $idx),
604 '}',
605 );
606440586µs44016.4ms if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) {
# spent 9.09ms making 169 calls to Moose::Meta::Class::_inline_init_attr_from_default, avg 54µs/call # spent 7.27ms making 271 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 27µs/call
607 push @source, (
608 'else {',
609 @default,
610 '}',
611 );
612 }
6134401.18ms 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 {
6231324µs return ();
624 }
625}
626
627
# spent 24.5ms (9.34+15.1) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 271 times, avg 90µs/call: # 271 times (9.34ms+15.1ms) by Class::MOP::Class::_inline_slot_initializer at line 601, avg 90µs/call
sub _inline_init_attr_from_constructor {
62827134µs my $self = shift;
62927139µs my ($attr, $idx) = @_;
630
631271725µs54214.9ms my @initial_value = $attr->_inline_set_value(
# spent 14.3ms making 269 calls to Class::MOP::Attribute::_inline_set_value, avg 53µs/call # spent 552µs making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 276µs/call # spent 60µs making 271 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 220ns/call
632 '$instance', '$params->{\'' . $attr->init_arg . '\'}',
633 );
634
635271219µs271251µs push @initial_value, (
# spent 251µs making 271 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 928ns/call
636 '$attrs->[' . $idx . ']->set_initial_value(',
637 '$instance,',
638 $attr->_inline_instance_get('$instance'),
639 ');',
640 ) if $attr->has_initializer;
641
642271494µs return @initial_value;
643}
644
645
# spent 7.81ms (1.09+6.71) within Class::MOP::Class::_inline_init_attr_from_default which was called 282 times, avg 28µs/call: # 271 times (1.03ms+6.24ms) by Class::MOP::Class::_inline_slot_initializer at line 606, avg 27µs/call # 11 times (63µs+475µs) by Class::MOP::Class::_inline_slot_initializer at line 600, avg 49µs/call
sub _inline_init_attr_from_default {
64628247µs my $self = shift;
64728248µs my ($attr, $idx) = @_;
648
649282179µs2821.61ms my $default = $self->_inline_default_value($attr, $idx);
# spent 1.61ms making 282 calls to Class::MOP::Class::_inline_default_value, avg 6µs/call
650282248µs return unless $default;
651
65299118µs995.03ms my @initial_value = $attr->_inline_set_value('$instance', $default);
# spent 5.03ms making 99 calls to Class::MOP::Attribute::_inline_set_value, avg 51µs/call
653
6549975µs9978µs push @initial_value, (
# spent 78µs making 99 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 792ns/call
655 '$attrs->[' . $idx . ']->set_initial_value(',
656 '$instance,',
657 $attr->_inline_instance_get('$instance'),
658 ');',
659 ) if $attr->has_initializer;
660
66199185µs return @initial_value;
662}
663
664
# spent 2.79ms (1.90+889µs) within Class::MOP::Class::_inline_default_value which was called 453 times, avg 6µs/call: # 282 times (1.08ms+526µs) by Class::MOP::Class::_inline_init_attr_from_default at line 649, avg 6µs/call # 171 times (819µs+363µs) by Moose::Meta::Class::_inline_init_attr_from_default at line 422 of Moose/Meta/Class.pm, avg 7µs/call
sub _inline_default_value {
66545355µs my $self = shift;
66645372µs my ($attr, $index) = @_;
667
668453886µs907889µs if ($attr->has_default) {
# spent 343µs making 453 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 757ns/call # spent 330µs making 168 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 2µs/call # spent 215µs making 285 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 755ns/call # spent 600ns making 1 call to Class::MOP::Mixin::AttributeCore::builder
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 {
6793055µs return '$defaults->[' . $index . ']';
680 }
681 }
682 elsif ($attr->has_builder) {
683 return '$instance->' . $attr->builder;
684 }
685 else {
686284410µs return;
687 }
688}
689
690
# spent 5.25ms (4.99+259µs) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 58 times, avg 90µs/call: # 58 times (4.99ms+259µs) by Class::MOP::Class::_inline_new_object at line 538, avg 90µs/call
sub _inline_preserve_weak_metaclasses {
6915817µs my $self = shift;
69258220µs116259µs if (Class::MOP::metaclass_is_weak($self->name)) {
# spent 229µs making 58 calls to Class::MOP::metaclass_is_weak, avg 4µs/call # spent 30µs making 58 calls to Class::MOP::Package::name, avg 519ns/call
693 return (
694 $self->_inline_set_mop_slot(
695 '$instance', 'Class::MOP::class_of($class)'
696 ) . ';'
697 );
698 }
699 else {
70058113µs return ();
701 }
702}
703
7043037µs
# spent 18µs within Class::MOP::Class::_inline_extra_init which was called 30 times, avg 617ns/call: # 30 times (18µs+0s) by Class::MOP::Class::_inline_new_object at line 538, avg 617ns/call
sub _inline_extra_init { }
705
706
# spent 14.1ms (1.28+12.9) within Class::MOP::Class::_eval_environment which was called 58 times, avg 244µs/call: # 30 times (702µs+7.66ms) by Class::MOP::Method::Constructor::_eval_environment at line 86 of Class/MOP/Method/Constructor.pm, avg 279µs/call # 28 times (576µs+5.21ms) by Moose::Meta::Class::_eval_environment at line 542 of Moose/Meta/Class.pm, avg 207µs/call
sub _eval_environment {
7075819µs my $self = shift;
708
709119910.6ms239813.0ms my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
# spent 10.4ms making 58 calls to Class::MOP::Class::CORE:sort, avg 179µs/call # spent 2.04ms making 58 calls to Class::MOP::Class::get_all_attributes, avg 35µs/call # spent 531µs making 2282 calls to Class::MOP::Mixin::AttributeCore::name, avg 233ns/call
710
711526503µs468416µs my $defaults = [map { $_->default } @attrs];
# spent 416µs making 468 calls to Class::MOP::Mixin::AttributeCore::default, avg 889ns/call
712
713 return {
71458189µs '$defaults' => \$defaults,
715 };
716}
717
718
719
# spent 24.1ms (1.32+22.7) within Class::MOP::Class::get_meta_instance which was called 848 times, avg 28µs/call: # 315 times (327µs+934µs) by Class::MOP::Attribute::_inline_instance_set at line 301 of Class/MOP/Attribute.pm, avg 4µs/call # 236 times (525µs+18.2ms) by Class::MOP::Attribute::_inline_instance_get at line 324 of Class/MOP/Attribute.pm, avg 80µs/call # 114 times (228µs+897µs) by Class::MOP::Class::_construct_instance at line 502, avg 10µs/call # 87 times (99µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 345 of Class/MOP/Attribute.pm, avg 1µs/call # 58 times (86µs+1.23ms) by Class::MOP::Class::_inline_create_instance at line 584, avg 23µs/call # 24 times (44µs+1.34ms) by Class::MOP::Class:::around at line 77 of Class/MOP/Class/Immutable/Trait.pm, avg 57µs/call # 8 times (6µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 737 of Moose/Meta/Attribute.pm, avg 762ns/call # 3 times (2µs+0s) by Class::MOP::Attribute::has_value at line 332 of Class/MOP/Attribute.pm, avg 833ns/call # 2 times (2µs+0s) by Class::MOP::Attribute::get_raw_value at line 311 of Class/MOP/Attribute.pm, avg 950ns/call # once (3µs+104µs) by Moose::Exporter::BEGIN@8 at line 733 of Class/MOP.pm
sub get_meta_instance {
720848165µs my $self = shift;
7218484.75ms16022.7ms $self->{'_meta_instance'} ||= $self->_create_meta_instance();
# spent 22.7ms making 160 calls to Class::MOP::Class::_create_meta_instance, avg 142µs/call
722}
723
724
# spent 22.7ms (1.65+21.1) within Class::MOP::Class::_create_meta_instance which was called 160 times, avg 142µs/call: # 160 times (1.65ms+21.1ms) by Class::MOP::Class::get_meta_instance at line 721, avg 142µs/call
sub _create_meta_instance {
72516039µs my $self = shift;
726
727160914µs48020.9ms my $instance = $self->instance_metaclass->new(
# spent 14.7ms making 160 calls to Class::MOP::Instance::new, avg 92µs/call # spent 5.55ms making 148 calls to Class::MOP::Class::get_all_attributes, avg 38µs/call # spent 669µs making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 56µs/call # spent 56µs making 160 calls to Class::MOP::Class::instance_metaclass, avg 351ns/call
728 associated_metaclass => $self,
729 attributes => [ $self->get_all_attributes() ],
730 );
731
732160272µs160154µs $self->add_meta_instance_dependencies()
# spent 154µs making 160 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 966ns/call
733 if $instance->is_dependent_on_superclasses();
734
735160266µ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 2.62ms (646µs+1.97) within Class::MOP::Class::_attach_attribute which was called 240 times, avg 11µs/call: # 240 times (646µs+1.97ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 22 of Class/MOP/Mixin/HasAttributes.pm, avg 11µs/call
sub _attach_attribute {
88724065µs my ($self, $attribute) = @_;
888240613µs2401.97ms $attribute->attach_to_class($self);
# spent 1.97ms making 240 calls to Class::MOP::Attribute::attach_to_class, avg 8µs/call
889}
890
891
# spent 537ms (6.09+531) within Class::MOP::Class::_post_add_attribute which was called 240 times, avg 2.24ms/call: # 240 times (6.09ms+531ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 39 of Class/MOP/Mixin/HasAttributes.pm, avg 2.24ms/call
sub _post_add_attribute {
89224062µs my ( $self, $attribute ) = @_;
893
894240285µs2401.54ms $self->invalidate_meta_instances;
# spent 1.54ms making 240 calls to Class::MOP::Class::invalidate_meta_instances, avg 6µs/call
895
896 # invalidate package flag here
897 try {
898240382µs local $SIG{__DIE__};
899240780µs240524ms $attribute->install_accessors;
# spent 218ms making 21 calls to Moose::Meta::Class::__ANON__::SERIAL::1::install_accessors, avg 10.4ms/call # spent 154ms making 78 calls to Moose::Meta::Attribute::install_accessors, avg 1.97ms/call # spent 117ms making 11 calls to Moose::Meta::Class::__ANON__::SERIAL::7::install_accessors, avg 10.6ms/call # spent 35.4ms making 130 calls to Class::MOP::Attribute::install_accessors, avg 273µs/call
900 }
901 catch {
902 $self->remove_attribute( $attribute->name );
903 die $_;
9042401.56ms480530ms };
# spent 529ms making 240 calls to Try::Tiny::try, avg 2.20ms/call # spent 658µs making 240 calls to Try::Tiny::catch, avg 3µs/call
905}
906
907
# spent 279µs (44+235) within Class::MOP::Class::remove_attribute which was called: # once (44µs+235µs) by Class::MOP::Mixin::HasAttributes::add_attribute at line 26 of Class/MOP/Mixin/HasAttributes.pm
sub remove_attribute {
9081400ns my $self = shift;
909
91017µs110µs my $removed_attribute = $self->SUPER::remove_attribute(@_)
# spent 10µs making 1 call to Class::MOP::Mixin::HasAttributes::remove_attribute
911 or return;
912
91312µs111µs $self->invalidate_meta_instances;
# spent 11µs making 1 call to Class::MOP::Class::invalidate_meta_instances
914
91512µs1212µs $removed_attribute->remove_accessors;
# spent 212µs making 1 call to Moose::Meta::Attribute::remove_accessors
91614µs12µs $removed_attribute->detach_from_class;
# spent 2µs making 1 call to Class::MOP::Attribute::detach_from_class
917
918121µs return$removed_attribute;
919}
920
921
# spent 2.84ms (785µs+2.06) within Class::MOP::Class::find_attribute_by_name which was called 83 times, avg 34µs/call: # 82 times (765µs+2.03ms) by Class::MOP::Class::_immutable_metaclass at line 1343, avg 34µs/call # once (20µs+26µs) by Moose::Meta::Class::_process_inherited_attribute at line 718 of Moose/Meta/Class.pm
sub find_attribute_by_name {
9228335µs my ( $self, $attr_name ) = @_;
923
92483117µs831.11ms foreach my $class ( $self->linearized_isa ) {
# spent 1.08ms making 78 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 14µs/call # spent 28µs making 5 calls to Class::MOP::Class::linearized_isa, avg 6µs/call
925 # fetch the meta-class ...
92683101µs83262µs my $meta = Class::MOP::Class->initialize($class);
# spent 262µs making 83 calls to Class::MOP::Class::initialize, avg 3µs/call
92783366µs166686µs return $meta->get_attribute($attr_name)
# spent 383µs making 83 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 5µs/call # spent 303µs making 83 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 4µs/call
928 if $meta->has_attribute($attr_name);
929 }
930
931 return;
932}
933
934
# spent 27.8ms (16.6+11.2) within Class::MOP::Class::get_all_attributes which was called 516 times, avg 54µs/call: # 148 times (2.85ms+2.70ms) by Class::MOP::Class::_create_meta_instance at line 727, avg 38µs/call # 114 times (7.70ms+3.09ms) by Class::MOP::Class::_construct_instance at line 525, avg 95µs/call # 58 times (1.15ms+1.00ms) by Class::MOP::Class::_inline_slot_initializers at line 593, avg 37µs/call # 58 times (1.01ms+1.04ms) by Class::MOP::Class::_eval_environment at line 709, avg 35µs/call # 33 times (1.51ms+1.13ms) by Moose::Meta::Attribute::new at line 58 of Moose/Meta/Attribute.pm, avg 80µs/call # 32 times (1.12ms+878µs) by Moose::Meta::Class::_call_all_triggers at line 286 of Moose/Meta/Class.pm, avg 62µs/call # 28 times (465µs+438µs) by Moose::Meta::Class::_inline_triggers at line 459 of Moose/Meta/Class.pm, avg 32µs/call # 28 times (396µs+390µs) by Moose::Meta::Class::_eval_environment at line 497 of Moose/Meta/Class.pm, avg 28µs/call # 17 times (397µs+530µs) by Class::MOP::Class:::around at line 71 of Class/MOP/Class/Immutable/Trait.pm, avg 55µs/call
sub get_all_attributes {
935516100µs my $self = shift;
936493614.6ms493611.1ms my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } }
# spent 6.73ms making 2210 calls to Class::MOP::Class::initialize, avg 3µs/call, recursion: max depth 1, sum of overlapping time 79µs # spent 3.08ms making 499 calls to Class::MOP::Class::linearized_isa, avg 6µs/call # spent 1.10ms making 2210 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 497ns/call # spent 282µs making 17 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 17µs/call
937 reverse $self->linearized_isa;
9385161.60ms return values %attrs;
939}
940
941# Inheritance
942
943sub superclasses {
94434581µs my $self = shift;
945
946345436µs3454.88ms my $isa = $self->get_or_add_package_symbol('@ISA');
# spent 4.88ms making 345 calls to Class::MOP::Package::get_or_add_package_symbol, avg 14µs/call
947
94834591µs if (@_) {
9495444µs my @supers = @_;
95054550µ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
95654184µs5440µs my $class = $self->name;
# spent 40µs making 54 calls to Class::MOP::Package::name, avg 744ns/call
95754404µs5450µs $class->isa($class);
# spent 50µs making 54 calls to UNIVERSAL::isa, avg 930ns/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
9665472µs5432.3ms $self->_check_metaclass_compatibility();
# spent 32.3ms making 54 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 599µs/call
9675490µs542.16ms $self->_superclasses_updated();
# spent 2.16ms making 54 calls to Class::MOP::Class::_superclasses_updated, avg 40µs/call
968 }
969
970345730µs return @{$isa};
971}
972
973
# spent 2.16ms (574µs+1.58) within Class::MOP::Class::_superclasses_updated which was called 54 times, avg 40µs/call: # 54 times (574µs+1.58ms) by Class::MOP::Class::superclasses at line 967, avg 40µs/call
sub _superclasses_updated {
9745418µs my $self = shift;
9755484µs5494µs $self->update_meta_instance_dependencies();
# spent 94µs making 54 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 2µ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
9786261µs62198µs $self->_superclass_metas(
# spent 198µs making 62 calls to Class::MOP::class_of, avg 3µs/call
97954248µs108123µs map { Class::MOP::class_of($_) } $self->superclasses
# spent 123µs making 54 calls to Class::MOP::Class::_superclass_metas, avg 2µs/call # spent 20µs making 2 calls to Class::MOP::Class::superclasses, avg 10µs/call, recursion: max depth 1, sum of overlapping time 20µs # spent 1.15ms making 52 calls to Moose::Meta::Class::superclasses, avg 22µs/call, recursion: max depth 2, sum of overlapping time 1.15ms
980 );
981}
982
983
# spent 123µs within Class::MOP::Class::_superclass_metas which was called 54 times, avg 2µs/call: # 54 times (123µs+0s) by Class::MOP::Class::_superclasses_updated at line 979, avg 2µs/call
sub _superclass_metas {
9845414µs my $self = shift;
98554157µ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.88ms (3.84+2.04) within Class::MOP::Class::linearized_isa which was called 969 times, avg 6µs/call: # 499 times (2.02ms+1.07ms) by Class::MOP::Class::get_all_attributes at line 936, avg 6µs/call # 442 times (1.66ms+888µs) by Class::MOP::Class::_method_lookup_order at line 1045, avg 6µs/call # 23 times (143µs+76µs) by Class::MOP::Class:::around at line 53 of Class/MOP/Class/Immutable/Trait.pm, avg 10µs/call # 5 times (20µs+8µs) by Class::MOP::Class::find_attribute_by_name at line 924, avg 6µs/call
sub linearized_isa {
10079696.61ms19382.04ms return @{ mro::get_linear_isa( (shift)->name ) };
# spent 1.65ms making 969 calls to mro::get_linear_isa, avg 2µs/call # spent 390µs making 969 calls to Class::MOP::Package::name, avg 402ns/call
1008}
1009
1010
# spent 3.03ms (732µs+2.30) within Class::MOP::Class::class_precedence_list which was called 50 times, avg 61µs/call: # 28 times (507µs+2.53ms) by Moose::Meta::Class::excludes_role at line 257 of Moose/Meta/Class.pm, avg 108µs/call # 13 times (159µs+-159µs) by Class::MOP::Class:::around at line 46 of Class/MOP/Class/Immutable/Trait.pm, avg 0s/call # 9 times (66µs+-66µs) by Class::MOP::Class::class_precedence_list at line 1036, avg 0s/call
sub class_precedence_list {
10115014µs my $self = shift;
101250138µs5028µs my $name = $self->name;
# spent 28µs making 50 calls to Class::MOP::Package::name, avg 556ns/call
1013
101450111µs5032µs unless (Class::MOP::IS_RUNNING_ON_5_10()) {
# spent 32µs making 50 calls to Class::MOP::__ANON__, avg 640ns/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
102750187µs5087µs if (mro::get_mro($name) eq 'c3') {
# spent 87µs making 50 calls to mro::get_mro, avg 2µ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 (
103652134µs1041.43ms $name,
# spent 1.71ms making 33 calls to Class::MOP::Class::Immutable::Class::MOP::Class::class_precedence_list, avg 52µs/call, recursion: max depth 3, sum of overlapping time 834µs # spent 308µs making 10 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::class_precedence_list, avg 31µs/call # spent 241µs making 52 calls to Class::MOP::Class::initialize, avg 5µs/call # spent 262µs making 9 calls to Class::MOP::Class::class_precedence_list, avg 29µs/call, recursion: max depth 2, sum of overlapping time 262µs
1037 map {
103850201µs50708µs Class::MOP::Class->initialize($_)->class_precedence_list()
# spent 993µs making 37 calls to Moose::Meta::Class::superclasses, avg 27µs/call, recursion: max depth 1, sum of overlapping time 587µs # spent 251µs making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::superclasses, avg 21µs/call # spent 51µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::superclasses
1039 } $self->superclasses()
1040 );
1041 }
1042}
1043
1044
# spent 3.91ms (989µs+2.92) within Class::MOP::Class::_method_lookup_order which was called 470 times, avg 8µs/call: # 207 times (470µs+1.27ms) by Class::MOP::Class::find_method_by_name at line 1132, avg 8µs/call # 200 times (401µs+1.32ms) by Class::MOP::Class::find_next_method_by_name at line 1178, avg 9µs/call # 56 times (99µs+273µs) by Class::MOP::Class::find_all_methods_by_name at line 1162, avg 7µs/call # 7 times (19µs+59µs) by Class::MOP::Class::get_all_methods at line 1143, avg 11µs/call
sub _method_lookup_order {
10454701.06ms4702.92ms return (shift->linearized_isa, 'UNIVERSAL');
# spent 2.55ms making 442 calls to Class::MOP::Class::linearized_isa, avg 6µs/call # spent 366µs making 28 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 13µs/call
1046}
1047
1048## Methods
1049
1050{
10511200ns
# spent 12.2ms (903µs+11.3) within Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm:1082] which was called 66 times, avg 185µs/call: # 62 times (832µs+10.5ms) by Class::MOP::Class::add_around_method_modifier at line 1108, avg 183µs/call # 4 times (71µs+772µs) by Class::MOP::Class::add_before_method_modifier at line 1088, avg 211µs/call
my $fetch_and_prepare_method = sub {
10526617µs my ($self, $method_name) = @_;
105366173µs6634µs my $wrapped_metaclass = $self->wrapped_method_metaclass;
# spent 34µs making 66 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 518ns/call
1054 # fetch it locally
10556650µs661.01ms my $method = $self->get_method($method_name);
# spent 1.01ms making 66 calls to Class::MOP::Mixin::HasMethods::get_method, avg 15µs/call
1056 # if we don't have local ...
10576632µs53µs unless ($method) {
# spent 3µs making 5 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 520ns/call
1058 # try to find the next method
10596177µs614.35ms $method = $self->find_next_method_by_name($method_name);
# spent 4.35ms making 61 calls to Class::MOP::Class::find_next_method_by_name, avg 71µs/call
1060 # die if it does not exist
10616110µ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
106861221µs1222.47ms $method = $wrapped_metaclass->wrap($method,
# spent 2.44ms making 61 calls to Class::MOP::Method::Wrapped::wrap, avg 40µs/call # spent 33µs making 61 calls to Class::MOP::Package::name, avg 548ns/call
1069 package_name => $self->name,
1070 name => $method_name,
1071 );
1072 }
1073 else {
1074 # now make sure we wrap it properly
1075534µs15199µs $method = $wrapped_metaclass->wrap($method,
# spent 191µs making 5 calls to Class::MOP::Method::Wrapped::wrap, avg 38µs/call # spent 6µs making 5 calls to UNIVERSAL::isa, avg 1µs/call # spent 2µs making 5 calls to Class::MOP::Package::name, avg 460ns/call
1076 package_name => $self->name,
1077 name => $method_name,
1078 ) unless $method->isa($wrapped_metaclass);
1079 }
10806662µs663.24ms $self->add_method($method_name => $method);
# spent 3.24ms making 66 calls to Class::MOP::Mixin::HasMethods::add_method, avg 49µs/call
108166128µs return $method;
108213µs };
1083
1084
# spent 923µs (32+891) within Class::MOP::Class::add_before_method_modifier which was called 4 times, avg 231µs/call: # 4 times (32µs+891µs) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 207 of Moose/Meta/Role/Application/ToClass.pm, avg 231µs/call
sub add_before_method_modifier {
108541µs my ($self, $method_name, $method_modifier) = @_;
108642µs (defined $method_name && length $method_name)
1087 || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
108845µs4844µs my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 844µs making 4 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1082], avg 211µs/call
1089425µs848µs $method->add_before_modifier(
# spent 41µs making 4 calls to Class::MOP::Method::Wrapped::add_before_modifier, avg 10µs/call # spent 6µs making 4 calls to Sub::Name::subname, avg 2µs/call
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 12.8ms (408µs+12.4) within Class::MOP::Class::add_around_method_modifier which was called 62 times, avg 206µs/call: # 43 times (264µs+8.87ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 212µs/call # 19 times (144µs+3.48ms) by Moose::Meta::Role::Application::ToClass::apply_method_modifiers at line 207 of Moose/Meta/Role/Application/ToClass.pm, avg 191µs/call
sub add_around_method_modifier {
11056226µs my ($self, $method_name, $method_modifier) = @_;
11066220µs (defined $method_name && length $method_name)
1107 || $self->_throw_exception( MethodModifierNeedsMethodName => class_name => $self->name );
11086265µs6211.4ms my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 11.4ms making 62 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1082], avg 183µs/call
110962347µs124982µs $method->add_around_modifier(
# spent 888µs making 62 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 14µs/call # spent 95µs making 62 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 30.6ms (2.83+27.7) within Class::MOP::Class::find_method_by_name which was called 207 times, avg 148µs/call: # 62 times (781µs+3.24ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 19 of Class/MOP/Mixin/HasMethods.pm, avg 65µs/call # 56 times (1.01ms+13.3ms) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 256µs/call # 28 times (393µs+6.81ms) by Moose::Meta::Method::Destructor::is_needed at line 66 of Moose/Meta/Method/Destructor.pm, avg 257µs/call # 28 times (376µs+1.95ms) by Moose::Meta::Class::_inline_BUILDARGS at line 325 of Moose/Meta/Class.pm, avg 83µs/call # 26 times (206µs+2.10ms) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 69 of Moose/Meta/Role/Application/ToClass.pm, avg 89µs/call # 7 times (66µs+318µs) by Moose::BEGIN@43 at line 16 of Moose/Meta/Attribute/Native.pm, avg 55µs/call
sub find_method_by_name {
112920782µs my ($self, $method_name) = @_;
1130207106µs (defined $method_name && length $method_name)
1131 || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1132207310µs2071.74ms foreach my $class ($self->_method_lookup_order) {
# spent 1.74ms making 207 calls to Class::MOP::Class::_method_lookup_order, avg 8µs/call
1133566941µs113226.0ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 24.0ms making 566 calls to Class::MOP::Mixin::HasMethods::get_method, avg 42µs/call # spent 1.94ms making 566 calls to Class::MOP::Class::initialize, avg 3µs/call
1134566490µs return $method if defined $method;
1135 }
1136805.10ms return;
1137}
1138
1139
# spent 2.47ms (270µs+2.20) within Class::MOP::Class::get_all_methods which was called 7 times, avg 354µs/call: # 7 times (270µs+2.20ms) by Class::MOP::MiniTrait::apply at line 17 of Class/MOP/MiniTrait.pm, avg 354µs/call
sub get_all_methods {
114074µs my $self = shift;
1141
114272µs my %methods;
1143716µs778µs for my $class ( reverse $self->_method_lookup_order ) {
# spent 78µs making 7 calls to Class::MOP::Class::_method_lookup_order, avg 11µs/call
11441514µs1548µs my $meta = Class::MOP::Class->initialize($class);
# spent 48µs making 15 calls to Class::MOP::Class::initialize, avg 3µs/call
1145
114615215µs1012.08ms $methods{ $_->name } = $_ for $meta->_get_local_methods;
# spent 2.05ms making 15 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 137µs/call # spent 31µs making 86 calls to Class::MOP::Method::name, avg 362ns/call
1147 }
1148
1149727µ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 9.86ms (1.05+8.80) within Class::MOP::Class::find_all_methods_by_name which was called 56 times, avg 176µs/call: # 28 times (597µs+6.83ms) by Moose::Meta::Class::_inline_BUILDALL at line 483 of Moose/Meta/Class.pm, avg 265µs/call # 28 times (456µs+1.97ms) by Moose::Meta::Method::Destructor::_generate_DEMOLISHALL at line 116 of Moose/Meta/Method/Destructor.pm, avg 87µs/call
sub find_all_methods_by_name {
11585626µs my ($self, $method_name) = @_;
11595630µs (defined $method_name && length $method_name)
1160 || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1161569µs my @methods;
11625695µs56372µs foreach my $class ($self->_method_lookup_order) {
# spent 372µs making 56 calls to Class::MOP::Class::_method_lookup_order, avg 7µs/call
1163 # fetch the meta-class ...
1164196184µs196616µs my $meta = Class::MOP::Class->initialize($class);
# spent 616µs making 196 calls to Class::MOP::Class::initialize, avg 3µs/call
1165196290µs2087.81ms push @methods => {
# spent 7.51ms making 196 calls to Class::MOP::Mixin::HasMethods::has_method, avg 38µs/call # spent 306µs making 12 calls to Class::MOP::Mixin::HasMethods::get_method, avg 26µs/call
1166 name => $method_name,
1167 class => $class,
1168 code => $meta->get_method($method_name)
1169 } if $meta->has_method($method_name);
1170 }
117156110µs return @methods;
1172}
1173
1174
# spent 11.6ms (2.05+9.53) within Class::MOP::Class::find_next_method_by_name which was called 200 times, avg 58µs/call: # 86 times (883µs+3.81ms) by Class::MOP::Method::Inlined::can_be_inlined at line 34 of Class/MOP/Method/Inlined.pm, avg 55µs/call # 61 times (715µs+3.64ms) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm:1082] at line 1059, avg 71µs/call # 28 times (204µs+895µs) by Class::MOP::Method::Inlined::_uninlined_body at line 14 of Class/MOP/Method/Inlined.pm, avg 39µs/call # 25 times (252µs+1.19ms) by Moose::Meta::Method::Overridden::new at line 22 of Moose/Meta/Method/Overridden.pm, avg 57µs/call
sub find_next_method_by_name {
117520079µs my ($self, $method_name) = @_;
117620082µs (defined $method_name && length $method_name)
1177 || $self->_throw_exception( MethodNameNotGiven => class_name => $self->name );
1178200364µs2001.72ms my @cpl = ($self->_method_lookup_order);
# spent 1.72ms making 200 calls to Class::MOP::Class::_method_lookup_order, avg 9µs/call
117920050µs shift @cpl; # discard ourselves
118020089µs foreach my $class (@cpl) {
1181275484µs5507.81ms my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 6.79ms making 275 calls to Class::MOP::Mixin::HasMethods::get_method, avg 25µs/call # spent 1.02ms making 275 calls to Class::MOP::Class::initialize, avg 4µs/call
1182275469µs return $method if defined $method;
1183 }
118424µs return;
1185}
1186
1187
# spent 94µs within Class::MOP::Class::update_meta_instance_dependencies which was called 54 times, avg 2µs/call: # 54 times (94µs+0s) by Class::MOP::Class::_superclasses_updated at line 975, avg 2µs/call
sub update_meta_instance_dependencies {
11885416µs my $self = shift;
1189
119054117µ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 1.55ms (1.25+295µs) within Class::MOP::Class::invalidate_meta_instances which was called 241 times, avg 6µs/call: # 240 times (1.24ms+293µs) by Class::MOP::Class::_post_add_attribute at line 894, avg 6µs/call # once (9µs+2µs) by Class::MOP::Class::remove_attribute at line 913
sub invalidate_meta_instances {
124124157µs my $self = shift;
1242 $_->invalidate_meta_instance()
12432411.09ms241295µs for $self, @{ $self->{dependent_meta_instances} };
# spent 295µs making 241 calls to Class::MOP::Class::invalidate_meta_instance, avg 1µs/call
1244}
1245
1246
# spent 295µs within Class::MOP::Class::invalidate_meta_instance which was called 241 times, avg 1µs/call: # 241 times (295µs+0s) by Class::MOP::Class::invalidate_meta_instances at line 1243, avg 1µs/call
sub invalidate_meta_instance {
124724141µs my $self = shift;
1248241505µ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
1269115179µs
# spent 71µs within Class::MOP::Class::is_mutable which was called 115 times, avg 618ns/call: # 82 times (57µs+0s) by Class::MOP::Class::make_immutable at line 1293, avg 698ns/call # 21 times (9µs+0s) by PONAPI::Server::ConfigReader::BEGIN@4 at line 238 of Moose.pm, avg 414ns/call # 9 times (4µs+0s) by Moose::Meta::Attribute::BEGIN@16 at line 712 of Moose/Util/TypeConstraints.pm, avg 422ns/call # 3 times (1µs+0s) by PONAPI::Server::ConfigReader::BEGIN@4 at line 274 of Moose.pm, avg 467ns/call
sub is_mutable { 1 }
127091138µs
# spent 63µs within Class::MOP::Class::is_immutable which was called 91 times, avg 690ns/call: # 91 times (63µs+0s) by Class::MOP::Class::_real_ref_name at line 122, avg 690ns/call
sub is_immutable { 0 }
1271
1272sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1273
1274
# spent 6.52ms (6.19+340µs) within Class::MOP::Class::_immutable_options which was called 82 times, avg 80µs/call: # 54 times (505µs+109µs) by Class::MOP::Class::make_immutable at line 1297, avg 11µs/call # 28 times (5.68ms+230µs) by Moose::Meta::Class::_immutable_options at line 757 of Moose/Meta/Class.pm, avg 211µs/call
sub _immutable_options {
12758266µs my ( $self, @args ) = @_;
1276
1277 return (
1278826.24ms328340µs inline_accessors => 1,
# spent 74µs making 28 calls to Moose::Meta::Class::immutable_trait, avg 3µs/call # spent 71µs making 28 calls to Moose::Meta::Class::constructor_class, avg 3µs/call # spent 58µs making 28 calls to Moose::Meta::Class::destructor_class, avg 2µs/call # spent 55µs making 82 calls to Class::MOP::Class::constructor_name, avg 673ns/call # spent 33µs making 54 calls to Class::MOP::Class::immutable_trait, avg 609ns/call # spent 25µs making 54 calls to Class::MOP::Class::destructor_class, avg 470ns/call # spent 24µs making 54 calls to Class::MOP::Class::constructor_class, avg 443ns/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 342ms (1.12+341) within Class::MOP::Class::make_immutable which was called 82 times, avg 4.18ms/call: # 21 times (272µs+79.9ms) by PONAPI::Server::ConfigReader::BEGIN@4 at line 243 of Moose.pm, avg 3.82ms/call # 14 times (125µs+14.4ms) by Moose::Exporter::BEGIN@8 at line 748 of Class/MOP.pm, avg 1.03ms/call # 9 times (126µs+41.0ms) by Moose::Meta::Attribute::BEGIN@16 at line 717 of Moose/Util/TypeConstraints.pm, avg 4.57ms/call # 5 times (41µs+314µs) by Moose::Exporter::BEGIN@8 at line 775 of Class/MOP.pm, avg 71µs/call # 3 times (31µs+10.6ms) by PONAPI::Server::ConfigReader::BEGIN@4 at line 279 of Moose.pm, avg 3.56ms/call # 2 times (30µs+-30µs) by Class::MOP::Class::_immutable_metaclass at line 1373, avg 0s/call # once (21µs+17.0ms) by PONAPI::Builder::Relationship::BEGIN@6 at line 23 of lib/PONAPI/Builder/Resource/Identifier.pm # once (17µs+11.0ms) by PONAPI::DAO::BEGIN@13 at line 34 of lib/PONAPI/DAO/Request/UpdateRelationships.pm # once (18µs+10.6ms) by PONAPI::DAO::BEGIN@11 at line 45 of lib/PONAPI/DAO/Request/CreateRelationships.pm # once (18µs+10.2ms) by PONAPI::DAO::BEGIN@9 at line 35 of lib/PONAPI/DAO/Request/RetrieveByRelationship.pm # once (19µs+10.2ms) by PONAPI::DAO::BEGIN@6 at line 29 of lib/PONAPI/DAO/Request/Retrieve.pm # once (18µs+10.0ms) by PONAPI::DAO::BEGIN@10 at line 37 of lib/PONAPI/DAO/Request/Create.pm # once (17µs+10.0ms) by Test::PONAPI::Repository::MockDB::Table::Articles::BEGIN@5 at line 20 of lib/Test/PONAPI/Repository/MockDB/Table/Relationships.pm # once (17µs+9.93ms) by PONAPI::DAO::BEGIN@15 at line 46 of lib/PONAPI/DAO/Request/DeleteRelationships.pm # once (16µs+9.71ms) by PONAPI::DAO::BEGIN@14 at line 27 of lib/PONAPI/DAO/Request/Delete.pm # once (15µs+9.45ms) by Test::PONAPI::Repository::MockDB::BEGIN@14 at line 35 of lib/Test/PONAPI/Repository/MockDB/Table/Comments.pm # once (21µs+9.08ms) by PONAPI::Builder::Document::BEGIN@6 at line 130 of lib/PONAPI/Builder/Resource.pm # once (20µs+8.73ms) by PONAPI::Builder::Resource::BEGIN@6 at line 95 of lib/PONAPI/Builder/Relationship.pm # once (20µs+8.50ms) by Test::PONAPI::Repository::MockDB::BEGIN@13 at line 35 of lib/Test/PONAPI/Repository/MockDB/Table/People.pm # once (18µs+7.45ms) by PONAPI::DAO::Request::Role::UpdateLike::BEGIN@7 at line 150 of lib/PONAPI/Exception.pm # once (17µs+6.27ms) by PONAPI::DAO::BEGIN@7 at line 26 of lib/PONAPI/DAO/Request/RetrieveAll.pm # once (18µs+6.26ms) by PONAPI::DAO::BEGIN@8 at line 33 of lib/PONAPI/DAO/Request/RetrieveRelationships.pm # once (17µs+6.06ms) by PONAPI::DAO::BEGIN@12 at line 31 of lib/PONAPI/DAO/Request/Update.pm # once (16µs+4.76ms) by PONAPI::DAO::Request::BEGIN@7 at line 204 of lib/PONAPI/Builder/Document.pm # once (16µs+4.24ms) by Test::PONAPI::Repository::MockDB::BEGIN@12 at line 70 of lib/Test/PONAPI/Repository/MockDB/Table/Articles.pm # once (18µs+4.11ms) by Module::Runtime::require_module at line 166 of lib/Test/PONAPI/Repository/MockDB/Table.pm # once (16µs+4.09ms) by Module::Runtime::require_module at line 161 of lib/PONAPI/DAO/Request.pm # once (17µs+3.11ms) by PONAPI::Server::ConfigReader::BEGIN@10 at line 70 of lib/PONAPI/DAO.pm # once (16µs+2.57ms) by Test::PONAPI::Repository::MockDB::BEGIN@10 at line 97 of lib/Test/PONAPI/Repository/MockDB/Loader.pm # once (16µs+2.49ms) by Module::Runtime::require_module at line 797 of lib/Test/PONAPI/Repository/MockDB.pm # once (18µs+2.46ms) by PONAPI::Builder::Role::HasLinksBuilder::BEGIN@6 at line 51 of lib/PONAPI/Builder/Links.pm # once (15µs+2.36ms) by PONAPI::Server::BEGIN@17 at line 112 of lib/PONAPI/Server/ConfigReader.pm # once (19µs+2.28ms) by PONAPI::Builder::Document::BEGIN@8 at line 32 of lib/PONAPI/Builder/Errors.pm # once (16µs+2.12ms) by PONAPI::Builder::Document::BEGIN@7 at line 10 of lib/PONAPI/Builder/Resource/Null.pm
sub make_immutable {
12918263µs my ( $self, @args ) = @_;
1292
12938295µs8257µs return $self unless $self->is_mutable;
# spent 57µs making 82 calls to Class::MOP::Class::is_mutable, avg 698ns/call
1294
129582128µs my ($file, $line) = (caller)[1..2];
1296
129782357µs164309ms $self->_initialize_immutable(
# spent 303ms making 82 calls to Class::MOP::Class::_initialize_immutable, avg 3.69ms/call # spent 6.05ms making 28 calls to Moose::Meta::Class::_immutable_options, avg 216µs/call # spent 614µs making 54 calls to Class::MOP::Class::_immutable_options, avg 11µs/call
1298 file => $file,
1299 line => $line,
1300 $self->_immutable_options(@args),
1301 );
130282135µs8231.9ms $self->_rebless_as_immutable(@args);
# spent 32.1ms making 82 calls to Class::MOP::Class::_rebless_as_immutable, avg 391µs/call, recursion: max depth 1, sum of overlapping time 145µs
1303
1304825.32ms 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 31.9ms (498µs+31.4) within Class::MOP::Class::_rebless_as_immutable which was called 82 times, avg 390µs/call: # 82 times (498µs+31.4ms) by Class::MOP::Class::make_immutable at line 1302, avg 390µs/call
sub _rebless_as_immutable {
13238266µs my ( $self, @args ) = @_;
1324
13258282µs $self->{__immutable}{original_class} = ref $self;
1326
132782303µs8231.5ms bless $self => $self->_immutable_metaclass(@args);
# spent 31.6ms making 82 calls to Class::MOP::Class::_immutable_metaclass, avg 385µs/call, recursion: max depth 1, sum of overlapping time 130µs
1328}
1329
1330
# spent 31.5ms (1.30+30.2) within Class::MOP::Class::_immutable_metaclass which was called 82 times, avg 384µs/call: # 82 times (1.30ms+30.2ms) by Class::MOP::Class::_rebless_as_immutable at line 1327, avg 384µs/call
sub _immutable_metaclass {
13318266µs my ( $self, %args ) = @_;
1332
13338244µs if ( my $class = $args{immutable_metaclass} ) {
1334 return $class;
1335 }
1336
133782231µs8291µs my $trait = $args{immutable_trait} = $self->immutable_trait
# spent 65µs making 28 calls to Moose::Meta::Class::immutable_trait, avg 2µs/call # spent 26µs making 54 calls to Class::MOP::Class::immutable_trait, avg 491ns/call
1338 || $self->_throw_exception( NoImmutableTraitSpecifiedForClass => class_name => $self->name,
1339 params => \%args
1340 );
1341
134282138µs82798µs my $meta = $self->meta;
# spent 798µs making 82 calls to Class::MOP::Object::meta, avg 10µs/call
134382161µs822.80ms my $meta_attr = $meta->find_attribute_by_name("immutable_trait");
# spent 2.80ms making 82 calls to Class::MOP::Class::find_attribute_by_name, avg 34µs/call
1344
13458216µs my $class_name;
1346
134782159µs82139µs if ( $meta_attr and $trait eq $meta_attr->default ) {
# spent 139µs making 82 calls to Class::MOP::Mixin::AttributeCore::default, avg 2µ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
135782306µs82145µs return $class_name
# spent 145µs making 82 calls to Class::MOP::does_metaclass_exist, avg 2µ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).
136424µs226µs my $meta_name = $meta->_real_ref_name;
# spent 26µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 13µs/call
1365
136626µs21.63ms my $immutable_meta = $meta_name->create(
# spent 1.63ms making 2 calls to Class::MOP::Class::create, avg 815µs/call
1367 $class_name,
1368 superclasses => [ ref $self ],
1369 );
1370
137125µs224.4ms Class::MOP::MiniTrait::apply( $immutable_meta, $trait );
# spent 24.4ms making 2 calls to Class::MOP::MiniTrait::apply, avg 12.2ms/call
1372
137325µs20s $immutable_meta->make_immutable(
# spent 233µs making 2 calls to Class::MOP::Class::make_immutable, avg 117µs/call, recursion: max depth 1, sum of overlapping time 233µs
1374 inline_constructor => 0,
1375 inline_accessors => 0,
1376 );
1377
137827µ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 86 times, avg 3µs/call: # 58 times (200µs+0s) by Class::MOP::Class::_inline_constructor at line 1468, avg 3µs/call # 28 times (49µs+0s) by Class::MOP::Class::_inline_destructor at line 1510, avg 2µs/call
sub _add_inlined_method {
13928629µs my ( $self, $method ) = @_;
1393
139486269µs push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1395}
1396
1397
# spent 303ms (771µs+302) within Class::MOP::Class::_initialize_immutable which was called 82 times, avg 3.69ms/call: # 82 times (771µs+302ms) by Class::MOP::Class::make_immutable at line 1297, avg 3.69ms/call
sub _initialize_immutable {
139882306µs my ( $self, %args ) = @_;
1399
140082108µs $self->{__immutable}{options} = \%args;
140182323µs82302ms $self->_install_inlined_code(%args);
# spent 302ms making 82 calls to Class::MOP::Class::_install_inlined_code, avg 3.68ms/call
1402}
1403
1404
# spent 302ms (778µs+301) within Class::MOP::Class::_install_inlined_code which was called 82 times, avg 3.68ms/call: # 82 times (778µs+301ms) by Class::MOP::Class::_initialize_immutable at line 1401, avg 3.68ms/call
sub _install_inlined_code {
140582150µs my ( $self, %args ) = @_;
1406
1407 # FIXME
140882107µs3348.8ms $self->_inline_accessors(%args) if $args{inline_accessors};
# spent 48.8ms making 33 calls to Class::MOP::Class::_inline_accessors, avg 1.48ms/call
140982177µs58220ms $self->_inline_constructor(%args) if $args{inline_constructor};
# spent 220ms making 58 calls to Class::MOP::Class::_inline_constructor, avg 3.79ms/call
141082346µs2832.5ms $self->_inline_destructor(%args) if $args{inline_destructor};
# spent 32.5ms making 28 calls to Class::MOP::Class::_inline_destructor, avg 1.16ms/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 48.8ms (401µs+48.4) within Class::MOP::Class::_inline_accessors which was called 33 times, avg 1.48ms/call: # 33 times (401µs+48.4ms) by Class::MOP::Class::_install_inlined_code at line 1408, avg 1.48ms/call
sub _inline_accessors {
1422339µs my $self = shift;
1423
142433121µs33142µs foreach my $attr_name ( $self->get_attribute_list ) {
# spent 142µs making 33 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 4µs/call
142576159µs15248.3ms $self->get_attribute($attr_name)->install_accessors(1);
# spent 47.0ms making 75 calls to Class::MOP::Attribute::install_accessors, avg 627µs/call # spent 982µs making 1 call to Moose::Meta::Attribute::install_accessors # spent 251µs making 76 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call
1426 }
1427}
1428
1429
# spent 220ms (1.57+218) within Class::MOP::Class::_inline_constructor which was called 58 times, avg 3.79ms/call: # 58 times (1.57ms+218ms) by Class::MOP::Class::_install_inlined_code at line 1409, avg 3.79ms/call
sub _inline_constructor {
143058145µs my ( $self, %args ) = @_;
1431
14325827µs my $name = $args{constructor_name};
1433 # A class may not even have a constructor, and that's okay.
14345815µs return unless defined $name;
1435
14365885µs581.62ms if ( $self->has_method($name) && !$args{replace_constructor} ) {
# spent 1.62ms making 58 calls to Class::MOP::Mixin::HasMethods::has_method, avg 28µ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
14465832µs my $constructor_class = $args{constructor_class};
1447
1448 {
144911631µs local $@;
145058109µs587.59ms use_package_optimistically($constructor_class);
# spent 8.10ms making 58 calls to Module::Runtime::use_package_optimistically, avg 140µs/call, recursion: max depth 1, sum of overlapping time 511µs
1451 }
1452
145358524µs174197ms my $constructor = $constructor_class->new(
# spent 125ms making 28 calls to Moose::Meta::Method::Constructor::new, avg 4.48ms/call # spent 71.9ms making 30 calls to Class::MOP::Method::Constructor::new, avg 2.40ms/call # spent 59µs making 116 calls to Class::MOP::Package::name, avg 506ns/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
146658315µs587.25ms if ( $args{replace_constructor} or $constructor->can_be_inlined ) {
# spent 7.25ms making 58 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 125µs/call
14675883µs583.81ms $self->add_method( $name => $constructor );
# spent 3.81ms making 58 calls to Class::MOP::Mixin::HasMethods::add_method, avg 66µs/call
146858116µs58200µs $self->_add_inlined_method($constructor);
# spent 200µs making 58 calls to Class::MOP::Class::_add_inlined_method, avg 3µs/call
1469 }
1470}
1471
1472
# spent 32.5ms (984µs+31.5) within Class::MOP::Class::_inline_destructor which was called 28 times, avg 1.16ms/call: # 28 times (984µs+31.5ms) by Class::MOP::Class::_install_inlined_code at line 1410, avg 1.16ms/call
sub _inline_destructor {
147328104µs my ( $self, %args ) = @_;
1474
14752831µs ( exists $args{destructor_class} && defined $args{destructor_class} )
1476 || $self->_throw_exception( NoDestructorClassSpecified => class_name => $self->name,
1477 params => \%args,
1478 );
1479
14802835µs28521µs if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) {
# spent 521µs making 28 calls to Class::MOP::Mixin::HasMethods::has_method, avg 19µ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
14872818µs my $destructor_class = $args{destructor_class};
1488
1489 {
14905616µs local $@;
14912865µs281.02ms use_package_optimistically($destructor_class);
# spent 1.48ms making 28 calls to Module::Runtime::use_package_optimistically, avg 53µs/call, recursion: max depth 1, sum of overlapping time 466µs
1492 }
1493
149428115µs567.53ms return unless $destructor_class->is_needed($self);
# spent 7.51ms making 28 calls to Moose::Meta::Method::Destructor::is_needed, avg 268µs/call # spent 16µs making 28 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 579ns/call
1495
149628277µs8418.7ms my $destructor = $destructor_class->new(
# spent 18.7ms making 28 calls to Moose::Meta::Method::Destructor::new, avg 668µs/call # spent 19µs making 56 calls to Class::MOP::Package::name, avg 343ns/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
150828108µs281.67ms if ( $args{replace_destructor} or $destructor->can_be_inlined ) {
# spent 1.67ms making 28 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 60µs/call
15092834µs281.55ms $self->add_method( 'DESTROY' => $destructor );
# spent 1.55ms making 28 calls to Class::MOP::Mixin::HasMethods::add_method, avg 55µs/call
15102836µs2849µs $self->_add_inlined_method($destructor);
# spent 49µs making 28 calls to Class::MOP::Class::_add_inlined_method, avg 2µs/call
1511 }
1512}
1513
151415µs1;
1515
1516# ABSTRACT: Class Meta Object
1517
1518__END__
 
# spent 13.6ms (12.6+1.07) within Class::MOP::Class::CORE:sort which was called 116 times, avg 117µs/call: # 58 times (9.88ms+531µs) by Class::MOP::Class::_eval_environment at line 709, avg 179µs/call # 58 times (2.68ms+536µs) by Class::MOP::Class::_inline_slot_initializers at line 593, avg 55µs/call
sub Class::MOP::Class::CORE:sort; # opcode