← 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:10:53 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Util/MetaRole.pm
StatementsExecuted 1770 statements in 31.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
421110.0ms761msMoose::Util::MetaRole::::_make_new_metaclassMoose::Util::MetaRole::_make_new_metaclass
84217.69ms123msMoose::Util::MetaRole::::_make_new_classMoose::Util::MetaRole::_make_new_class
42115.14ms772msMoose::Util::MetaRole::::apply_metarolesMoose::Util::MetaRole::apply_metaroles
42114.28ms297msMoose::Util::MetaRole::::apply_base_class_rolesMoose::Util::MetaRole::apply_base_class_roles
4211567µs567µsMoose::Util::MetaRole::::_fixup_old_style_argsMoose::Util::MetaRole::_fixup_old_style_args
11166µs82µsMoose::Util::MetaRole::::BEGIN@3Moose::Util::MetaRole::BEGIN@3
11150µs335µsMoose::Util::MetaRole::::BEGIN@12Moose::Util::MetaRole::BEGIN@12
11141µs256µsMoose::Util::MetaRole::::BEGIN@11Moose::Util::MetaRole::BEGIN@11
11139µs70µsMoose::Util::MetaRole::::BEGIN@13Moose::Util::MetaRole::BEGIN@13
11137µs104µsMoose::Util::MetaRole::::BEGIN@4Moose::Util::MetaRole::BEGIN@4
11136µs198µsMoose::Util::MetaRole::::BEGIN@5Moose::Util::MetaRole::BEGIN@5
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µs299µs
# spent 82µs (66+17) within Moose::Util::MetaRole::BEGIN@3 which was called: # once (66µs+17µs) by Moose::Exporter::BEGIN@13 at line 3
use strict;
# spent 82µs making 1 call to Moose::Util::MetaRole::BEGIN@3 # spent 17µs making 1 call to strict::import
4398µs2170µ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 66µs making 1 call to warnings::import
53234µs2359µs
# spent 198µs (36+162) within Moose::Util::MetaRole::BEGIN@5 which was called: # once (36µs+162µs) by Moose::Exporter::BEGIN@13 at line 5
use Scalar::Util 'blessed';
# spent 198µs making 1 call to Moose::Util::MetaRole::BEGIN@5 # spent 162µs making 1 call to Exporter::import
6
714µsour $VERSION = '1.19';
8164µs$VERSION = eval $VERSION;
# spent 13µs executing statements in string eval
914µsour $AUTHORITY = 'cpan:STEVAN';
10
113117µs2470µs
# spent 256µs (41+215) within Moose::Util::MetaRole::BEGIN@11 which was called: # once (41µs+215µs) by Moose::Exporter::BEGIN@13 at line 11
use List::MoreUtils qw( all );
# spent 256µs making 1 call to Moose::Util::MetaRole::BEGIN@11 # spent 214µs making 1 call to Exporter::import
123114µs2620µs
# spent 335µs (50+285) within Moose::Util::MetaRole::BEGIN@12 which was called: # once (50µs+285µs) by Moose::Exporter::BEGIN@13 at line 12
use List::Util qw( first );
# spent 335µs making 1 call to Moose::Util::MetaRole::BEGIN@12 # spent 285µs making 1 call to Exporter::import
1332.49ms2100µs
# spent 70µs (39+31) within Moose::Util::MetaRole::BEGIN@13 which was called: # once (39µs+31µ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 772ms (5.14+767) within Moose::Util::MetaRole::apply_metaroles which was called 42 times, avg 18.4ms/call: # 42 times (5.14ms+767ms) by Moose::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Exporter.pm:643] at line 627 of Moose/Exporter.pm, avg 18.4ms/call
sub apply_metaroles {
261683.13ms my %args = @_;
27
2842567µs _fixup_old_style_args(\%args);
# spent 567µs making 42 calls to Moose::Util::MetaRole::_fixup_old_style_args, avg 13µs/call
29
30841.29ms my $for
# spent 1.07ms making 42 calls to Class::MOP::class_of, avg 26µs/call # spent 215µ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.22ms42613µs if ( $for->isa('Moose::Meta::Role') ) {
# spent 613µs making 42 calls to UNIVERSAL::isa, avg 15µs/call
36 return _make_new_metaclass( $for, $args{role_metaroles}, 'role' );
37 }
38 else {
3942761ms return _make_new_metaclass( $for, $args{class_metaroles}, 'class' );
# spent 761ms making 42 calls to Moose::Util::MetaRole::_make_new_metaclass, avg 18.1ms/call
40 }
41}
42
43
# spent 567µs within Moose::Util::MetaRole::_fixup_old_style_args which was called 42 times, avg 13µs/call: # 42 times (567µs+0s) by Moose::Util::MetaRole::apply_metaroles at line 28, avg 13µs/call
sub _fixup_old_style_args {
4484759µ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 761ms (10.0+751) within Moose::Util::MetaRole::_make_new_metaclass which was called 42 times, avg 18.1ms/call: # 42 times (10.0ms+751ms) by Moose::Util::MetaRole::apply_metaroles at line 39, avg 18.1ms/call
sub _make_new_metaclass {
1023783.18ms my $for = shift;
103 my $roles = shift;
104 my $primary = shift;
105
106 return $for unless keys %{$roles};
107
10842242µs my $new_metaclass
# spent 242µs making 42 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} ) {
11642995µs my $attr = first {$_}
1172105.71ms21060.4ms map { $for->meta->find_attribute_by_name($_) } (
# spent 52.5ms making 84 calls to Class::MOP::Class::find_attribute_by_name, avg 625µs/call # spent 7.23ms making 84 calls to Class::MOP::Object::meta, avg 86µs/call # spent 608µs making 42 calls to List::Util::first, avg 14µs/call
118 $key . '_metaclass',
119 $key . '_class'
120 );
121
122422.86ms my $reader = $attr->get_read_method;
# spent 2.86ms making 42 calls to Class::MOP::Attribute::get_read_method, avg 68µs/call
123
12412660.2ms $classes{ $attr->init_arg }
# spent 59.1ms making 42 calls to Moose::Util::MetaRole::_make_new_class, avg 1.41ms/call # spent 586µs making 38 calls to Moose::Meta::Class::constructor_class, avg 15µs/call # spent 551µs making 42 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 13µs/call # spent 48µs making 4 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 12µs/call
125 = _make_new_class( $for->$reader(), $roles->{$key} );
126 }
127
12842628ms my $new_meta = $new_metaclass->reinitialize( $for, %classes );
# spent 628ms making 42 calls to Moose::Meta::Class::reinitialize, avg 14.9ms/call
129
130 return $new_meta;
131}
132
133
# spent 297ms (4.28+292) within Moose::Util::MetaRole::apply_base_class_roles which was called 42 times, avg 7.07ms/call: # 42 times (4.28ms+292ms) by Moose::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Exporter.pm:643] at line 636 of Moose/Exporter.pm, avg 7.07ms/call
sub apply_base_class_roles {
1342103.95ms my %args = @_;
135
136 my $for = $args{for} || $args{for_class};
137
138421.13ms my $meta = Class::MOP::class_of($for);
# spent 1.13ms making 42 calls to Class::MOP::class_of, avg 27µs/call
139
1408475.7ms my $new_base = _make_new_class(
# spent 63.9ms making 42 calls to Moose::Util::MetaRole::_make_new_class, avg 1.52ms/call # spent 11.7ms making 42 calls to Moose::Meta::Class::superclasses, avg 279µs/call
141 $for,
142 $args{roles},
143 [ $meta->superclasses() ],
144 );
145
14680216ms $meta->superclasses($new_base)
# spent 215ms making 38 calls to Moose::Meta::Class::superclasses, avg 5.67ms/call # spent 223µs making 42 calls to Class::MOP::Package::name, avg 5µs/call
147 if $new_base ne $meta->name();
148}
149
150
# spent 123ms (7.69+115) within Moose::Util::MetaRole::_make_new_class which was called 84 times, avg 1.46ms/call: # 42 times (4.04ms+59.9ms) by Moose::Util::MetaRole::apply_base_class_roles at line 140, avg 1.52ms/call # 42 times (3.65ms+55.4ms) by Moose::Util::MetaRole::_make_new_metaclass at line 124, avg 1.41ms/call
sub _make_new_class {
1515768.39ms my $existing_class = shift;
152 my $roles = shift;
153 my $superclasses = shift || [$existing_class];
154
155 return $existing_class unless $roles;
156
157803.64ms my $meta = Class::MOP::Class->initialize($existing_class);
# spent 3.64ms making 80 calls to Class::MOP::Class::initialize, avg 45µs/call
158
159 return $existing_class
160381.16ms3835.2ms if $meta->can('does_role') && all { $meta->does_role($_) }
# spent 35.2ms making 38 calls to Moose::Meta::Class::does_role, avg 926µs/call
16111836.9ms grep { !ref $_ } @{$roles};
# spent 36.3ms making 38 calls to List::MoreUtils::all, avg 954µs/call # spent 650µs making 80 calls to UNIVERSAL::can, avg 8µs/call
162
16316074.7ms return Moose::Meta::Class->create_anon_class(
# spent 74.1ms making 80 calls to Moose::Meta::Class::create_anon_class, avg 927µs/call # spent 616µ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__