← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:15 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Composite.pm
StatementsExecuted 519 statements in 4.56ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
59113.77ms4.69msMoose::Meta::Role::Composite::::add_methodMoose::Meta::Role::Composite::add_method
31180µs322µsMoose::Meta::Role::Composite::::newMoose::Meta::Role::Composite::new
31155µs12.4msMoose::Meta::Role::Composite::::apply_paramsMoose::Meta::Role::Composite::apply_params
122231µs40µsMoose::Meta::Role::Composite::::has_methodMoose::Meta::Role::Composite::has_method
32218µs22µsMoose::Meta::Role::Composite::::_get_local_methodsMoose::Meta::Role::Composite::_get_local_methods
1118µs8µsMoose::Meta::Role::Composite::::BEGIN@2Moose::Meta::Role::Composite::BEGIN@2
1116µs27µsMoose::Meta::Role::Composite::::BEGIN@13Moose::Meta::Role::Composite::BEGIN@13
1116µs24µsMoose::Meta::Role::Composite::::BEGIN@14Moose::Meta::Role::Composite::BEGIN@14
1116µs9µsMoose::Meta::Role::Composite::::BEGIN@10Moose::Meta::Role::Composite::BEGIN@10
1116µs57µsMoose::Meta::Role::Composite::::BEGIN@16Moose::Meta::Role::Composite::BEGIN@16
1115µs327µsMoose::Meta::Role::Composite::::BEGIN@11Moose::Meta::Role::Composite::BEGIN@11
1115µs16µsMoose::Meta::Role::Composite::::BEGIN@9Moose::Meta::Role::Composite::BEGIN@9
3115µs5µsMoose::Meta::Role::Composite::::__ANON__[:36]Moose::Meta::Role::Composite::__ANON__[:36]
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::::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 8µs within Moose::Meta::Role::Composite::BEGIN@2 which was called: # once (8µs+0s) by Moose::BEGIN@36 at line 4
BEGIN {
314µs $Moose::Meta::Role::Composite::AUTHORITY = 'cpan:STEVAN';
4128µs18µs}
# spent 8µs making 1 call to Moose::Meta::Role::Composite::BEGIN@2
5{
62800ns $Moose::Meta::Role::Composite::VERSION = '2.1005';
7}
8
9220µs226µs
# spent 16µs (5+10) within Moose::Meta::Role::Composite::BEGIN@9 which was called: # once (5µs+10µs) by Moose::BEGIN@36 at line 9
use strict;
# spent 16µs making 1 call to Moose::Meta::Role::Composite::BEGIN@9 # spent 10µs making 1 call to strict::import
10218µs212µs
# spent 9µs (6+3) within Moose::Meta::Role::Composite::BEGIN@10 which was called: # once (6µs+3µs) by Moose::BEGIN@36 at line 10
use warnings;
# spent 9µs making 1 call to Moose::Meta::Role::Composite::BEGIN@10 # spent 3µs making 1 call to warnings::import
11226µs2649µs
# spent 327µs (5+322) within Moose::Meta::Role::Composite::BEGIN@11 which was called: # once (5µs+322µs) by Moose::BEGIN@36 at line 11
use metaclass;
# spent 327µs making 1 call to Moose::Meta::Role::Composite::BEGIN@11 # spent 322µs making 1 call to metaclass::import
12
13222µs247µs
# spent 27µs (6+21) within Moose::Meta::Role::Composite::BEGIN@13 which was called: # once (6µs+21µs) by Moose::BEGIN@36 at line 13
use Class::Load qw(load_class);
# spent 27µs making 1 call to Moose::Meta::Role::Composite::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14222µs241µs
# spent 24µs (6+18) within Moose::Meta::Role::Composite::BEGIN@14 which was called: # once (6µs+18µs) by Moose::BEGIN@36 at line 14
use Scalar::Util 'blessed';
# spent 24µs making 1 call to Moose::Meta::Role::Composite::BEGIN@14 # spent 18µs making 1 call to Exporter::import
15
162537µs2109µs
# spent 57µs (6+52) within Moose::Meta::Role::Composite::BEGIN@16 which was called: # once (6µs+52µs) by Moose::BEGIN@36 at line 16
use base 'Moose::Meta::Role';
# spent 57µs making 1 call to Moose::Meta::Role::Composite::BEGIN@16 # spent 52µ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
2413µs3286µs__PACKAGE__->meta->add_attribute('name' => (
# spent 266µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Moose::Meta::Role::Composite::meta # spent 5µ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',
3638µs
# spent 5µs within Moose::Meta::Role::Composite::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Composite.pm:36] which was called 3 times, avg 2µs/call: # 3 times (5µs+0s) by Moose::Meta::Role::Composite::_new at line 15 of (eval 74)[Eval/Closure.pm:135], avg 2µs/call
default => sub { {} },
3714µs3271µs Class::MOP::_definition_context(),
# spent 258µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µs making 1 call to Moose::Meta::Role::Composite::meta # spent 5µs making 1 call to Class::MOP::_definition_context
38));
39
4013µs3268µs__PACKAGE__->meta->add_attribute(
# spent 255µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::Role::Composite::meta # spent 4µ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
47
# spent 322µs (80+242) within Moose::Meta::Role::Composite::new which was called 3 times, avg 107µs/call: # 3 times (80µs+242µs) by Moose::Meta::Role::combine at line 495 of Moose/Meta/Role.pm, avg 107µs/call
sub new {
4833µs my ($class, %params) = @_;
49
50 # the roles param is required ...
5133µs foreach ( @{$params{roles}} ) {
52818µs84µs unless ( $_->isa('Moose::Meta::Role') ) {
# spent 4µs making 8 calls to UNIVERSAL::isa, avg 488ns/call
53 require Moose;
54 Moose->throw_error("The list of roles must be instances of Moose::Meta::Role, not $_");
55 }
56 }
57
5887µs85µs my @composition_roles = map {
# spent 5µs making 8 calls to Moose::Meta::Role::composition_class_roles, avg 662ns/call
59 $_->composition_class_roles
6035µs } @{ $params{roles} };
61
623700ns 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
731125µs84µs $params{name} ||= (join "|" => map { $_->name } @{$params{roles}});
# spent 4µs making 8 calls to Class::MOP::Package::name, avg 538ns/call
74311µs3229µs $class->_new(\%params);
# spent 229µs making 3 calls to Moose::Meta::Role::Composite::_new, avg 76µs/call
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.
81
# spent 4.69ms (3.77+917µs) within Moose::Meta::Role::Composite::add_method which was called 59 times, avg 80µs/call: # 59 times (3.77ms+917µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 205 of Moose/Meta/Role/Application/RoleSummation.pm, avg 80µs/call
sub add_method {
825913µs my ($self, $method_name, $method) = @_;
83
84596µs unless ( defined $method_name && $method_name ) {
85 Moose->throw_error("You must define a method name");
86 }
87
8859300ns my $body;
89593.14ms5925µs if (blessed($method)) {
# spent 25µs making 59 calls to Scalar::Util::blessed, avg 427ns/call
9059102µs5925µs $body = $method->body;
# spent 25µs making 59 calls to Class::MOP::Method::body, avg 422ns/call
9159302µs295805µs if ($method->package_name ne $self->name) {
# spent 627µs making 59 calls to Class::MOP::Method::clone, avg 11µs/call # spent 125µs making 118 calls to Moose::Meta::Role::Composite::name, avg 1µs/call # spent 32µs making 59 calls to UNIVERSAL::can, avg 537ns/call # spent 22µs making 59 calls to Class::MOP::Method::package_name, avg 376ns/call
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
10359133µs5961µs $self->_method_map->{$method_name} = $method;
# spent 61µs making 59 calls to Moose::Meta::Role::Composite::_method_map, avg 1µs/call
104}
105
106sub get_method_list {
107 my $self = shift;
108 return keys %{ $self->_method_map };
109}
110
111
# spent 22µs (18+4) within Moose::Meta::Role::Composite::_get_local_methods which was called 3 times, avg 7µs/call: # 2 times (11µs+2µs) by Moose::Meta::Role::Application::ToRole::apply_methods at line 82 of Moose/Meta/Role/Application/ToRole.pm, avg 6µs/call # once (7µs+2µs) by Moose::Meta::Role::Application::ToClass::apply_methods at line 162 of Moose/Meta/Role/Application/ToClass.pm
sub _get_local_methods {
1123800ns my $self = shift;
113316µs34µs return values %{ $self->_method_map };
# spent 4µs making 3 calls to Moose::Meta::Role::Composite::_method_map, avg 1µs/call
114}
115
116
# spent 40µs (31+9) within Moose::Meta::Role::Composite::has_method which was called 12 times, avg 3µs/call: # 6 times (18µs+5µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 223 of Moose/Meta/Role/Application/RoleSummation.pm, avg 4µs/call # 6 times (13µs+4µs) by Moose::Meta::Role::add_override_method_modifier at line 366 of Moose/Meta/Role.pm, avg 3µs/call
sub has_method {
117122µs my ($self, $method_name) = @_;
118
1191225µs129µs return exists $self->_method_map->{$method_name};
# spent 9µs making 12 calls to Moose::Meta::Role::Composite::_method_map, avg 758ns/call
120}
121
122sub get_method {
123 my ($self, $method_name) = @_;
124
125 return $self->_method_map->{$method_name};
126}
127
128
# spent 12.4ms (55µs+12.3) within Moose::Meta::Role::Composite::apply_params which was called 3 times, avg 4.13ms/call: # 3 times (55µs+12.3ms) by Moose::Meta::Role::combine at line 496 of Moose/Meta/Role.pm, avg 4.13ms/call
sub apply_params {
12931µs my ($self, $role_params) = @_;
13037µs629µs load_class($self->application_role_summation_class);
# spent 64µs making 3 calls to Class::Load::load_class, avg 21µs/call, recursion: max depth 2, sum of overlapping time 42µs # spent 7µs making 3 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 2µs/call
131
132321µs94.19ms $self->application_role_summation_class->new(
# spent 12.2ms making 3 calls to Moose::Meta::Role::Application::apply, avg 4.05ms/call, recursion: max depth 1, sum of overlapping time 8.06ms # spent 81µs making 3 calls to Moose::Meta::Role::Application::new, avg 27µs/call # spent 4µs making 3 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 1µs/call
133 role_params => $role_params,
134 )->apply($self);
135
13636µs 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
15516µs1;
156
157# ABSTRACT: An object to represent the set of roles
158
159__END__