← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:10:51 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Util/MetaRole.pm
StatementsExecuted 1542 statements in 25.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
84317.70ms109msMoose::Util::MetaRole::::_make_new_classMoose::Util::MetaRole::_make_new_class
42115.94ms641msMoose::Util::MetaRole::::apply_metarolesMoose::Util::MetaRole::apply_metaroles
42114.30ms274msMoose::Util::MetaRole::::apply_base_class_rolesMoose::Util::MetaRole::apply_base_class_roles
42113.78ms630msMoose::Util::MetaRole::::_make_new_metaclassMoose::Util::MetaRole::_make_new_metaclass
4211560µs560µsMoose::Util::MetaRole::::_fixup_old_style_argsMoose::Util::MetaRole::_fixup_old_style_args
11171µs89µsMoose::Util::MetaRole::::BEGIN@3Moose::Util::MetaRole::BEGIN@3
11163µs210µsMoose::Util::MetaRole::::BEGIN@5Moose::Util::MetaRole::BEGIN@5
11151µs314µsMoose::Util::MetaRole::::BEGIN@12Moose::Util::MetaRole::BEGIN@12
11150µs201µsMoose::Util::MetaRole::::BEGIN@11Moose::Util::MetaRole::BEGIN@11
11138µs68µsMoose::Util::MetaRole::::BEGIN@13Moose::Util::MetaRole::BEGIN@13
11137µs104µsMoose::Util::MetaRole::::BEGIN@4Moose::Util::MetaRole::BEGIN@4
0000s0sMoose::Util::MetaRole::::__ANON__[:116]Moose::Util::MetaRole::__ANON__[:116]
0000s0sMoose::Util::MetaRole::::__ANON__[:160]Moose::Util::MetaRole::__ANON__[:160]
0000s0sMoose::Util::MetaRole::::apply_metaclass_rolesMoose::Util::MetaRole::apply_metaclass_roles
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Util::MetaRole;
2
3398µs2106µs
# spent 89µs (71+18) within Moose::Util::MetaRole::BEGIN@3 which was called: # once (71µs+18µs) by Moose::Exporter::BEGIN@13 at line 3
use strict;
# spent 89µs making 1 call to Moose::Util::MetaRole::BEGIN@3 # spent 18µs making 1 call to strict::import
43112µs2171µs
# spent 104µs (37+67) within Moose::Util::MetaRole::BEGIN@4 which was called: # once (37µs+67µs) by Moose::Exporter::BEGIN@13 at line 4
use warnings;
# spent 104µs making 1 call to Moose::Util::MetaRole::BEGIN@4 # spent 67µs making 1 call to warnings::import
53219µs2357µs
# spent 210µs (63+147) within Moose::Util::MetaRole::BEGIN@5 which was called: # once (63µs+147µs) by Moose::Exporter::BEGIN@13 at line 5
use Scalar::Util 'blessed';
# spent 210µs making 1 call to Moose::Util::MetaRole::BEGIN@5 # spent 147µs making 1 call to Exporter::import
6
714µsour $VERSION = '1.19';
8162µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
913µsour $AUTHORITY = 'cpan:STEVAN';
10
113127µs2351µs
# spent 201µs (50+150) within Moose::Util::MetaRole::BEGIN@11 which was called: # once (50µs+150µs) by Moose::Exporter::BEGIN@13 at line 11
use List::MoreUtils qw( all );
# spent 201µs making 1 call to Moose::Util::MetaRole::BEGIN@11 # spent 150µs making 1 call to Exporter::import
123110µs2578µs
# spent 314µs (51+263) within Moose::Util::MetaRole::BEGIN@12 which was called: # once (51µs+263µs) by Moose::Exporter::BEGIN@13 at line 12
use List::Util qw( first );
# spent 314µs making 1 call to Moose::Util::MetaRole::BEGIN@12 # spent 264µs making 1 call to Exporter::import
1332.48ms298µs
# spent 68µs (38+30) within Moose::Util::MetaRole::BEGIN@13 which was called: # once (38µs+30µs) by Moose::Exporter::BEGIN@13 at line 13
use Moose::Deprecated;
14
15sub apply_metaclass_roles {
16 Moose::Deprecated::deprecated(
17 feature => 'pre-0.94 MetaRole API',
18 message =>
19 'The old Moose::Util::MetaRole API (before version 0.94) has been deprecated'
20 );
21
22 goto &apply_metaroles;
23}
24
25
# spent 641ms (5.94+636) within Moose::Util::MetaRole::apply_metaroles which was called 42 times, avg 15.3ms/call: # 42 times (5.94ms+636ms) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:643] at line 627 of Moose/Exporter.pm, avg 15.3ms/call
sub apply_metaroles {
261683.11ms my %args = @_;
27
2842560µs _fixup_old_style_args(\%args);
# spent 560µs making 42 calls to Moose::Util::MetaRole::_fixup_old_style_args, avg 13µs/call
29
30841.34ms my $for
# spent 1.13ms making 42 calls to Class::MOP::class_of, avg 27µs/call # spent 209µs making 42 calls to Scalar::Util::blessed, avg 5µs/call
31 = blessed $args{for}
32 ? $args{for}
33 : Class::MOP::class_of( $args{for} );
34
35421.17ms42609µs if ( $for->isa('Moose::Meta::Role') ) {
# spent 609µs making 42 calls to UNIVERSAL::isa, avg 15µs/call
36 return _make_new_metaclass( $for, $args{role_metaroles}, 'role' );
37 }
38 else {
3942630ms return _make_new_metaclass( $for, $args{class_metaroles}, 'class' );
# spent 630ms making 42 calls to Moose::Util::MetaRole::_make_new_metaclass, avg 15.0ms/call
40 }
41}
42
43
# spent 560µs within Moose::Util::MetaRole::_fixup_old_style_args which was called 42 times, avg 13µs/call: # 42 times (560µs+0s) by Moose::Util::MetaRole::apply_metaroles at line 28, avg 13µs/call
sub _fixup_old_style_args {
4484769µs my $args = shift;
45
46 return if $args->{class_metaroles} || $args->{role_metaroles};
47
48 Moose::Deprecated::deprecated(
49 feature => 'pre-0.94 MetaRole API',
50 message =>
51 'The old Moose::Util::MetaRole API (before version 0.94) has been deprecated'
52 );
53
54 $args->{for} = delete $args->{for_class}
55 if exists $args->{for_class};
56
57 my @old_keys = qw(
58 attribute_metaclass_roles
59 method_metaclass_roles
60 wrapped_method_metaclass_roles
61 instance_metaclass_roles
62 constructor_class_roles
63 destructor_class_roles
64 error_class_roles
65
66 application_to_class_class_roles
67 application_to_role_class_roles
68 application_to_instance_class_roles
69 application_role_summation_class_roles
70 );
71
72 my $for
73 = blessed $args->{for}
74 ? $args->{for}
75 : Class::MOP::class_of( $args->{for} );
76
77 my $top_key;
78 if ( $for->isa('Moose::Meta::Class') ) {
79 $top_key = 'class_metaroles';
80
81 $args->{class_metaroles}{class} = delete $args->{metaclass_roles}
82 if exists $args->{metaclass_roles};
83 }
84 else {
85 $top_key = 'role_metaroles';
86
87 $args->{role_metaroles}{role} = delete $args->{metaclass_roles}
88 if exists $args->{metaclass_roles};
89 }
90
91 for my $old_key (@old_keys) {
92 my ($new_key) = $old_key =~ /^(.+)_(?:class|metaclass)_roles$/;
93
94 $args->{$top_key}{$new_key} = delete $args->{$old_key}
95 if exists $args->{$old_key};
96 }
97
98 return;
99}
100
101
# spent 630ms (3.78+627) within Moose::Util::MetaRole::_make_new_metaclass which was called 42 times, avg 15.0ms/call: # 42 times (3.78ms+627ms) by Moose::Util::MetaRole::apply_metaroles at line 39, avg 15.0ms/call
sub _make_new_metaclass {
1023783.03ms my $for = shift;
103 my $roles = shift;
104 my $primary = shift;
105
106 return $for unless keys %{$roles};
107
1084228.2ms my $new_metaclass
# spent 28.1ms making 38 calls to Moose::Util::MetaRole::_make_new_class, avg 740µs/call # spent 24µs making 4 calls to Scalar::Util::blessed, avg 6µs/call
109 = exists $roles->{$primary}
110 ? _make_new_class( ref $for, $roles->{$primary} )
111 : blessed $for;
112
113 my %classes;
114
115 for my $key ( grep { $_ ne $primary } keys %{$roles} ) {
1164100µs my $attr = first {$_}
11720576µs207.05ms map { $for->meta->find_attribute_by_name($_) } (
# spent 6.35ms making 8 calls to Class::MOP::Class::find_attribute_by_name, avg 794µs/call # spent 639µs making 8 calls to Class::MOP::Object::meta, avg 80µs/call # spent 61µs making 4 calls to List::Util::first, avg 15µs/call
118 $key . '_metaclass',
119 $key . '_class'
120 );
121
1224175µs my $reader = $attr->get_read_method;
# spent 175µs making 4 calls to Class::MOP::Attribute::get_read_method, avg 44µs/call
123
1241221.7ms $classes{ $attr->init_arg }
# spent 21.6ms making 4 calls to Moose::Util::MetaRole::_make_new_class, avg 5.40ms/call # spent 27µs making 4 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 7µs/call # spent 25µs making 4 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call
125 = _make_new_class( $for->$reader(), $roles->{$key} );
126 }
127
12842569ms my $new_meta = $new_metaclass->reinitialize( $for, %classes );
# spent 569ms making 42 calls to Moose::Meta::Class::reinitialize, avg 13.6ms/call
129
130 return $new_meta;
131}
132
133
# spent 274ms (4.30+269) within Moose::Util::MetaRole::apply_base_class_roles which was called 42 times, avg 6.52ms/call: # 42 times (4.30ms+269ms) by Moose::Exporter::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Exporter.pm:643] at line 636 of Moose/Exporter.pm, avg 6.52ms/call
sub apply_base_class_roles {
1342104.04ms my %args = @_;
135
136 my $for = $args{for} || $args{for_class};
137
138421.21ms my $meta = Class::MOP::class_of($for);
# spent 1.21ms making 42 calls to Class::MOP::class_of, avg 29µs/call
139
1408468.5ms my $new_base = _make_new_class(
# spent 59.5ms making 42 calls to Moose::Util::MetaRole::_make_new_class, avg 1.42ms/call # spent 8.97ms making 42 calls to Moose::Meta::Class::superclasses, avg 214µs/call
141 $for,
142 $args{roles},
143 [ $meta->superclasses() ],
144 );
145
14680200ms $meta->superclasses($new_base)
# spent 200ms making 38 calls to Moose::Meta::Class::superclasses, avg 5.25ms/call # spent 220µs making 42 calls to Class::MOP::Package::name, avg 5µs/call
147 if $new_base ne $meta->name();
148}
149
150
# spent 109ms (7.70+102) within Moose::Util::MetaRole::_make_new_class which was called 84 times, avg 1.30ms/call: # 42 times (4.24ms+55.3ms) by Moose::Util::MetaRole::apply_base_class_roles at line 140, avg 1.42ms/call # 38 times (3.12ms+25.0ms) by Moose::Util::MetaRole::_make_new_metaclass at line 108, avg 740µs/call # 4 times (336µs+21.3ms) by Moose::Util::MetaRole::_make_new_metaclass at line 124, avg 5.40ms/call
sub _make_new_class {
1515768.53ms my $existing_class = shift;
152 my $roles = shift;
153 my $superclasses = shift || [$existing_class];
154
155 return $existing_class unless $roles;
156
157803.73ms my $meta = Class::MOP::Class->initialize($existing_class);
# spent 3.73ms making 80 calls to Class::MOP::Class::initialize, avg 47µs/call
158
159 return $existing_class
160381.16ms3831.6ms if $meta->can('does_role') && all { $meta->does_role($_) }
# spent 31.6ms making 38 calls to Moose::Meta::Class::does_role, avg 832µs/call
16111833.3ms grep { !ref $_ } @{$roles};
# spent 32.7ms making 38 calls to List::MoreUtils::all, avg 861µs/call # spent 606µs making 80 calls to UNIVERSAL::can, avg 8µs/call
162
16316064.5ms return Moose::Meta::Class->create_anon_class(
# spent 63.9ms making 80 calls to Moose::Meta::Class::create_anon_class, avg 799µs/call # spent 600µs making 80 calls to Class::MOP::Package::name, avg 8µs/call
164 superclasses => $superclasses,
165 roles => $roles,
166 cache => 1,
167 )->name();
168}
169
170111µs1;
171
172__END__