← Index
NYTProf Performance Profile   « line view »
For fastest.pl
  Run on Fri Jan 31 20:48:16 2014
Reported on Fri Jan 31 20:49:41 2014

Filename/opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Moose/Meta/Role/Composite.pm
StatementsExecuted 19 statements in 1.03ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs12µsMoose::Meta::Role::Composite::::BEGIN@2Moose::Meta::Role::Composite::BEGIN@2
11110µs38µsMoose::Meta::Role::Composite::::BEGIN@14Moose::Meta::Role::Composite::BEGIN@14
1119µs43µsMoose::Meta::Role::Composite::::BEGIN@13Moose::Meta::Role::Composite::BEGIN@13
1119µs14µsMoose::Meta::Role::Composite::::BEGIN@10Moose::Meta::Role::Composite::BEGIN@10
1119µs81µsMoose::Meta::Role::Composite::::BEGIN@16Moose::Meta::Role::Composite::BEGIN@16
1118µs490µsMoose::Meta::Role::Composite::::BEGIN@11Moose::Meta::Role::Composite::BEGIN@11
1118µs24µsMoose::Meta::Role::Composite::::BEGIN@9Moose::Meta::Role::Composite::BEGIN@9
0000s0sMoose::Meta::Role::Composite::::__ANON__[:36]Moose::Meta::Role::Composite::__ANON__[:36]
0000s0sMoose::Meta::Role::Composite::::_get_local_methodsMoose::Meta::Role::Composite::_get_local_methods
0000s0sMoose::Meta::Role::Composite::::add_methodMoose::Meta::Role::Composite::add_method
0000s0sMoose::Meta::Role::Composite::::apply_paramsMoose::Meta::Role::Composite::apply_params
0000s0sMoose::Meta::Role::Composite::::get_methodMoose::Meta::Role::Composite::get_method
0000s0sMoose::Meta::Role::Composite::::get_method_listMoose::Meta::Role::Composite::get_method_list
0000s0sMoose::Meta::Role::Composite::::has_methodMoose::Meta::Role::Composite::has_method
0000s0sMoose::Meta::Role::Composite::::newMoose::Meta::Role::Composite::new
0000s0sMoose::Meta::Role::Composite::::reinitializeMoose::Meta::Role::Composite::reinitialize
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::Role::Composite;
2
# spent 12µs within Moose::Meta::Role::Composite::BEGIN@2 which was called: # once (12µs+0s) by Moose::BEGIN@36 at line 4
BEGIN {
316µs $Moose::Meta::Role::Composite::AUTHORITY = 'cpan:STEVAN';
4144µs112µs}
# spent 12µs making 1 call to Moose::Meta::Role::Composite::BEGIN@2
5{
621µs $Moose::Meta::Role::Composite::VERSION = '2.1005';
7}
8
9231µs240µs
# spent 24µs (8+16) within Moose::Meta::Role::Composite::BEGIN@9 which was called: # once (8µs+16µs) by Moose::BEGIN@36 at line 9
use strict;
# spent 24µs making 1 call to Moose::Meta::Role::Composite::BEGIN@9 # spent 16µs making 1 call to strict::import
10228µs220µs
# spent 14µs (9+5) within Moose::Meta::Role::Composite::BEGIN@10 which was called: # once (9µs+5µs) by Moose::BEGIN@36 at line 10
use warnings;
# spent 14µs making 1 call to Moose::Meta::Role::Composite::BEGIN@10 # spent 5µs making 1 call to warnings::import
11246µs2971µs
# spent 490µs (8+481) within Moose::Meta::Role::Composite::BEGIN@11 which was called: # once (8µs+481µs) by Moose::BEGIN@36 at line 11
use metaclass;
# spent 490µs making 1 call to Moose::Meta::Role::Composite::BEGIN@11 # spent 481µs making 1 call to metaclass::import
12
13239µs276µs
# spent 43µs (9+33) within Moose::Meta::Role::Composite::BEGIN@13 which was called: # once (9µs+33µs) by Moose::BEGIN@36 at line 13
use Class::Load qw(load_class);
# spent 43µs making 1 call to Moose::Meta::Role::Composite::BEGIN@13 # spent 33µs making 1 call to Exporter::import
14235µs266µs
# spent 38µs (10+28) within Moose::Meta::Role::Composite::BEGIN@14 which was called: # once (10µs+28µs) by Moose::BEGIN@36 at line 14
use Scalar::Util 'blessed';
# spent 38µs making 1 call to Moose::Meta::Role::Composite::BEGIN@14 # spent 28µs making 1 call to Exporter::import
15
162778µs2153µs
# spent 81µs (9+72) within Moose::Meta::Role::Composite::BEGIN@16 which was called: # once (9µs+72µs) by Moose::BEGIN@36 at line 16
use base 'Moose::Meta::Role';
# spent 81µs making 1 call to Moose::Meta::Role::Composite::BEGIN@16 # spent 72µs making 1 call to base::import
17
18# NOTE:
19# we need to override the ->name
20# method from Class::MOP::Package
21# since we don't have an actual
22# package for this.
23# - SL
2415µs3422µs__PACKAGE__->meta->add_attribute('name' => (
# spent 390µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 26µs making 1 call to Moose::Meta::Role::Composite::meta # spent 7µs making 1 call to Class::MOP::_definition_context
25 reader => 'name',
26 Class::MOP::_definition_context(),
27));
28
29# NOTE:
30# Again, since we don't have a real
31# package to store our methods in,
32# we use a HASH ref instead.
33# - SL
34__PACKAGE__->meta->add_attribute('_methods' => (
35 reader => '_method_map',
36 default => sub { {} },
3716µs3410µs Class::MOP::_definition_context(),
# spent 391µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 12µs making 1 call to Moose::Meta::Role::Composite::meta # spent 7µs making 1 call to Class::MOP::_definition_context
38));
39
4014µs3409µs__PACKAGE__->meta->add_attribute(
# spent 386µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Moose::Meta::Role::Composite::meta # spent 7µs making 1 call to Class::MOP::_definition_context
41 'application_role_summation_class',
42 reader => 'application_role_summation_class',
43 default => 'Moose::Meta::Role::Application::RoleSummation',
44 Class::MOP::_definition_context(),
45);
46
47sub new {
48 my ($class, %params) = @_;
49
50 # the roles param is required ...
51 foreach ( @{$params{roles}} ) {
52 unless ( $_->isa('Moose::Meta::Role') ) {
53 require Moose;
54 Moose->throw_error("The list of roles must be instances of Moose::Meta::Role, not $_");
55 }
56 }
57
58 my @composition_roles = map {
59 $_->composition_class_roles
60 } @{ $params{roles} };
61
62 if (@composition_roles) {
63 my $meta = Moose::Meta::Class->create_anon_class(
64 superclasses => [ $class ],
65 roles => [ @composition_roles ],
66 cache => 1,
67 );
68 $class = $meta->name;
69 }
70
71 # and the name is created from the
72 # roles if one has not been provided
73 $params{name} ||= (join "|" => map { $_->name } @{$params{roles}});
74 $class->_new(\%params);
75}
76
77# This is largely a copy of what's in Moose::Meta::Role (itself
78# largely a copy of Class::MOP::Class). However, we can't actually
79# call add_package_symbol, because there's no package into which to
80# add the symbol.
81sub add_method {
82 my ($self, $method_name, $method) = @_;
83
84 unless ( defined $method_name && $method_name ) {
85 Moose->throw_error("You must define a method name");
86 }
87
88 my $body;
89 if (blessed($method)) {
90 $body = $method->body;
91 if ($method->package_name ne $self->name) {
92 $method = $method->clone(
93 package_name => $self->name,
94 name => $method_name
95 ) if $method->can('clone');
96 }
97 }
98 else {
99 $body = $method;
100 $method = $self->wrap_method_body( body => $body, name => $method_name );
101 }
102
103 $self->_method_map->{$method_name} = $method;
104}
105
106sub get_method_list {
107 my $self = shift;
108 return keys %{ $self->_method_map };
109}
110
111sub _get_local_methods {
112 my $self = shift;
113 return values %{ $self->_method_map };
114}
115
116sub has_method {
117 my ($self, $method_name) = @_;
118
119 return exists $self->_method_map->{$method_name};
120}
121
122sub get_method {
123 my ($self, $method_name) = @_;
124
125 return $self->_method_map->{$method_name};
126}
127
128sub apply_params {
129 my ($self, $role_params) = @_;
130 load_class($self->application_role_summation_class);
131
132 $self->application_role_summation_class->new(
133 role_params => $role_params,
134 )->apply($self);
135
136 return $self;
137}
138
139sub reinitialize {
140 my ( $class, $old_meta, @args ) = @_;
141
142 Moose->throw_error(
143 'Moose::Meta::Role::Composite instances can only be reinitialized from an existing metaclass instance'
144 )
145 if !blessed $old_meta
146 || !$old_meta->isa('Moose::Meta::Role::Composite');
147
148 my %existing_classes = map { $_ => $old_meta->$_() } qw(
149 application_role_summation_class
150 );
151
152 return $old_meta->meta->clone_object( $old_meta, %existing_classes, @args );
153}
154
155110µs1;
156
157# ABSTRACT: An object to represent the set of roles
158
159__END__