← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:07 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/Role/Composite.pm
StatementsExecuted 19 statements in 762µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11110µs10µsMoose::Meta::Role::Composite::::BEGIN@2Moose::Meta::Role::Composite::BEGIN@2
11110µs12µsMoose::Meta::Role::Composite::::BEGIN@9Moose::Meta::Role::Composite::BEGIN@9
1117µs33µsMoose::Meta::Role::Composite::::BEGIN@13Moose::Meta::Role::Composite::BEGIN@13
1117µs12µsMoose::Meta::Role::Composite::::BEGIN@10Moose::Meta::Role::Composite::BEGIN@10
1117µs54µsMoose::Meta::Role::Composite::::BEGIN@16Moose::Meta::Role::Composite::BEGIN@16
1117µs473µsMoose::Meta::Role::Composite::::BEGIN@11Moose::Meta::Role::Composite::BEGIN@11
1117µs30µsMoose::Meta::Role::Composite::::BEGIN@14Moose::Meta::Role::Composite::BEGIN@14
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 10µs within Moose::Meta::Role::Composite::BEGIN@2 which was called: # once (10µs+0s) by Moose::BEGIN@36 at line 4
BEGIN {
315µs $Moose::Meta::Role::Composite::AUTHORITY = 'cpan:STEVAN';
4133µs110µs}
# spent 10µs making 1 call to Moose::Meta::Role::Composite::BEGIN@2
5{
621µs $Moose::Meta::Role::Composite::VERSION = '2.1005';
7}
8
9224µs216µs
# spent 12µs (10+3) within Moose::Meta::Role::Composite::BEGIN@9 which was called: # once (10µs+3µs) by Moose::BEGIN@36 at line 9
use strict;
# spent 12µs making 1 call to Moose::Meta::Role::Composite::BEGIN@9 # spent 3µs making 1 call to strict::import
10221µs218µs
# spent 12µs (7+5) within Moose::Meta::Role::Composite::BEGIN@10 which was called: # once (7µs+5µs) by Moose::BEGIN@36 at line 10
use warnings;
# spent 12µs making 1 call to Moose::Meta::Role::Composite::BEGIN@10 # spent 5µs making 1 call to warnings::import
11231µs2940µs
# spent 473µs (7+467) within Moose::Meta::Role::Composite::BEGIN@11 which was called: # once (7µs+467µs) by Moose::BEGIN@36 at line 11
use metaclass;
# spent 473µs making 1 call to Moose::Meta::Role::Composite::BEGIN@11 # spent 467µs making 1 call to metaclass::import
12
13226µs258µs
# spent 33µs (7+25) within Moose::Meta::Role::Composite::BEGIN@13 which was called: # once (7µs+25µs) by Moose::BEGIN@36 at line 13
use Class::Load qw(load_class);
# spent 33µs making 1 call to Moose::Meta::Role::Composite::BEGIN@13 # spent 25µs making 1 call to Exporter::import
14224µs253µs
# spent 30µs (7+23) within Moose::Meta::Role::Composite::BEGIN@14 which was called: # once (7µs+23µs) by Moose::BEGIN@36 at line 14
use Scalar::Util 'blessed';
# spent 30µs making 1 call to Moose::Meta::Role::Composite::BEGIN@14 # spent 23µs making 1 call to Exporter::import
15
162576µs2102µs
# spent 54µs (7+47) within Moose::Meta::Role::Composite::BEGIN@16 which was called: # once (7µs+47µs) by Moose::BEGIN@36 at line 16
use base 'Moose::Meta::Role';
# spent 54µs making 1 call to Moose::Meta::Role::Composite::BEGIN@16 # spent 47µ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
2414µs3346µs__PACKAGE__->meta->add_attribute('name' => (
# spent 321µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 19µs making 1 call to Moose::Meta::Role::Composite::meta # spent 6µ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µs3334µs Class::MOP::_definition_context(),
# spent 317µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 12µs making 1 call to Moose::Meta::Role::Composite::meta # spent 5µs making 1 call to Class::MOP::_definition_context
38));
39
4013µs3322µs__PACKAGE__->meta->add_attribute(
# spent 305µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::Role::Composite::meta # spent 6µ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
15518µs1;
156
157# ABSTRACT: An object to represent the set of roles
158
159__END__