← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:45:08 2010
Reported on Wed Nov 17 22:13:39 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm
StatementsExecuted 14341 statements in 262ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
7858355.2ms817msMoose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 1, inclusive time 57.2ms)
3122147.5ms71.0msMoose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
1102232.4ms428msMoose::Meta::Class::::new_objectMoose::Meta::Class::new_object
731118.8ms128msMoose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_role
18721117.8ms17.8msMoose::Meta::Class::::CORE:substMoose::Meta::Class::CORE:subst (opcode)
421110.9ms628msMoose::Meta::Class::::reinitializeMoose::Meta::Class::reinitialize
11110.1ms13.9msMoose::Meta::Class::::BEGIN@26Moose::Meta::Class::BEGIN@26
72337.58ms5.19sMoose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 79.9ms)
44226.80ms42.6msMoose::Meta::Class::::does_roleMoose::Meta::Class::does_role
116446.72ms1.18sMoose::Meta::Class::::create_anon_classMoose::Meta::Class::create_anon_class
1116.49ms7.50msMoose::Meta::Class::::BEGIN@23Moose::Meta::Class::BEGIN@23
110446.17ms687msMoose::Meta::Class::::initializeMoose::Meta::Class::initialize
73113.69ms5.66msMoose::Meta::Class::::add_roleMoose::Meta::Class::add_role
73113.48ms5.41msMoose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
116113.28ms3.76msMoose::Meta::Class::::_anon_cache_keyMoose::Meta::Class::_anon_cache_key
1112.84ms3.93msMoose::Meta::Class::::BEGIN@24Moose::Meta::Class::BEGIN@24
50112.74ms3.84sMoose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
45112.69ms70.1msMoose::Meta::Class::::add_override_method_modifierMoose::Meta::Class::add_override_method_modifier
51112.65ms3.84sMoose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
1111.95ms16.0msMoose::Meta::Class::::BEGIN@21Moose::Meta::Class::BEGIN@21
42111.79ms7.35msMoose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
22111.72ms1.17sMoose::Meta::Class::::createMoose::Meta::Class::create
1111.61ms2.48msMoose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
1111.58ms2.11msMoose::Meta::Class::::BEGIN@20Moose::Meta::Class::BEGIN@20
1111.39ms16.1msMoose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
1111.30ms1.98msMoose::Meta::Class::::BEGIN@25Moose::Meta::Class::BEGIN@25
110111.26ms1.26msMoose::Meta::Class::::__ANON__[:40]Moose::Meta::Class::__ANON__[:40]
110111.23ms1.23msMoose::Meta::Class::::__ANON__[:35]Moose::Meta::Class::__ANON__[:35]
6811662µs662µsMoose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
611485µs1.69msMoose::Meta::Class::::calculate_all_rolesMoose::Meta::Class::calculate_all_roles
11611484µs484µsMoose::Meta::Class::::CORE:sortMoose::Meta::Class::CORE:sort (opcode)
5111293µs293µsMoose::Meta::Class::::CORE:matchMoose::Meta::Class::CORE:match (opcode)
111116µs143µsMoose::Meta::Class::::BEGIN@4Moose::Meta::Class::BEGIN@4
111114µs2.66msMoose::Meta::Class::::_process_inherited_attributeMoose::Meta::Class::_process_inherited_attribute
11167µs224µsMoose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
11154µs147µsMoose::Meta::Class::::BEGIN@5Moose::Meta::Class::BEGIN@5
11142µs319µsMoose::Meta::Class::::BEGIN@29Moose::Meta::Class::BEGIN@29
11142µs66µsMoose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
11138µs254µsMoose::Meta::Class::::BEGIN@12Moose::Meta::Class::BEGIN@12
11137µs37µsMoose::Meta::Class::::BEGIN@7Moose::Meta::Class::BEGIN@7
11137µs203µsMoose::Meta::Class::::BEGIN@9Moose::Meta::Class::BEGIN@9
11136µs194µsMoose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
11129µs29µsMoose::Meta::Class::::BEGIN@27Moose::Meta::Class::BEGIN@27
0000s0sMoose::Meta::Class::::_find_next_method_by_name_which_is_not_overriddenMoose::Meta::Class::_find_next_method_by_name_which_is_not_overridden
0000s0sMoose::Meta::Class::::_fix_class_metaclass_incompatibilityMoose::Meta::Class::_fix_class_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_fix_single_metaclass_incompatibilityMoose::Meta::Class::_fix_single_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_replace_selfMoose::Meta::Class::_replace_self
0000s0sMoose::Meta::Class::::add_augment_method_modifierMoose::Meta::Class::add_augment_method_modifier
0000s0sMoose::Meta::Class::::calculate_all_roles_with_inheritanceMoose::Meta::Class::calculate_all_roles_with_inheritance
0000s0sMoose::Meta::Class::::create_errorMoose::Meta::Class::create_error
0000s0sMoose::Meta::Class::::raise_errorMoose::Meta::Class::raise_error
0000s0sMoose::Meta::Class::::role_applicationsMoose::Meta::Class::role_applications
0000s0sMoose::Meta::Class::::throw_errorMoose::Meta::Class::throw_error
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::Class;
3
43156µs2169µs
# spent 143µs (116+26) within Moose::Meta::Class::BEGIN@4 which was called: # once (116µs+26µs) by Moose::BEGIN@19 at line 4
use strict;
# spent 143µs making 1 call to Moose::Meta::Class::BEGIN@4 # spent 26µs making 1 call to strict::import
53148µs2239µs
# spent 147µs (54+93) within Moose::Meta::Class::BEGIN@5 which was called: # once (54µs+93µs) by Moose::BEGIN@19 at line 5
use warnings;
# spent 147µs making 1 call to Moose::Meta::Class::BEGIN@5 # spent 93µs making 1 call to warnings::import
6
73119µs137µs
# spent 37µs within Moose::Meta::Class::BEGIN@7 which was called: # once (37µs+0s) by Moose::BEGIN@19 at line 7
use Class::MOP;
# spent 37µs making 1 call to Moose::Meta::Class::BEGIN@7
8
93194µs2368µs
# spent 203µs (37+166) within Moose::Meta::Class::BEGIN@9 which was called: # once (37µs+166µs) by Moose::BEGIN@19 at line 9
use Carp qw( confess );
# spent 203µs making 1 call to Moose::Meta::Class::BEGIN@9 # spent 166µs making 1 call to Exporter::import
103100µs290µs
# spent 66µs (42+24) within Moose::Meta::Class::BEGIN@10 which was called: # once (42µs+24µs) by Moose::BEGIN@19 at line 10
use Data::OptList;
# spent 66µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 24µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284]
113113µs2381µs
# spent 224µs (67+157) within Moose::Meta::Class::BEGIN@11 which was called: # once (67µs+157µs) by Moose::BEGIN@19 at line 11
use List::Util qw( first );
# spent 224µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 156µs making 1 call to Exporter::import
123108µs2470µs
# spent 254µs (38+216) within Moose::Meta::Class::BEGIN@12 which was called: # once (38µs+216µs) by Moose::BEGIN@19 at line 12
use List::MoreUtils qw( any all uniq first_index );
# spent 254µs making 1 call to Moose::Meta::Class::BEGIN@12 # spent 216µs making 1 call to Exporter::import
133215µs2353µs
# spent 194µs (36+158) within Moose::Meta::Class::BEGIN@13 which was called: # once (36µs+158µs) by Moose::BEGIN@19 at line 13
use Scalar::Util 'weaken', 'blessed';
# spent 194µs making 1 call to Moose::Meta::Class::BEGIN@13 # spent 158µs making 1 call to Exporter::import
14
1517µsour $VERSION = '1.19';
161108µs$VERSION = eval $VERSION;
# spent 16µs executing statements in string eval
1716µsour $AUTHORITY = 'cpan:STEVAN';
18
193490µs116.1ms
# spent 16.1ms (1.39+14.7) within Moose::Meta::Class::BEGIN@19 which was called: # once (1.39ms+14.7ms) by Moose::BEGIN@19 at line 19
use Moose::Meta::Method::Overridden;
# spent 16.1ms making 1 call to Moose::Meta::Class::BEGIN@19
203517µs12.11ms
# spent 2.11ms (1.58+524µs) within Moose::Meta::Class::BEGIN@20 which was called: # once (1.58ms+524µs) by Moose::BEGIN@19 at line 20
use Moose::Meta::Method::Augmented;
# spent 2.11ms making 1 call to Moose::Meta::Class::BEGIN@20
213628µs116.0ms
# spent 16.0ms (1.95+14.1) within Moose::Meta::Class::BEGIN@21 which was called: # once (1.95ms+14.1ms) by Moose::BEGIN@19 at line 21
use Moose::Error::Default;
# spent 16.0ms making 1 call to Moose::Meta::Class::BEGIN@21
223489µs12.48ms
# spent 2.48ms (1.61+870µs) within Moose::Meta::Class::BEGIN@22 which was called: # once (1.61ms+870µs) by Moose::BEGIN@19 at line 22
use Moose::Meta::Class::Immutable::Trait;
# spent 2.48ms making 1 call to Moose::Meta::Class::BEGIN@22
233516µs17.50ms
# spent 7.50ms (6.49+1.01) within Moose::Meta::Class::BEGIN@23 which was called: # once (6.49ms+1.01ms) by Moose::BEGIN@19 at line 23
use Moose::Meta::Method::Constructor;
# spent 7.50ms making 1 call to Moose::Meta::Class::BEGIN@23
243494µs13.93ms
# spent 3.93ms (2.84+1.09) within Moose::Meta::Class::BEGIN@24 which was called: # once (2.84ms+1.09ms) by Moose::BEGIN@19 at line 24
use Moose::Meta::Method::Destructor;
# spent 3.93ms making 1 call to Moose::Meta::Class::BEGIN@24
253586µs11.98ms
# spent 1.98ms (1.30+676µs) within Moose::Meta::Class::BEGIN@25 which was called: # once (1.30ms+676µs) by Moose::BEGIN@19 at line 25
use Moose::Meta::Method::Meta;
# spent 1.98ms making 1 call to Moose::Meta::Class::BEGIN@25
263765µs214.5ms
# spent 13.9ms (10.1+3.86) within Moose::Meta::Class::BEGIN@26 which was called: # once (10.1ms+3.86ms) by Moose::BEGIN@19 at line 26
use Moose::Util;
# spent 13.9ms making 1 call to Moose::Meta::Class::BEGIN@26 # spent 589µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
273107µs129µs
# spent 29µs within Moose::Meta::Class::BEGIN@27 which was called: # once (29µs+0s) by Moose::BEGIN@19 at line 27
use Class::MOP::MiniTrait;
# spent 29µs making 1 call to Moose::Meta::Class::BEGIN@27
28
2938.07ms2595µs
# spent 319µs (42+277) within Moose::Meta::Class::BEGIN@29 which was called: # once (42µs+277µs) by Moose::BEGIN@19 at line 29
use base 'Class::MOP::Class';
# spent 319µs making 1 call to Moose::Meta::Class::BEGIN@29 # spent 277µs making 1 call to base::import
30
31121µs112.8msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 12.8ms making 1 call to Class::MOP::MiniTrait::apply
32
33__PACKAGE__->meta->add_attribute('roles' => (
34 reader => 'roles',
351101.56ms
# spent 1.23ms within Moose::Meta::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm:35] which was called 110 times, avg 11µs/call: # 110 times (1.23ms+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call
default => sub { [] }
36170µs22.79ms));
# spent 2.71ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 84µs making 1 call to Class::MOP::Object::meta
37
38__PACKAGE__->meta->add_attribute('role_applications' => (
39 reader => '_get_role_applications',
401101.40ms
# spent 1.26ms within Moose::Meta::Class::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Class.pm:40] which was called 110 times, avg 11µs/call: # 110 times (1.26ms+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 11µs/call
default => sub { [] }
41133µs22.20ms));
# spent 2.11ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 87µs making 1 call to Class::MOP::Object::meta
42
43145µs32.11ms__PACKAGE__->meta->add_attribute(
# spent 1.87ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 125µs making 1 call to Class::MOP::Attribute::new # spent 110µs making 1 call to Class::MOP::Object::meta
44 Class::MOP::Attribute->new('immutable_trait' => (
45 accessor => "immutable_trait",
46 default => 'Moose::Meta::Class::Immutable::Trait',
47 ))
48);
49
50126µs22.13ms__PACKAGE__->meta->add_attribute('constructor_class' => (
# spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 86µs making 1 call to Class::MOP::Object::meta
51 accessor => 'constructor_class',
52 default => 'Moose::Meta::Method::Constructor',
53));
54
55124µs22.17ms__PACKAGE__->meta->add_attribute('destructor_class' => (
# spent 2.09ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 84µs making 1 call to Class::MOP::Object::meta
56 accessor => 'destructor_class',
57 default => 'Moose::Meta::Method::Destructor',
58));
59
60126µs27.81ms__PACKAGE__->meta->add_attribute('error_class' => (
# spent 7.72ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 84µs making 1 call to Class::MOP::Object::meta
61 accessor => 'error_class',
62 default => 'Moose::Error::Default',
63));
64
65
# spent 687ms (6.17+680) within Moose::Meta::Class::initialize which was called 110 times, avg 6.24ms/call: # 45 times (2.59ms+211ms) by Moose::init_meta at line 199 of Moose.pm, avg 4.74ms/call # 42 times (2.32ms+371ms) by Class::MOP::Package::reinitialize at line 60 of Class/MOP/Package.pm, avg 8.90ms/call # 22 times (1.16ms+91.9ms) by Class::MOP::Class::create at line 525 of Class/MOP/Class.pm, avg 4.23ms/call # once (110µs+6.52ms) by metaclass::import at line 45 of metaclass.pm
sub initialize {
66110511µs my $class = shift;
67110316µs my $pkg = shift;
681105.10ms220680ms return Class::MOP::get_metaclass_by_name($pkg)
# spent 679ms making 110 calls to Class::MOP::Class::initialize, avg 6.18ms/call # spent 1.02ms making 110 calls to Class::MOP::get_metaclass_by_name, avg 9µs/call
69 || $class->SUPER::initialize($pkg,
70 'attribute_metaclass' => 'Moose::Meta::Attribute',
71 'method_metaclass' => 'Moose::Meta::Method',
72 'instance_metaclass' => 'Moose::Meta::Instance',
73 @_
74 );
75}
76
77
# spent 1.17s (1.72ms+1.17) within Moose::Meta::Class::create which was called 22 times, avg 53.2ms/call: # 22 times (1.72ms+1.17s) by Class::MOP::Class::create_anon_class at line 453 of Class/MOP/Class.pm, avg 53.2ms/call
sub create {
7822178µs my ($class, $package_name, %options) = @_;
79
8022125µs (ref $options{roles} eq 'ARRAY')
81 || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
82 if exists $options{roles};
832286µs my $roles = delete $options{roles};
84
8522575µs22331ms my $new_meta = $class->SUPER::create($package_name, %options);
# spent 331ms making 22 calls to Class::MOP::Class::create, avg 15.0ms/call
86
8722344µs20838ms if ($roles) {
# spent 838ms making 20 calls to Moose::Util::apply_all_roles, avg 41.9ms/call
88 Moose::Util::apply_all_roles( $new_meta, @$roles );
89 }
90
9122410µs return $new_meta;
92}
93
9413µsmy %ANON_CLASSES;
95
96
# spent 1.18s (6.72ms+1.18) within Moose::Meta::Class::create_anon_class which was called 116 times, avg 10.2ms/call: # 80 times (3.81ms+70.3ms) by Moose::Util::MetaRole::_make_new_class at line 163 of Moose/Util/MetaRole.pm, avg 927µs/call # 28 times (2.06ms+791ms) by Moose::Meta::Attribute::Native::Trait::_native_accessor_class_for at line 172 of Moose/Meta/Attribute/Native/Trait.pm, avg 28.3ms/call # 6 times (629µs+285ms) by Moose::Meta::Attribute::interpolate_class at line 124 of Moose/Meta/Attribute.pm, avg 47.6ms/call # 2 times (219µs+29.8ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm:31] at line 27 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 15.0ms/call
sub create_anon_class {
971161.18ms my ($self, %options) = @_;
98
99116549µs my $cache_ok = delete $options{cache};
100
1011161.46ms1163.76ms my $cache_key
# spent 3.76ms making 116 calls to Moose::Meta::Class::_anon_cache_key, avg 32µs/call
102 = _anon_cache_key( $options{superclasses}, $options{roles} );
103
1041161.74ms if ($cache_ok && defined $ANON_CLASSES{$cache_key}) {
105 return $ANON_CLASSES{$cache_key};
106 }
107
10822131µs $options{weaken} = !$cache_ok
109 unless exists $options{weaken};
110
11122775µs221.17s my $new_class = $self->SUPER::create_anon_class(%options);
# spent 1.17s making 22 calls to Class::MOP::Class::create_anon_class, avg 53.3ms/call
112
1132292µs if ($cache_ok) {
11420153µs $ANON_CLASSES{$cache_key} = $new_class;
11520444µs20166µs weaken($ANON_CLASSES{$cache_key});
# spent 166µs making 20 calls to Scalar::Util::weaken, avg 8µs/call
116 }
117
11822476µs return $new_class;
119}
120
12168876µs
# spent 662µs within Moose::Meta::Class::_meta_method_class which was called 68 times, avg 10µs/call: # 68 times (662µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 30 of Class/MOP/Mixin/HasMethods.pm, avg 10µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
122
123
# spent 3.76ms (3.28+484µs) within Moose::Meta::Class::_anon_cache_key which was called 116 times, avg 32µs/call: # 116 times (3.28ms+484µs) by Moose::Meta::Class::create_anon_class at line 101, avg 32µs/call
sub _anon_cache_key {
124 # Makes something like Super::Class|Super::Class::2=Role|Role::1
125 return join '=' => (
126 join( '|', @{ $_[0] || [] } ),
1271164.01ms116484µs join( '|', sort @{ $_[1] || [] } ),
# spent 484µs making 116 calls to Moose::Meta::Class::CORE:sort, avg 4µs/call
128 );
129}
130
131
# spent 628ms (10.9+617) within Moose::Meta::Class::reinitialize which was called 42 times, avg 14.9ms/call: # 42 times (10.9ms+617ms) by Moose::Util::MetaRole::_make_new_metaclass at line 128 of Moose/Util/MetaRole.pm, avg 14.9ms/call
sub reinitialize {
13242165µs my $self = shift;
1334298µs my $pkg = shift;
134
13542809µs42291µs my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
# spent 291µs making 42 calls to Scalar::Util::blessed, avg 7µs/call
136
1374277µs my $cache_key;
138
1394285µs my %existing_classes;
14042210µs if ($meta) {
141425.50ms2943.80ms %existing_classes = map { $_ => $meta->$_() } qw(
# spent 601µs making 42 calls to Moose::Meta::Class::destructor_class, avg 14µs/call # spent 566µs making 42 calls to Moose::Meta::Class::error_class, avg 13µs/call # spent 565µs making 42 calls to Moose::Meta::Class::constructor_class, avg 13µs/call # spent 557µs making 42 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 13µs/call # spent 525µs making 42 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 13µs/call # spent 514µs making 42 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 12µs/call # spent 475µs making 42 calls to Class::MOP::Class::instance_metaclass, avg 11µs/call
142 attribute_metaclass
143 method_metaclass
144 wrapped_method_metaclass
145 instance_metaclass
146 constructor_class
147 destructor_class
148 error_class
149 );
150
151 $cache_key = _anon_cache_key(
152 [ $meta->superclasses ],
15342594µs421.81ms [ map { $_->name } @{ $meta->roles } ],
# spent 1.81ms making 42 calls to Class::MOP::Class::is_anon_class, avg 43µs/call
154 ) if $meta->is_anon_class;
155 }
156
157421.70ms42611ms my $new_meta = $self->SUPER::reinitialize(
# spent 611ms making 42 calls to Class::MOP::Class::reinitialize, avg 14.5ms/call
158 $pkg,
159 %existing_classes,
160 @_,
161 );
162
16342862µs return $new_meta unless defined $cache_key;
164
165 my $new_cache_key = _anon_cache_key(
166 [ $meta->superclasses ],
167 [ map { $_->name } @{ $meta->roles } ],
168 );
169
170 delete $ANON_CLASSES{$cache_key};
171 $ANON_CLASSES{$new_cache_key} = $new_meta;
172 weaken($ANON_CLASSES{$new_cache_key});
173
174 return $new_meta;
175}
176
177
# spent 5.66ms (3.69+1.97) within Moose::Meta::Class::add_role which was called 73 times, avg 77µs/call: # 73 times (3.69ms+1.97ms) by Moose::Meta::Role::Application::ToClass::apply at line 33 of Moose/Meta/Role/Application/ToClass.pm, avg 77µs/call
sub add_role {
17873261µs my ($self, $role) = @_;
179732.60ms146988µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 527µs making 73 calls to Scalar::Util::blessed, avg 7µs/call # spent 460µs making 73 calls to UNIVERSAL::isa, avg 6µs/call
180 || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role);
181731.67ms73982µs push @{$self->roles} => $role;
# spent 982µs making 73 calls to Moose::Meta::Class::roles, avg 13µs/call
182}
183
184sub role_applications {
185 my ($self) = @_;
186
187 return @{$self->_get_role_applications};
188}
189
190
# spent 5.41ms (3.48+1.93) within Moose::Meta::Class::add_role_application which was called 73 times, avg 74µs/call: # 73 times (3.48ms+1.93ms) by Moose::Meta::Role::Application::ToClass::apply at line 34 of Moose/Meta/Role/Application/ToClass.pm, avg 74µs/call
sub add_role_application {
19173253µs my ($self, $application) = @_;
192732.26ms146799µs (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
# spent 406µs making 73 calls to UNIVERSAL::isa, avg 6µs/call # spent 393µs making 73 calls to Scalar::Util::blessed, avg 5µs/call
193 || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application);
194731.81ms731.13ms push @{$self->_get_role_applications} => $application;
# spent 1.13ms making 73 calls to Moose::Meta::Class::_get_role_applications, avg 15µs/call
195}
196
197
# spent 1.69ms (485µs+1.20) within Moose::Meta::Class::calculate_all_roles which was called 6 times, avg 281µs/call: # 6 times (485µs+1.20ms) by Moose::Meta::Attribute::Native::Trait::_build_native_type at line 183 of Moose/Meta/Attribute/Native/Trait.pm, avg 281µs/call
sub calculate_all_roles {
198618µs my $self = shift;
199611µs my %seen;
20024492µs241.20ms grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
# spent 1.07ms making 6 calls to Moose::Meta::Role::calculate_all_roles, avg 178µs/call # spent 77µs making 6 calls to Moose::Meta::Class::roles, avg 13µs/call # spent 57µs making 12 calls to Class::MOP::Package::name, avg 5µs/call
201}
202
203sub calculate_all_roles_with_inheritance {
204 my $self = shift;
205 my %seen;
206 grep { !$seen{$_->name}++ }
207 map { Class::MOP::class_of($_)->can('calculate_all_roles')
208 ? Class::MOP::class_of($_)->calculate_all_roles
209 : () }
210 $self->linearized_isa;
211}
212
213
# spent 42.6ms (6.80+35.8) within Moose::Meta::Class::does_role which was called 44 times, avg 969µs/call: # 38 times (4.94ms+30.2ms) by List::MoreUtils::all at line 160 of Moose/Util/MetaRole.pm, avg 926µs/call # 6 times (1.86ms+5.58ms) by Moose::Object::does at line 125 of Moose/Object.pm, avg 1.24ms/call
sub does_role {
21444228µs my ($self, $role_name) = @_;
215
21644124µs (defined $role_name)
217 || $self->throw_error("You must supply a role name to look for");
218
21944924µs4429.7ms foreach my $class ($self->class_precedence_list) {
# spent 29.7ms making 44 calls to Class::MOP::Class::class_precedence_list, avg 675µs/call
2201301.35ms1303.68ms my $meta = Class::MOP::class_of($class);
# spent 3.68ms making 130 calls to Class::MOP::class_of, avg 28µs/call
221 # when a Moose metaclass is itself extended with a role,
222 # this check needs to be done since some items in the
223 # class_precedence_list might in fact be Class::MOP
224 # based still.
2251302.37ms130859µs next unless $meta && $meta->can('roles');
# spent 859µs making 130 calls to UNIVERSAL::can, avg 7µs/call
226821.47ms821.03ms foreach my $role (@{$meta->roles}) {
# spent 1.03ms making 82 calls to Moose::Meta::Class::roles, avg 13µs/call
2276107µs6542µs return 1 if $role->does_role($role_name);
# spent 542µs making 6 calls to Moose::Meta::Role::does_role, avg 90µs/call
228 }
229 }
23044585µs return 0;
231}
232
233
# spent 128ms (18.8+109) within Moose::Meta::Class::excludes_role which was called 73 times, avg 1.75ms/call: # 73 times (18.8ms+109ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 1.75ms/call
sub excludes_role {
23473336µs my ($self, $role_name) = @_;
235
23673184µs (defined $role_name)
237 || $self->throw_error("You must supply a role name to look for");
238
239732.20ms7388.9ms foreach my $class ($self->class_precedence_list) {
# spent 88.9ms making 73 calls to Class::MOP::Class::class_precedence_list, avg 1.22ms/call
2404274.26ms42711.9ms my $meta = Class::MOP::class_of($class);
# spent 11.9ms making 427 calls to Class::MOP::class_of, avg 28µs/call
241 # when a Moose metaclass is itself extended with a role,
242 # this check needs to be done since some items in the
243 # class_precedence_list might in fact be Class::MOP
244 # based still.
2454277.81ms4272.83ms next unless $meta && $meta->can('roles');
# spent 2.83ms making 427 calls to UNIVERSAL::can, avg 7µs/call
2461823.10ms1822.23ms foreach my $role (@{$meta->roles}) {
# spent 2.23ms making 182 calls to Moose::Meta::Class::roles, avg 12µs/call
247761.27ms763.29ms return 1 if $role->excludes_role($role_name);
# spent 3.29ms making 76 calls to Moose::Meta::Role::excludes_role, avg 43µs/call
248 }
249 }
25073947µs return 0;
251}
252
253
# spent 428ms (32.4+396) within Moose::Meta::Class::new_object which was called 110 times, avg 3.89ms/call: # 68 times (28.1ms+346ms) by Moose::Meta::Attribute::_new or Moose::Meta::Role::_new at line 4 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 5.50ms/call # 42 times (4.27ms+50.0ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::construct_parameters at line 68 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm, avg 1.29ms/call
sub new_object {
254110447µs my $self = shift;
255110375µs my $params = @_ == 1 ? $_[0] : {@_};
2561102.92ms110350ms my $object = $self->SUPER::new_object($params);
# spent 350ms making 110 calls to Class::MOP::Class::new_object, avg 3.18ms/call
257
2581105.50ms11033.5ms foreach my $attr ( $self->get_all_attributes() ) {
# spent 30.7ms making 66 calls to Class::MOP::Class::get_all_attributes, avg 465µs/call # spent 2.80ms making 44 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::get_all_attributes, avg 64µs/call
259
260170628.0ms181610.3ms next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 9.16ms making 1706 calls to UNIVERSAL::can, avg 5µs/call # spent 1.16ms making 110 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 11µs/call
261
262 my $init_arg = $attr->init_arg;
263
264 next unless defined $init_arg;
265
266 next unless exists $params->{$init_arg};
267
268 $attr->trigger->(
269 $object,
270 (
271 $attr->should_coerce
272 ? $attr->get_read_method_ref->($object)
273 : $params->{$init_arg}
274 ),
275 );
276 }
277
2781103.03ms1521.98ms $object->BUILDALL($params) if $object->can('BUILDALL');
# spent 1.04ms making 42 calls to Moose::Object::BUILDALL, avg 25µs/call # spent 940µs making 110 calls to UNIVERSAL::can, avg 9µs/call
279
2801101.46ms return $object;
281}
282
283
# spent 817ms (55.2+762) within Moose::Meta::Class::superclasses which was called 785 times, avg 1.04ms/call: # 264 times (14.7ms+50.5ms) by Class::MOP::Class::class_precedence_list at line 929 of Class/MOP/Class.pm, avg 247µs/call # 218 times (13.8ms+32.5ms) by Class::MOP::Class::_check_metaclass_compatibility at line 213 of Class/MOP/Class.pm, avg 212µs/call # 108 times (7.19ms+-7.19ms) by Class::MOP::Class::_superclasses_updated at line 870 of Class/MOP/Class.pm, avg 0s/call # 90 times (8.39ms+283ms) by Moose::init_meta at line 218 of Moose.pm, avg 3.24ms/call # 42 times (2.93ms+8.80ms) by Moose::Util::MetaRole::apply_base_class_roles at line 140 of Moose/Util/MetaRole.pm, avg 279µs/call # 38 times (4.41ms+211ms) by Moose::Util::MetaRole::apply_base_class_roles at line 146 of Moose/Util/MetaRole.pm, avg 5.67ms/call # 22 times (3.40ms+165ms) by Class::MOP::Class::create at line 532 of Class/MOP/Class.pm, avg 7.66ms/call # 3 times (402µs+17.8ms) by Moose::extends at line 54 of Moose.pm, avg 6.06ms/call
sub superclasses {
2847852.29ms my $self = shift;
2857859.64ms78529.6ms my $supers = Data::OptList::mkopt(\@_);
# spent 29.6ms making 785 calls to Data::OptList::mkopt, avg 38µs/call
2867854.82ms foreach my $super (@{ $supers }) {
287120512µs my ($name, $opts) = @{ $super };
2881201.31ms12024.8ms Class::MOP::load_class($name, $opts);
# spent 27.0ms making 120 calls to Class::MOP::load_class, avg 225µs/call, recursion: max depth 2, sum of overlapping time 2.28ms
2891201.41ms1203.87ms my $meta = Class::MOP::class_of($name);
# spent 3.87ms making 120 calls to Class::MOP::class_of, avg 32µs/call
2901203.98ms1191.55ms $self->throw_error("You cannot inherit from a Moose Role ($name)")
# spent 1.55ms making 119 calls to UNIVERSAL::isa, avg 13µs/call
291 if $meta && $meta->isa('Moose::Meta::Role')
292 }
29378529.9ms785720ms return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
# spent 757ms making 785 calls to Class::MOP::Class::superclasses, avg 964µs/call, recursion: max depth 1, sum of overlapping time 36.5ms
294}
295
296### ---------------------------------------------
297
298
# spent 5.19s (7.58ms+5.18) within Moose::Meta::Class::add_attribute which was called 72 times, avg 72.1ms/call: # 50 times (5.15ms+5.09s) by Moose::has at line 70 of Moose.pm, avg 102ms/call # 21 times (2.28ms+85.3ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 142 of Moose/Meta/Role/Application/ToClass.pm, avg 4.17ms/call # once (154µs+9.03ms) by MooseX::Role::Parameterized::Meta::Role::Parameterizable::add_parameter at line 55 of MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm
sub add_attribute {
29972224µs my $self = shift;
300722.78ms1443.84s my $attr =
# spent 3.84s making 51 calls to Moose::Meta::Class::_process_attribute, avg 75.3ms/call # spent 427µs making 72 calls to Scalar::Util::blessed, avg 6µs/call # spent 148µs making 21 calls to UNIVERSAL::isa, avg 7µs/call
301 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
302 ? $_[0]
303 : $self->_process_attribute(@_));
304721.97ms721.42s $self->SUPER::add_attribute($attr);
# spent 1.42s making 72 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 19.7ms/call
305 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
306 # 'bare' and doesn't implement this method
307722.65ms1433.59ms if ($attr->can('_check_associated_methods')) {
# spent 2.73ms making 71 calls to Moose::Meta::Attribute::_check_associated_methods, avg 38µs/call # spent 859µs making 72 calls to UNIVERSAL::can, avg 12µs/call
308 $attr->_check_associated_methods;
309 }
31072970µs return $attr;
311}
312
313
# spent 70.1ms (2.69+67.5) within Moose::Meta::Class::add_override_method_modifier which was called 45 times, avg 1.56ms/call: # 45 times (2.69ms+67.5ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 208 of Moose/Meta/Role/Application/ToClass.pm, avg 1.56ms/call
sub add_override_method_modifier {
31445233µs my ($self, $name, $method, $_super_package) = @_;
315
31645490µs459.08ms (!$self->has_method($name))
# spent 9.08ms making 45 calls to Class::MOP::Mixin::HasMethods::has_method, avg 202µs/call
317 || $self->throw_error("Cannot add an override method if a local method is already present");
318
319451.65ms9058.4ms $self->add_method($name => Moose::Meta::Method::Overridden->new(
# spent 36.5ms making 45 calls to Moose::Meta::Method::Overridden::new, avg 812µs/call # spent 21.9ms making 45 calls to Class::MOP::Mixin::HasMethods::add_method, avg 486µs/call
320 method => $method,
321 class => $self,
322 package => $_super_package, # need this for roles
323 name => $name,
324 ));
325}
326
327sub add_augment_method_modifier {
328 my ($self, $name, $method) = @_;
329 (!$self->has_method($name))
330 || $self->throw_error("Cannot add an augment method if a local method is already present");
331
332 $self->add_method($name => Moose::Meta::Method::Augmented->new(
333 method => $method,
334 class => $self,
335 name => $name,
336 ));
337}
338
339## Private Utility methods ...
340
341sub _find_next_method_by_name_which_is_not_overridden {
342 my ($self, $name) = @_;
343 foreach my $method ($self->find_all_methods_by_name($name)) {
344 return $method->{code}
345 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
346 }
347 return undef;
348}
349
350## Metaclass compatibility
351
352
# spent 71.0ms (47.5+23.6) within Moose::Meta::Class::_base_metaclasses which was called 312 times, avg 228µs/call: # 162 times (25.1ms+12.4ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 343 of Class/MOP/Class.pm, avg 232µs/call # 150 times (22.4ms+11.2ms) by Class::MOP::Class::_check_metaclass_compatibility at line 218 of Class/MOP/Class.pm, avg 224µs/call
sub _base_metaclasses {
3533121.01ms my $self = shift;
35431211.4ms3125.82ms my %metaclasses = $self->SUPER::_base_metaclasses;
# spent 5.82ms making 312 calls to Class::MOP::Class::_base_metaclasses, avg 19µs/call
3553123.15ms for my $class (keys %metaclasses) {
356187241.9ms187217.8ms $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
# spent 17.8ms making 1872 calls to Moose::Meta::Class::CORE:subst, avg 9µs/call
357 }
358 return (
3593127.30ms %metaclasses,
360 error_class => 'Moose::Error::Default',
361 );
362}
363
364sub _fix_class_metaclass_incompatibility {
365 my $self = shift;
366 my ($super_meta) = @_;
367
368 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
369
370 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
371 ($self->is_pristine)
372 || confess "Can't fix metaclass incompatibility for "
373 . $self->name
374 . " because it is not pristine.";
375 my $super_meta_name = $super_meta->_real_ref_name;
376 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
377 my $new_self = $class_meta_subclass_meta_name->reinitialize(
378 $self->name,
379 );
380
381 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
382 }
383}
384
385sub _fix_single_metaclass_incompatibility {
386 my $self = shift;
387 my ($metaclass_type, $super_meta) = @_;
388
389 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
390
391 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
392 ($self->is_pristine)
393 || confess "Can't fix metaclass incompatibility for "
394 . $self->name
395 . " because it is not pristine.";
396 my $super_meta_name = $super_meta->_real_ref_name;
397 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
398 my $new_self = $super_meta->reinitialize(
399 $self->name,
400 $metaclass_type => $class_specific_meta_subclass_meta_name,
401 );
402
403 $self->_replace_self( $new_self, $super_meta_name );
404 }
405}
406
407sub _replace_self {
408 my $self = shift;
409 my ( $new_self, $new_class) = @_;
410
411 %$self = %$new_self;
412 bless $self, $new_class;
413
414 # We need to replace the cached metaclass instance or else when it goes
415 # out of scope Class::MOP::Class destroy's the namespace for the
416 # metaclass's class, causing much havoc.
417 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
418 Class::MOP::store_metaclass_by_name( $self->name, $self );
419 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
420}
421
422
# spent 3.84s (2.65ms+3.84) within Moose::Meta::Class::_process_attribute which was called 51 times, avg 75.3ms/call: # 51 times (2.65ms+3.84s) by Moose::Meta::Class::add_attribute at line 300, avg 75.3ms/call
sub _process_attribute {
42351556µs my ( $self, $name, @args ) = @_;
424
42551162µs @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
426
42751892µs51293µs if (($name || '') =~ /^\+(.*)/) {
# spent 293µs making 51 calls to Moose::Meta::Class::CORE:match, avg 6µs/call
428128µs12.66ms return $self->_process_inherited_attribute($1, @args);
# spent 2.66ms making 1 call to Moose::Meta::Class::_process_inherited_attribute
429 }
430 else {
431501.30ms503.84s return $self->_process_new_attribute($name, @args);
# spent 3.84s making 50 calls to Moose::Meta::Class::_process_new_attribute, avg 76.7ms/call
432 }
433}
434
435
# spent 3.84s (2.74ms+3.83) within Moose::Meta::Class::_process_new_attribute which was called 50 times, avg 76.7ms/call: # 50 times (2.74ms+3.83s) by Moose::Meta::Class::_process_attribute at line 431, avg 76.7ms/call
sub _process_new_attribute {
43650511µs my ( $self, $name, @args ) = @_;
437
438502.01ms1003.83s $self->attribute_metaclass->interpolate_class_and_new($name, @args);
# spent 3.83s making 50 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 76.7ms/call # spent 672µs making 50 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 13µs/call
439}
440
441
# spent 2.66ms (114µs+2.54) within Moose::Meta::Class::_process_inherited_attribute which was called: # once (114µs+2.54ms) by Moose::Meta::Class::_process_attribute at line 428
sub _process_inherited_attribute {
442114µs my ($self, $attr_name, %options) = @_;
443129µs1933µs my $inherited_attr = $self->find_attribute_by_name($attr_name);
# spent 933µs making 1 call to Class::MOP::Class::find_attribute_by_name
444 (defined $inherited_attr)
44512µs || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name);
446135µs115µs if ($inherited_attr->isa('Moose::Meta::Attribute')) {
# spent 15µs making 1 call to UNIVERSAL::isa
447 return $inherited_attr->clone_and_inherit_options(%options);
448 }
449 else {
450 # NOTE:
451 # kind of a kludge to handle Class::MOP::Attributes
452140µs11.60ms return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
# spent 1.60ms making 1 call to Moose::Meta::Attribute::clone_and_inherit_options
453 }
454}
455
456## Immutability
457
458
# spent 7.35ms (1.79+5.56) within Moose::Meta::Class::_immutable_options which was called 42 times, avg 175µs/call: # 42 times (1.79ms+5.56ms) by Class::MOP::Class::make_immutable at line 1180 of Class/MOP/Class.pm, avg 175µs/call
sub _immutable_options {
45942165µs my ( $self, @args ) = @_;
460
461421.64ms425.56ms $self->SUPER::_immutable_options(
# spent 5.56ms making 42 calls to Class::MOP::Class::_immutable_options, avg 132µs/call
462 inline_destructor => 1,
463
464 # Moose always does this when an attribute is created
465 inline_accessors => 0,
466
467 @args,
468 );
469}
470
471## -------------------------------------------------
472
47313µsour $error_level;
474
475sub throw_error {
476 my ( $self, @args ) = @_;
477 local $error_level = ($error_level || 0) + 1;
478 $self->raise_error($self->create_error(@args));
479}
480
481sub raise_error {
482 my ( $self, @args ) = @_;
483 die @args;
484}
485
486sub create_error {
487 my ( $self, @args ) = @_;
488
489 require Carp::Heavy;
490
491 local $error_level = ($error_level || 0 ) + 1;
492
493 if ( @args % 2 == 1 ) {
494 unshift @args, "message";
495 }
496
497 my %args = ( metaclass => $self, last_error => $@, @args );
498
499 $args{depth} += $error_level;
500
501 my $class = ref $self ? $self->error_class : "Moose::Error::Default";
502
503 Class::MOP::load_class($class);
504
505 $class->new(
506 Carp::caller_info($args{depth}),
507 %args
508 );
509}
510
511180µs1;
512
513__END__
 
# spent 293µs within Moose::Meta::Class::CORE:match which was called 51 times, avg 6µs/call: # 51 times (293µs+0s) by Moose::Meta::Class::_process_attribute at line 427, avg 6µs/call
sub Moose::Meta::Class::CORE:match; # opcode
# spent 484µs within Moose::Meta::Class::CORE:sort which was called 116 times, avg 4µs/call: # 116 times (484µs+0s) by Moose::Meta::Class::_anon_cache_key at line 127, avg 4µs/call
sub Moose::Meta::Class::CORE:sort; # opcode
# spent 17.8ms within Moose::Meta::Class::CORE:subst which was called 1872 times, avg 9µs/call: # 1872 times (17.8ms+0s) by Moose::Meta::Class::_base_metaclasses at line 356, avg 9µs/call
sub Moose::Meta::Class::CORE:subst; # opcode