← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Moo/Role.pm
StatementsExecuted 10034 statements in 19.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
40043234.3ms55.5msMoo::Role::::does_roleMoo::Role::does_role
1111.85ms1.92msMoo::Role::::BEGIN@5Moo::Role::BEGIN@5
221713µs876µsMoo::Role::::beforeMoo::Role::before
121212588µs11.8msMoo::Role::::importMoo::Role::import
51517446µs4.82msMoo::Role::::hasMoo::Role::has
9631376µs649µsMoo::Role::::_inhale_if_mooseMoo::Role::_inhale_if_moose
1721288µs1.34msMoo::Role::::_handle_constructorMoo::Role::_handle_constructor
7241176µs768µsMoo::Role::::_install_trackedMoo::Role::_install_tracked
6852172µs670µsMoo::Role::::is_roleMoo::Role::is_role
1422160µs68.6msMoo::Role::::apply_roles_to_packageMoo::Role::apply_roles_to_package (recurses: max depth 1, inclusive time 14.0ms)
6741145µs198µsMoo::Role::::_maybe_reset_handlemooseMoo::Role::_maybe_reset_handlemoose
111195µs2.94msMoo::Role::::apply_single_role_to_packageMoo::Role::apply_single_role_to_package
171164µs539µsMoo::Role::::_install_doesMoo::Role::_install_does
172159µs76µsMoo::Role::::_maybe_make_accessorsMoo::Role::_maybe_make_accessors
99853µs118µsMoo::Role::::requiresMoo::Role::requires
121148µs9.92msMoo::Role::::__ANON__[:100]Moo::Role::__ANON__[:100]
142136µs54µsMoo::Role::::role_application_stepsMoo::Role::role_application_steps
44420µs14.0msMoo::Role::::withMoo::Role::with
31110µs530µsMoo::Role::::_install_single_modifierMoo::Role::_install_single_modifier
1119µs20µsMoo::Role::::BEGIN@3Moo::Role::BEGIN@3
1115µs58µsMoo::Role::::BEGIN@4Moo::Role::BEGIN@4
1115µs6µsMoo::Role::::aroundMoo::Role::around
1114µs4µsMoo::Role::::BEGIN@14Moo::Role::BEGIN@14
0000s0sMoo::Role::::__ANON__[:183]Moo::Role::__ANON__[:183]
0000s0sMoo::Role::::__ANON__[:189]Moo::Role::__ANON__[:189]
0000s0sMoo::Role::::__ANON__[:202]Moo::Role::__ANON__[:202]
0000s0sMoo::Role::::__ANON__[:347]Moo::Role::__ANON__[:347]
0000s0sMoo::Role::::__ANON__[:62]Moo::Role::__ANON__[:62]
0000s0sMoo::Role::::__ANON__[:69]Moo::Role::__ANON__[:69]
0000s0sMoo::Role::::__ANON__[:74]Moo::Role::__ANON__[:74]
0000s0sMoo::Role::::__ANON__[:78]Moo::Role::__ANON__[:78]
0000s0sMoo::Role::::_composable_package_forMoo::Role::_composable_package_for
0000s0sMoo::Role::::_make_accessorsMoo::Role::_make_accessors
0000s0sMoo::Role::::_make_accessors_if_mooseMoo::Role::_make_accessors_if_moose
0000s0sMoo::Role::::afterMoo::Role::after
0000s0sMoo::Role::::apply_roles_to_objectMoo::Role::apply_roles_to_object
0000s0sMoo::Role::::create_class_with_rolesMoo::Role::create_class_with_roles
0000s0sMoo::Role::::metaMoo::Role::meta
0000s0sMoo::Role::::methods_provided_byMoo::Role::methods_provided_by
0000s0sMoo::Role::::unimportMoo::Role::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moo::Role;
2
3215µs232µs
# spent 20µs (9+11) within Moo::Role::BEGIN@3 which was called: # once (9µs+11µs) by CHI::BEGIN@8 at line 3
use Moo::_strictures;
# spent 20µs making 1 call to Moo::Role::BEGIN@3 # spent 11µs making 1 call to Moo::_strictures::import
4215µs2110µs
# spent 58µs (5+53) within Moo::Role::BEGIN@4 which was called: # once (5µs+53µs) by CHI::BEGIN@8 at line 4
use Moo::_Utils;
# spent 58µs making 1 call to Moo::Role::BEGIN@4 # spent 53µs making 1 call to Exporter::import
52121µs11.92ms
# spent 1.92ms (1.85+71µs) within Moo::Role::BEGIN@5 which was called: # once (1.85ms+71µs) by CHI::BEGIN@8 at line 5
use Role::Tiny ();
# spent 1.92ms making 1 call to Moo::Role::BEGIN@5
615µsour @ISA = qw(Role::Tiny);
7
81200nsour $VERSION = '2.000002';
919µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
10
111500nsrequire Moo::sification;
1214µs12µsMoo::sification->import;
# spent 2µs making 1 call to Moo::sification::import
13
14
# spent 4µs within Moo::Role::BEGIN@14 which was called: # once (4µs+0s) by CHI::BEGIN@8 at line 18
BEGIN {
1511µs *INFO = \%Role::Tiny::INFO;
161300ns *APPLIED_TO = \%Role::Tiny::APPLIED_TO;
1713µs *ON_ROLE_CREATE = \@Role::Tiny::ON_ROLE_CREATE;
1811.38ms14µs}
# spent 4µs making 1 call to Moo::Role::BEGIN@14
19
20our %INFO;
21our %APPLIED_TO;
22our %APPLY_DEFAULTS;
23our @ON_ROLE_CREATE;
24
25
# spent 768µs (176+592) within Moo::Role::_install_tracked which was called 72 times, avg 11µs/call: # 36 times (69µs+263µs) by Moo::Role::import at line 69, avg 9µs/call # 12 times (62µs+154µs) by Moo::Role::import at line 62, avg 18µs/call # 12 times (22µs+91µs) by Moo::Role::import at line 74, avg 9µs/call # 12 times (23µs+85µs) by Moo::Role::import at line 78, avg 9µs/call
sub _install_tracked {
267218µs my ($target, $name, $code) = @_;
277236µs $INFO{$target}{exports}{$name} = $code;
2872122µs72592µs _install_coderef "${target}::${name}" => "Moo::Role::${name}" => $code;
# spent 592µs making 72 calls to Moo::_Utils::_install_coderef, avg 8µs/call
29}
30
31
# spent 11.8ms (588µs+11.2) within Moo::Role::import which was called 12 times, avg 983µs/call: # once (36µs+5.34ms) by Search::Elasticsearch::Role::API::BEGIN@3 at line 3 of Search/Elasticsearch/Role/API.pm # once (55µs+714µs) by Search::Elasticsearch::Role::Transport::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Transport.pm # once (63µs+630µs) by Search::Elasticsearch::Role::CxnPool::Static::BEGIN@3 at line 3 of Search/Elasticsearch/Role/CxnPool/Static.pm # once (62µs+609µs) by Search::Elasticsearch::Role::CxnPool::BEGIN@3 at line 3 of Search/Elasticsearch/Role/CxnPool.pm # once (72µs+589µs) by Search::Elasticsearch::Role::Serializer::JSON::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Serializer/JSON.pm # once (58µs+598µs) by Search::Elasticsearch::Role::Cxn::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Cxn.pm # once (51µs+545µs) by Search::Elasticsearch::Role::Is_Sync::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Is_Sync.pm # once (45µs+453µs) by Search::Elasticsearch::Client::5_0::Role::API::BEGIN@3 at line 3 of Search/Elasticsearch/Client/5_0/Role/API.pm # once (34µs+454µs) by Search::Elasticsearch::Role::Client::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Client.pm # once (38µs+434µs) by Search::Elasticsearch::Role::Client::Direct::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Client/Direct.pm # once (40µs+429µs) by Search::Elasticsearch::Role::Logger::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Logger.pm # once (34µs+410µs) by Search::Elasticsearch::Role::Serializer::BEGIN@3 at line 3 of Search/Elasticsearch/Role/Serializer.pm
sub import {
321210µs my $target = caller;
33124µs my ($me) = @_;
34
351222µs12175µs _set_loaded(caller);
# spent 175µs making 12 calls to Moo::_Utils::_set_loaded, avg 15µs/call
361214µs1219µs strict->import;
# spent 19µs making 12 calls to strict::import, avg 2µs/call
371213µs1247µs warnings->import;
# spent 47µs making 12 calls to warnings::import, avg 4µs/call
38126µs if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) {
39 die "Cannot import Moo::Role into a Moo class";
40 }
411213µs $INFO{$target} ||= {};
42 # get symbol table reference
431217µs1221µs my $stash = _getstash($target);
# spent 21µs making 12 calls to Moo::_Utils::_getstash, avg 2µs/call
44
# spent 4.82ms (446µs+4.37) within Moo::Role::has which was called 51 times, avg 94µs/call: # once (7µs+677µs) by Module::Runtime::require_module at line 23 of Search/Elasticsearch/Role/Logger.pm # once (73µs+427µs) by Module::Runtime::require_module at line 11 of Search/Elasticsearch/Role/Transport.pm # once (6µs+366µs) by Module::Runtime::require_module at line 18 of Search/Elasticsearch/Role/Logger.pm # once (6µs+207µs) by Module::Runtime::require_module at line 40 of Search/Elasticsearch/Role/Cxn.pm # once (28µs+121µs) by Module::Runtime::require_module at line 12 of Search/Elasticsearch/Role/Transport.pm # once (18µs+109µs) by Module::Runtime::require_module at line 13 of Search/Elasticsearch/Role/CxnPool.pm # once (19µs+103µs) by Module::Runtime::require_module at line 17 of Search/Elasticsearch/Role/Cxn.pm # once (7µs+110µs) by Module::Runtime::require_module at line 35 of Search/Elasticsearch/Role/Logger.pm # once (16µs+99µs) by Module::Runtime::require_module at line 11 of Search/Elasticsearch/Role/Serializer/JSON.pm # once (5µs+94µs) by Module::Runtime::require_module at line 17 of Search/Elasticsearch/Role/CxnPool.pm # once (15µs+83µs) by Module::Runtime::require_module at line 9 of Search/Elasticsearch/Client/5_0/Role/API.pm # once (5µs+93µs) by Module::Runtime::require_module at line 16 of Search/Elasticsearch/Role/CxnPool.pm # once (25µs+70µs) by Module::Runtime::require_module at line 24 of Search/Elasticsearch/Role/Cxn.pm # once (13µs+78µs) by Module::Runtime::require_module at line 10 of Search/Elasticsearch/Role/Logger.pm # once (11µs+80µs) by Module::Runtime::require_module at line 8 of Search/Elasticsearch/Role/Client.pm # once (7µs+80µs) by Module::Runtime::require_module at line 13 of Search/Elasticsearch/Role/Transport.pm # once (5µs+79µs) by Module::Runtime::require_module at line 39 of Search/Elasticsearch/Role/Cxn.pm # once (12µs+57µs) by Module::Runtime::require_module at line 41 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+64µs) by Module::Runtime::require_module at line 19 of Search/Elasticsearch/Role/CxnPool.pm # once (5µs+55µs) by Module::Runtime::require_module at line 30 of Search/Elasticsearch/Role/Cxn.pm # once (9µs+49µs) by Module::Runtime::require_module at line 14 of Search/Elasticsearch/Role/CxnPool.pm # once (5µs+52µs) by Module::Runtime::require_module at line 26 of Search/Elasticsearch/Role/Cxn.pm # once (6µs+46µs) by Module::Runtime::require_module at line 18 of Search/Elasticsearch/Role/Cxn.pm # once (6µs+46µs) by Module::Runtime::require_module at line 11 of Search/Elasticsearch/Role/Logger.pm # once (5µs+47µs) by Module::Runtime::require_module at line 31 of Search/Elasticsearch/Role/Cxn.pm # once (6µs+46µs) by Module::Runtime::require_module at line 18 of Search/Elasticsearch/Role/CxnPool.pm # once (6µs+45µs) by Module::Runtime::require_module at line 9 of Search/Elasticsearch/Role/Client.pm # once (6µs+45µs) by Module::Runtime::require_module at line 14 of Search/Elasticsearch/Role/Transport.pm # once (5µs+46µs) by Module::Runtime::require_module at line 29 of Search/Elasticsearch/Role/Cxn.pm # once (6µs+44µs) by Module::Runtime::require_module at line 15 of Search/Elasticsearch/Role/CxnPool.pm # once (4µs+44µs) by Module::Runtime::require_module at line 25 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+43µs) by Module::Runtime::require_module at line 20 of Search/Elasticsearch/Role/CxnPool.pm # once (4µs+42µs) by Module::Runtime::require_module at line 32 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+42µs) by Module::Runtime::require_module at line 21 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+42µs) by Module::Runtime::require_module at line 19 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+41µs) by Module::Runtime::require_module at line 12 of Search/Elasticsearch/Role/Logger.pm # once (5µs+42µs) by Module::Runtime::require_module at line 22 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+41µs) by Module::Runtime::require_module at line 20 of Search/Elasticsearch/Role/Cxn.pm # once (4µs+41µs) by Module::Runtime::require_module at line 36 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+40µs) by Module::Runtime::require_module at line 33 of Search/Elasticsearch/Role/Cxn.pm # once (4µs+41µs) by Module::Runtime::require_module at line 35 of Search/Elasticsearch/Role/Cxn.pm # once (4µs+41µs) by Module::Runtime::require_module at line 27 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+40µs) by Module::Runtime::require_module at line 13 of Search/Elasticsearch/Role/Logger.pm # once (5µs+39µs) by Module::Runtime::require_module at line 15 of Search/Elasticsearch/Role/Logger.pm # once (4µs+40µs) by Module::Runtime::require_module at line 37 of Search/Elasticsearch/Role/Cxn.pm # once (4µs+40µs) by Module::Runtime::require_module at line 14 of Search/Elasticsearch/Role/Logger.pm # once (5µs+40µs) by Module::Runtime::require_module at line 34 of Search/Elasticsearch/Role/Cxn.pm # once (4µs+40µs) by Module::Runtime::require_module at line 23 of Search/Elasticsearch/Role/Cxn.pm # once (4µs+40µs) by Module::Runtime::require_module at line 28 of Search/Elasticsearch/Role/Cxn.pm # once (4µs+40µs) by Module::Runtime::require_module at line 38 of Search/Elasticsearch/Role/Cxn.pm # once (5µs+38µs) by Module::Runtime::require_module at line 16 of Search/Elasticsearch/Role/Logger.pm
_install_tracked $target => has => sub {
45519µs my $name_proto = shift;
465128µs my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto;
475133µs if (@_ % 2 != 0) {
48 require Carp;
49 Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto)
50 . " attribute(s): even number of arguments expected, got " . scalar @_)
51 }
525138µs my %spec = @_;
5351104µs foreach my $name (@name_proto) {
545121µs my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec;
555187µs514.16ms ($INFO{$target}{accessor_maker} ||= do {
# spent 4.16ms making 51 calls to Method::Generate::Accessor::generate_method, avg 82µs/call
56710µs require Method::Generate::Accessor;
57731µs792µs Method::Generate::Accessor->new
# spent 92µs making 7 calls to Moo::Object::new, avg 13µs/call
58 })->generate_method($target, $name, $spec_ref);
595148µs push @{$INFO{$target}{attributes}||=[]}, $name, $spec_ref;
605148µs51115µs $me->_maybe_reset_handlemoose($target);
# spent 115µs making 51 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call
61 }
621259µs12216µs };
# spent 216µs making 12 calls to Moo::Role::_install_tracked, avg 18µs/call
63 # install before/after/around subs
64129µs foreach my $type (qw(before after around)) {
65
# spent 6µs (5+2) within Moo::Role::around which was called: # once (5µs+2µs) by Module::Runtime::require_module at line 33 of Search/Elasticsearch/Role/CxnPool.pm # spent 876µs (713+163) within Moo::Role::before which was called 2 times, avg 438µs/call: # once (711µs+161µs) by Module::Runtime::require_module at line 134 of Search/Elasticsearch/Role/Cxn.pm # once (2µs+2µs) by Module::Runtime::require_module at line 243 of Search/Elasticsearch/Role/Cxn.pm
_install_tracked $target => $type => sub {
66348µs require Class::Method::Modifiers;
6735µs push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ];
6838µs38µs $me->_maybe_reset_handlemoose($target);
# spent 8µs making 3 calls to Moo::Role::_maybe_reset_handlemoose, avg 3µs/call
693655µs36332µs };
# spent 332µs making 36 calls to Moo::Role::_install_tracked, avg 9µs/call
70 }
71
# spent 118µs (53+65) within Moo::Role::requires which was called 9 times, avg 13µs/call: # once (20µs+28µs) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Role/Transport.pm # once (8µs+7µs) by Module::Runtime::require_module at line 15 of Search/Elasticsearch/Role/Cxn.pm # once (6µs+9µs) by Module::Runtime::require_module at line 11 of Search/Elasticsearch/Role/CxnPool.pm # once (5µs+5µs) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Role/Serializer/JSON.pm # once (4µs+5µs) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Role/API.pm # once (3µs+4µs) by Module::Runtime::require_module at line 6 of Search/Elasticsearch/Role/Client.pm # once (3µs+3µs) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Role/Serializer.pm # once (2µs+2µs) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Role/CxnPool/Static.pm # once (2µs+2µs) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Role/API.pm
_install_tracked $target => requires => sub {
72919µs push @{$INFO{$target}{requires}||=[]}, @_;
73944µs965µs $me->_maybe_reset_handlemoose($target);
# spent 65µs making 9 calls to Moo::Role::_maybe_reset_handlemoose, avg 7µs/call
741222µs12113µs };
# spent 113µs making 12 calls to Moo::Role::_install_tracked, avg 9µs/call
75
# spent 14.0ms (20µs+14.0) within Moo::Role::with which was called 4 times, avg 3.51ms/call: # once (5µs+6.35ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Client/5_0/Role/API.pm # once (6µs+5.60ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Role/CxnPool/Static.pm # once (3µs+1.24ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Role/Client/Direct.pm # once (6µs+814µs) by Module::Runtime::require_module at line 13 of Search/Elasticsearch/Role/Serializer/JSON.pm
_install_tracked $target => with => sub {
76410µs40s $me->apply_roles_to_package($target, @_);
# spent 14.0ms making 4 calls to Moo::Role::apply_roles_to_package, avg 3.50ms/call, recursion: max depth 1, sum of overlapping time 14.0ms
77410µs410µs $me->_maybe_reset_handlemoose($target);
# spent 10µs making 4 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call
781224µs12107µs };
# spent 107µs making 12 calls to Moo::Role::_install_tracked, avg 9µs/call
791216µs12229µs return if $me->is_role($target); # already exported into this package
# spent 229µs making 12 calls to Moo::Role::is_role, avg 19µs/call
80127µs $INFO{$target}{is_role} = 1;
811243µs2428µs *{_getglob("${target}::meta")} = $me->can('meta');
# spent 19µs making 12 calls to Moo::_Utils::_getglob, avg 2µs/call # spent 9µs making 12 calls to UNIVERSAL::can, avg 775ns/call
82 # grab all *non-constant* (stash slot is not a scalarref) subs present
83 # in the symbol table and store their refaddrs (no need to forcibly
84 # inflate constant subs into real subs) - also add '' to here (this
85 # is used later) with a map to the coderefs in case of copying or re-use
861252µs my @not_methods = ('', map { *$_{CODE}||() } grep !ref($_), values %$stash);
871267µs @{$INFO{$target}{not_methods}={}}{@not_methods} = @not_methods;
88 # a role does itself
891211µs $APPLIED_TO{$target} = { $target => undef };
90
91 $_->($target)
921272µs129.92ms for @ON_ROLE_CREATE;
# spent 9.92ms making 12 calls to Moo::Role::__ANON__[Moo/Role.pm:100], avg 826µs/call
93}
94
95
# spent 9.92ms (48µs+9.87) within Moo::Role::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Moo/Role.pm:100] which was called 12 times, avg 826µs/call: # 12 times (48µs+9.87ms) by Moo::Role::import at line 92, avg 826µs/call
push @ON_ROLE_CREATE, sub {
96124µs my $target = shift;
971235µs129.87ms if ($INC{'Moo/HandleMoose.pm'}) {
# spent 9.87ms making 12 calls to Moo::HandleMoose::inject_fake_metaclass_for, avg 823µs/call
98 Moo::HandleMoose::inject_fake_metaclass_for($target);
99 }
10011µs};
101
102# duplicate from Moo::Object
103sub meta {
104 require Moo::HandleMoose::FakeMetaClass;
105 my $class = ref($_[0])||$_[0];
106 bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass');
107}
108
109sub unimport {
110 my $target = caller;
111 _unimport_coderefs($target, $INFO{$target});
112}
113
114
# spent 198µs (145+53) within Moo::Role::_maybe_reset_handlemoose which was called 67 times, avg 3µs/call: # 51 times (85µs+29µs) by Moo::Role::has at line 60, avg 2µs/call # 9 times (46µs+19µs) by Moo::Role::requires at line 73, avg 7µs/call # 4 times (7µs+3µs) by Moo::Role::with at line 77, avg 2µs/call # 3 times (7µs+2µs) by Moo::Role::around or Moo::Role::before at line 68, avg 3µs/call
sub _maybe_reset_handlemoose {
1156717µs my ($class, $target) = @_;
11667118µs6753µs if ($INC{"Moo/HandleMoose.pm"}) {
# spent 53µs making 67 calls to Moo::HandleMoose::maybe_reinject_fake_metaclass_for, avg 785ns/call
117 Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target);
118 }
119}
120
121sub methods_provided_by {
122 my ($self, $role) = @_;
123 _load_module($role);
124 $self->_inhale_if_moose($role);
125 die "${role} is not a Moo::Role" unless $self->is_role($role);
126 return $self->SUPER::methods_provided_by($role);
127}
128
129
# spent 670µs (172+498) within Moo::Role::is_role which was called 68 times, avg 10µs/call: # 17 times (38µs+155µs) by Role::Tiny::_install_does at line 418 of Role/Tiny.pm, avg 11µs/call # 17 times (48µs+66µs) by Moo::Role::apply_roles_to_package at line 261, avg 7µs/call # 12 times (42µs+187µs) by Moo::Role::import at line 79, avg 19µs/call # 11 times (22µs+50µs) by Role::Tiny::apply_single_role_to_package at line 89 of Role/Tiny.pm, avg 7µs/call # 11 times (22µs+40µs) by Moo::Role::apply_single_role_to_package at line 270, avg 6µs/call
sub is_role {
1306812µs my ($self, $role) = @_;
1316841µs68453µs $self->_inhale_if_moose($role);
# spent 453µs making 68 calls to Moo::Role::_inhale_if_moose, avg 7µs/call
13268102µs6846µs $self->SUPER::is_role($role);
# spent 46µs making 68 calls to Role::Tiny::is_role, avg 669ns/call
133}
134
135
# spent 649µs (376+273) within Moo::Role::_inhale_if_moose which was called 96 times, avg 7µs/call: # 68 times (241µs+212µs) by Moo::Role::is_role at line 131, avg 7µs/call # 17 times (81µs+46µs) by Moo::Role::apply_roles_to_package at line 260, avg 7µs/call # 11 times (54µs+15µs) by Moo::Role::apply_single_role_to_package at line 269, avg 6µs/call
sub _inhale_if_moose {
1369627µs my ($self, $role) = @_;
1379610µs my $meta;
13896375µs217273µs if (!$self->SUPER::is_role($role)
# spent 106µs making 25 calls to Class::MOP::class_of, avg 4µs/call # spent 106µs making 96 calls to Role::Tiny::is_role, avg 1µs/call # spent 61µs making 96 calls to UNIVERSAL::can, avg 636ns/call
139 and (
140 $INC{"Moose.pm"}
141 and $meta = Class::MOP::class_of($role)
142 and ref $meta ne 'Moo::HandleMoose::FakeMetaClass'
143 and $meta->isa('Moose::Meta::Role')
144 )
145 or (
146 Mouse::Util->can('find_meta')
147 and $meta = Mouse::Util::find_meta($role)
148 and $meta->isa('Mouse::Meta::Role')
149 )
150 ) {
151 my $is_mouse = $meta->isa('Mouse::Meta::Role');
152 $INFO{$role}{methods} = {
153 map +($_ => $role->can($_)),
154 grep $role->can($_),
155 grep !($is_mouse && $_ eq 'meta'),
156 grep !$meta->get_method($_)->isa('Class::MOP::Method::Meta'),
157 $meta->get_method_list
158 };
159 $APPLIED_TO{$role} = {
160 map +($_->name => 1), $meta->calculate_all_roles
161 };
162 $INFO{$role}{requires} = [ $meta->get_required_method_list ];
163 $INFO{$role}{attributes} = [
164 map +($_ => do {
165 my $attr = $meta->get_attribute($_);
166 my $spec = { %{ $is_mouse ? $attr : $attr->original_options } };
167
168 if ($spec->{isa}) {
169
170 my $get_constraint = do {
171 my $pkg = $is_mouse
172 ? 'Mouse::Util::TypeConstraints'
173 : 'Moose::Util::TypeConstraints';
174 _load_module($pkg);
175 $pkg->can('find_or_create_isa_type_constraint');
176 };
177
178 my $tc = $get_constraint->($spec->{isa});
179 my $check = $tc->_compiled_type_constraint;
180
181 $spec->{isa} = sub {
182 &$check or die "Type constraint failed for $_[0]"
183 };
184
185 if ($spec->{coerce}) {
186
187 # Mouse has _compiled_type_coercion straight on the TC object
188 $spec->{coerce} = $tc->${\(
189 $tc->can('coercion')||sub { $_[0] }
190 )}->_compiled_type_coercion;
191 }
192 }
193 $spec;
194 }), $meta->get_attribute_list
195 ];
196 my $mods = $INFO{$role}{modifiers} = [];
197 foreach my $type (qw(before after around)) {
198 # Mouse pokes its own internals so we have to fall back to doing
199 # the same thing in the absence of the Moose API method
200 my $map = $meta->${\(
201 $meta->can("get_${type}_method_modifiers_map")
202 or sub { shift->{"${type}_method_modifiers"} }
203 )};
204 foreach my $method (keys %$map) {
205 foreach my $mod (@{$map->{$method}}) {
206 push @$mods, [ $type => $method => $mod ];
207 }
208 }
209 }
210 require Class::Method::Modifiers if @$mods;
211 $INFO{$role}{inhaled_from_moose} = 1;
212 $INFO{$role}{is_role} = 1;
213 }
214}
215
216
# spent 76µs (59+17) within Moo::Role::_maybe_make_accessors which was called 17 times, avg 4µs/call: # 11 times (42µs+13µs) by Role::Tiny::apply_single_role_to_package at line 92 of Role/Tiny.pm, avg 5µs/call # 6 times (18µs+4µs) by Role::Tiny::apply_roles_to_package at line 252 of Role/Tiny.pm, avg 4µs/call
sub _maybe_make_accessors {
217174µs my ($self, $target, $role) = @_;
218173µs my $m;
2191753µs1717µs if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}
# spent 17µs making 17 calls to Moo::_accessor_maker_for, avg 982ns/call
220 or $INC{"Moo.pm"}
221 and $m = Moo->_accessor_maker_for($target)
222 and ref($m) ne 'Method::Generate::Accessor') {
223 $self->_make_accessors($target, $role);
224 }
225}
226
227sub _make_accessors_if_moose {
228 my ($self, $target, $role) = @_;
229 if ($INFO{$role} && $INFO{$role}{inhaled_from_moose}) {
230 $self->_make_accessors($target, $role);
231 }
232}
233
234sub _make_accessors {
235 my ($self, $target, $role) = @_;
236 my $acc_gen = ($Moo::MAKERS{$target}{accessor} ||= do {
237 require Method::Generate::Accessor;
238 Method::Generate::Accessor->new
239 });
240 my $con_gen = $Moo::MAKERS{$target}{constructor};
241 my @attrs = @{$INFO{$role}{attributes}||[]};
242 while (my ($name, $spec) = splice @attrs, 0, 2) {
243 # needed to ensure we got an index for an arrayref based generator
244 if ($con_gen) {
245 $spec = $con_gen->all_attribute_specs->{$name};
246 }
247 $acc_gen->generate_method($target, $name, $spec);
248 }
249}
250
251
# spent 54µs (36+18) within Moo::Role::role_application_steps which was called 14 times, avg 4µs/call: # 11 times (27µs+14µs) by Role::Tiny::apply_single_role_to_package at line 91 of Role/Tiny.pm, avg 4µs/call # 3 times (8µs+3µs) by Role::Tiny::apply_roles_to_package at line 250 of Role/Tiny.pm, avg 4µs/call
sub role_application_steps {
2521439µs1418µs qw(_handle_constructor _maybe_make_accessors),
# spent 18µs making 14 calls to Role::Tiny::role_application_steps, avg 1µs/call
253 $_[0]->SUPER::role_application_steps;
254}
255
256
# spent 68.6ms (160µs+68.4) within Moo::Role::apply_roles_to_package which was called 14 times, avg 4.90ms/call: # 10 times (116µs+68.4ms) by Moo::with at line 39 of Moo.pm, avg 6.86ms/call # 4 times (44µs+-44µs) by Moo::Role::with at line 76, avg 0s/call
sub apply_roles_to_package {
2571411µs my ($me, $to, @roles) = @_;
258149µs foreach my $role (@roles) {
2591723µs1763.8ms _load_module($role);
# spent 76.8ms making 17 calls to Moo::_Utils::_load_module, avg 4.52ms/call, recursion: max depth 1, sum of overlapping time 13.0ms
2601723µs17127µs $me->_inhale_if_moose($role);
# spent 127µs making 17 calls to Moo::Role::_inhale_if_moose, avg 7µs/call
2611723µs17115µs die "${role} is not a Moo::Role" unless $me->is_role($role);
# spent 115µs making 17 calls to Moo::Role::is_role, avg 7µs/call
262 }
2631442µs145.34ms $me->SUPER::apply_roles_to_package($to, @roles);
# spent 5.34ms making 14 calls to Role::Tiny::apply_roles_to_package, avg 381µs/call
264}
265
266
# spent 2.94ms (95µs+2.84) within Moo::Role::apply_single_role_to_package which was called 11 times, avg 267µs/call: # 11 times (95µs+2.84ms) by Role::Tiny::apply_role_to_package at line 196 of Role/Tiny.pm, avg 267µs/call
sub apply_single_role_to_package {
267113µs my ($me, $to, $role) = @_;
268117µs11244µs _load_module($role);
# spent 394µs making 11 calls to Moo::_Utils::_load_module, avg 36µs/call, recursion: max depth 1, sum of overlapping time 150µs
2691126µs1169µs $me->_inhale_if_moose($role);
# spent 69µs making 11 calls to Moo::Role::_inhale_if_moose, avg 6µs/call
270119µs1162µs die "${role} is not a Moo::Role" unless $me->is_role($role);
# spent 62µs making 11 calls to Moo::Role::is_role, avg 6µs/call
2711124µs112.32ms $me->SUPER::apply_single_role_to_package($to, $role);
# spent 2.32ms making 11 calls to Role::Tiny::apply_single_role_to_package, avg 210µs/call
272}
273
274sub create_class_with_roles {
275 my ($me, $superclass, @roles) = @_;
276
277 my ($new_name, $compose_name) = $me->_composite_name($superclass, @roles);
278
279 return $new_name if $Role::Tiny::COMPOSED{class}{$new_name};
280
281 foreach my $role (@roles) {
282 _load_module($role);
283 $me->_inhale_if_moose($role);
284 }
285
286 my $m;
287 if ($INC{"Moo.pm"}
288 and $m = Moo->_accessor_maker_for($superclass)
289 and ref($m) ne 'Method::Generate::Accessor') {
290 # old fashioned way time.
291 *{_getglob("${new_name}::ISA")} = [ $superclass ];
292 $Moo::MAKERS{$new_name} = {is_class => 1};
293 $me->apply_roles_to_package($new_name, @roles);
294 _set_loaded($new_name, (caller)[1]);
295 return $new_name;
296 }
297
298 $me->SUPER::create_class_with_roles($superclass, @roles);
299
300 foreach my $role (@roles) {
301 die "${role} is not a Moo::Role" unless $me->is_role($role);
302 }
303
304 $Moo::MAKERS{$new_name} = {is_class => 1};
305
306 $me->_handle_constructor($new_name, $_) for @roles;
307
308 _set_loaded($new_name, (caller)[1]);
309 return $new_name;
310}
311
312sub apply_roles_to_object {
313 my ($me, $object, @roles) = @_;
314 my $new = $me->SUPER::apply_roles_to_object($object, @roles);
315 _set_loaded(ref $new, (caller)[1]);
316
317 my $apply_defaults = $APPLY_DEFAULTS{ref $new} ||= do {
318 my %attrs = map { @{$INFO{$_}{attributes}||[]} } @roles;
319
320 if ($INC{'Moo.pm'}
321 and keys %attrs
322 and my $con_gen = Moo->_constructor_maker_for(ref $new)
323 and my $m = Moo->_accessor_maker_for(ref $new)) {
324 require Sub::Quote;
325
326 my $specs = $con_gen->all_attribute_specs;
327
328 my $assign = "{no warnings 'void';\n";
329 my %captures;
330 foreach my $name ( keys %attrs ) {
331 my $spec = $specs->{$name};
332 if ($m->has_eager_default($name, $spec)) {
333 my ($has, $has_cap)
334 = $m->generate_simple_has('$_[0]', $name, $spec);
335 my ($code, $pop_cap)
336 = $m->generate_use_default('$_[0]', $name, $spec, $has);
337
338 $assign .= $code . ";\n";
339 @captures{keys %$has_cap, keys %$pop_cap}
340 = (values %$has_cap, values %$pop_cap);
341 }
342 }
343 $assign .= "}";
344 Sub::Quote::quote_sub($assign, \%captures);
345 }
346 else {
347 sub {};
348 }
349 };
350 $new->$apply_defaults;
351 return $new;
352}
353
354sub _composable_package_for {
355 my ($self, $role) = @_;
356 my $composed_name = 'Role::Tiny::_COMPOSABLE::'.$role;
357 return $composed_name if $Role::Tiny::COMPOSED{role}{$composed_name};
358 $self->_make_accessors_if_moose($composed_name, $role);
359 $self->SUPER::_composable_package_for($role);
360}
361
362
# spent 530µs (10+520) within Moo::Role::_install_single_modifier which was called 3 times, avg 177µs/call: # 3 times (10µs+520µs) by Role::Tiny::_install_modifiers at line 394 of Role/Tiny.pm, avg 177µs/call
sub _install_single_modifier {
36332µs my ($me, @args) = @_;
36438µs3520µs _install_modifier(@args);
# spent 520µs making 3 calls to Moo::_Utils::_install_modifier, avg 174µs/call
365}
366
367
# spent 539µs (64+475) within Moo::Role::_install_does which was called 17 times, avg 32µs/call: # 17 times (64µs+475µs) by Role::Tiny::_install_methods at line 384 of Role/Tiny.pm, avg 32µs/call
sub _install_does {
368174µs my ($me, $to) = @_;
369
370 # If Role::Tiny actually installed the DOES, give it a name
3711735µs17434µs my $new = $me->SUPER::_install_does($to) or return;
# spent 434µs making 17 calls to Role::Tiny::_install_does, avg 26µs/call
372822µs841µs return _name_coderef("${to}::DOES", $new);
# spent 41µs making 8 calls to Moo::_Utils::_name_coderef, avg 5µs/call
373}
374
375
# spent 55.5ms (34.3+21.1) within Moo::Role::does_role which was called 4004 times, avg 14µs/call: # 2002 times (8.78ms+6.71ms) by Search::Elasticsearch::Util::is_compat at line 101 of Search/Elasticsearch/Util.pm, avg 8µs/call # 2001 times (25.6ms+14.4ms) by Search::Elasticsearch::Util::is_compat at line 96 of Search/Elasticsearch/Util.pm, avg 20µs/call # once (3µs+7µs) by Search::Elasticsearch::Util::is_compat at line 70 of Moo/Object.pm
sub does_role {
3764004955µs my ($proto, $role) = @_;
377400414.1ms400421.1ms return 1
# spent 21.1ms making 4004 calls to Role::Tiny::does_role, avg 5µs/call
378 if Role::Tiny::does_role($proto, $role);
379 my $meta;
380 if ($INC{'Moose.pm'}
381 and $meta = Class::MOP::class_of($proto)
382 and ref $meta ne 'Moo::HandleMoose::FakeMetaClass'
383 and $meta->can('does_role')
384 ) {
385 return $meta->does_role($role);
386 }
387 return 0;
388}
389
390
# spent 1.34ms (288µs+1.05) within Moo::Role::_handle_constructor which was called 17 times, avg 79µs/call: # 11 times (186µs+533µs) by Role::Tiny::apply_single_role_to_package at line 92 of Role/Tiny.pm, avg 65µs/call # 6 times (102µs+522µs) by Role::Tiny::apply_roles_to_package at line 252 of Role/Tiny.pm, avg 104µs/call
sub _handle_constructor {
391175µs my ($me, $to, $role) = @_;
3921712µs my $attr_info = $INFO{$role} && $INFO{$role}{attributes};
3931712µs return unless $attr_info && @$attr_info;
394124µs my $info = $INFO{$to};
3951222µs12759µs my $con = $INC{"Moo.pm"} && Moo->_constructor_maker_for($to);
# spent 759µs making 12 calls to Moo::_constructor_maker_for, avg 63µs/call
396 my %existing
397 = $info ? @{$info->{attributes} || []}
3981229µs1010µs : $con ? %{$con->all_attribute_specs || {}}
# spent 10µs making 10 calls to Method::Generate::Constructor::all_attribute_specs, avg 970ns/call
399 : ();
400
401 my @attr_info =
402 map { @{$attr_info}[$_, $_+1] }
403 grep { ! $existing{$attr_info->[$_]} }
4041285µs map { 2 * $_ } 0..@$attr_info/2-1;
405
40612101µs10286µs if ($info) {
# spent 286µs making 10 calls to Method::Generate::Constructor::register_attribute_specs, avg 29µs/call
407 push @{$info->{attributes}||=[]}, @attr_info;
408 }
409 elsif ($con) {
410 # shallow copy of the specs since the constructor will assign an index
411 $con->register_attribute_specs(map ref() ? { %$_ } : $_, @attr_info);
412 }
413}
414
41514µs1;
416__END__