Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Moo/Role.pm |
Statements | Executed 10034 statements in 19.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
4004 | 3 | 2 | 34.3ms | 55.5ms | does_role | Moo::Role::
1 | 1 | 1 | 1.85ms | 1.92ms | BEGIN@5 | Moo::Role::
2 | 2 | 1 | 713µs | 876µs | before | Moo::Role::
12 | 12 | 12 | 588µs | 11.8ms | import | Moo::Role::
51 | 51 | 7 | 446µs | 4.82ms | has | Moo::Role::
96 | 3 | 1 | 376µs | 649µs | _inhale_if_moose | Moo::Role::
17 | 2 | 1 | 288µs | 1.34ms | _handle_constructor | Moo::Role::
72 | 4 | 1 | 176µs | 768µs | _install_tracked | Moo::Role::
68 | 5 | 2 | 172µs | 670µs | is_role | Moo::Role::
14 | 2 | 2 | 160µs | 68.6ms | apply_roles_to_package (recurses: max depth 1, inclusive time 14.0ms) | Moo::Role::
67 | 4 | 1 | 145µs | 198µs | _maybe_reset_handlemoose | Moo::Role::
11 | 1 | 1 | 95µs | 2.94ms | apply_single_role_to_package | Moo::Role::
17 | 1 | 1 | 64µs | 539µs | _install_does | Moo::Role::
17 | 2 | 1 | 59µs | 76µs | _maybe_make_accessors | Moo::Role::
9 | 9 | 8 | 53µs | 118µs | requires | Moo::Role::
12 | 1 | 1 | 48µs | 9.92ms | __ANON__[:100] | Moo::Role::
14 | 2 | 1 | 36µs | 54µs | role_application_steps | Moo::Role::
4 | 4 | 4 | 20µs | 14.0ms | with | Moo::Role::
3 | 1 | 1 | 10µs | 530µs | _install_single_modifier | Moo::Role::
1 | 1 | 1 | 9µs | 20µs | BEGIN@3 | Moo::Role::
1 | 1 | 1 | 5µs | 58µs | BEGIN@4 | Moo::Role::
1 | 1 | 1 | 5µs | 6µs | around | Moo::Role::
1 | 1 | 1 | 4µs | 4µs | BEGIN@14 | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:183] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:189] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:202] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:347] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:62] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:69] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:74] | Moo::Role::
0 | 0 | 0 | 0s | 0s | __ANON__[:78] | Moo::Role::
0 | 0 | 0 | 0s | 0s | _composable_package_for | Moo::Role::
0 | 0 | 0 | 0s | 0s | _make_accessors | Moo::Role::
0 | 0 | 0 | 0s | 0s | _make_accessors_if_moose | Moo::Role::
0 | 0 | 0 | 0s | 0s | after | Moo::Role::
0 | 0 | 0 | 0s | 0s | apply_roles_to_object | Moo::Role::
0 | 0 | 0 | 0s | 0s | create_class_with_roles | Moo::Role::
0 | 0 | 0 | 0s | 0s | meta | Moo::Role::
0 | 0 | 0 | 0s | 0s | methods_provided_by | Moo::Role::
0 | 0 | 0 | 0s | 0s | unimport | Moo::Role::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moo::Role; | ||||
2 | |||||
3 | 2 | 15µs | 2 | 32µ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 # spent 20µs making 1 call to Moo::Role::BEGIN@3
# spent 11µs making 1 call to Moo::_strictures::import |
4 | 2 | 15µs | 2 | 110µ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 # spent 58µs making 1 call to Moo::Role::BEGIN@4
# spent 53µs making 1 call to Exporter::import |
5 | 2 | 121µs | 1 | 1.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 # spent 1.92ms making 1 call to Moo::Role::BEGIN@5 |
6 | 1 | 5µs | our @ISA = qw(Role::Tiny); | ||
7 | |||||
8 | 1 | 200ns | our $VERSION = '2.000002'; | ||
9 | 1 | 9µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
10 | |||||
11 | 1 | 500ns | require Moo::sification; | ||
12 | 1 | 4µs | 1 | 2µs | Moo::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 | ||||
15 | 1 | 1µs | *INFO = \%Role::Tiny::INFO; | ||
16 | 1 | 300ns | *APPLIED_TO = \%Role::Tiny::APPLIED_TO; | ||
17 | 1 | 3µs | *ON_ROLE_CREATE = \@Role::Tiny::ON_ROLE_CREATE; | ||
18 | 1 | 1.38ms | 1 | 4µs | } # spent 4µs making 1 call to Moo::Role::BEGIN@14 |
19 | |||||
20 | our %INFO; | ||||
21 | our %APPLIED_TO; | ||||
22 | our %APPLY_DEFAULTS; | ||||
23 | our @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 | ||||
26 | 72 | 18µs | my ($target, $name, $code) = @_; | ||
27 | 72 | 36µs | $INFO{$target}{exports}{$name} = $code; | ||
28 | 72 | 122µs | 72 | 592µ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 | ||||
32 | 12 | 10µs | my $target = caller; | ||
33 | 12 | 4µs | my ($me) = @_; | ||
34 | |||||
35 | 12 | 22µs | 12 | 175µs | _set_loaded(caller); # spent 175µs making 12 calls to Moo::_Utils::_set_loaded, avg 15µs/call |
36 | 12 | 14µs | 12 | 19µs | strict->import; # spent 19µs making 12 calls to strict::import, avg 2µs/call |
37 | 12 | 13µs | 12 | 47µs | warnings->import; # spent 47µs making 12 calls to warnings::import, avg 4µs/call |
38 | 12 | 6µs | if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) { | ||
39 | die "Cannot import Moo::Role into a Moo class"; | ||||
40 | } | ||||
41 | 12 | 13µs | $INFO{$target} ||= {}; | ||
42 | # get symbol table reference | ||||
43 | 12 | 17µs | 12 | 21µ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 | ||||
45 | 51 | 9µs | my $name_proto = shift; | ||
46 | 51 | 28µs | my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto; | ||
47 | 51 | 33µ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 | } | ||||
52 | 51 | 38µs | my %spec = @_; | ||
53 | 51 | 104µs | foreach my $name (@name_proto) { | ||
54 | 51 | 21µs | my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec; | ||
55 | 51 | 87µs | 51 | 4.16ms | ($INFO{$target}{accessor_maker} ||= do { # spent 4.16ms making 51 calls to Method::Generate::Accessor::generate_method, avg 82µs/call |
56 | 7 | 10µs | require Method::Generate::Accessor; | ||
57 | 7 | 31µs | 7 | 92µ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); | ||||
59 | 51 | 48µs | push @{$INFO{$target}{attributes}||=[]}, $name, $spec_ref; | ||
60 | 51 | 48µs | 51 | 115µs | $me->_maybe_reset_handlemoose($target); # spent 115µs making 51 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call |
61 | } | ||||
62 | 12 | 59µs | 12 | 216µs | }; # spent 216µs making 12 calls to Moo::Role::_install_tracked, avg 18µs/call |
63 | # install before/after/around subs | ||||
64 | 12 | 9µ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 | ||||
66 | 3 | 48µs | require Class::Method::Modifiers; | ||
67 | 3 | 5µs | push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ]; | ||
68 | 3 | 8µs | 3 | 8µs | $me->_maybe_reset_handlemoose($target); # spent 8µs making 3 calls to Moo::Role::_maybe_reset_handlemoose, avg 3µs/call |
69 | 36 | 55µs | 36 | 332µ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 | ||||
72 | 9 | 19µs | push @{$INFO{$target}{requires}||=[]}, @_; | ||
73 | 9 | 44µs | 9 | 65µs | $me->_maybe_reset_handlemoose($target); # spent 65µs making 9 calls to Moo::Role::_maybe_reset_handlemoose, avg 7µs/call |
74 | 12 | 22µs | 12 | 113µ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 | ||||
76 | 4 | 10µs | 4 | 0s | $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 |
77 | 4 | 10µs | 4 | 10µs | $me->_maybe_reset_handlemoose($target); # spent 10µs making 4 calls to Moo::Role::_maybe_reset_handlemoose, avg 2µs/call |
78 | 12 | 24µs | 12 | 107µs | }; # spent 107µs making 12 calls to Moo::Role::_install_tracked, avg 9µs/call |
79 | 12 | 16µs | 12 | 229µ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 |
80 | 12 | 7µs | $INFO{$target}{is_role} = 1; | ||
81 | 12 | 43µs | 24 | 28µ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 | ||||
86 | 12 | 52µs | my @not_methods = ('', map { *$_{CODE}||() } grep !ref($_), values %$stash); | ||
87 | 12 | 67µs | @{$INFO{$target}{not_methods}={}}{@not_methods} = @not_methods; | ||
88 | # a role does itself | ||||
89 | 12 | 11µs | $APPLIED_TO{$target} = { $target => undef }; | ||
90 | |||||
91 | $_->($target) | ||||
92 | 12 | 72µs | 12 | 9.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 | ||||
96 | 12 | 4µs | my $target = shift; | ||
97 | 12 | 35µs | 12 | 9.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 | } | ||||
100 | 1 | 1µs | }; | ||
101 | |||||
102 | # duplicate from Moo::Object | ||||
103 | sub meta { | ||||
104 | require Moo::HandleMoose::FakeMetaClass; | ||||
105 | my $class = ref($_[0])||$_[0]; | ||||
106 | bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass'); | ||||
107 | } | ||||
108 | |||||
109 | sub 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 | ||||
115 | 67 | 17µs | my ($class, $target) = @_; | ||
116 | 67 | 118µs | 67 | 53µ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 | |||||
121 | sub 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 | ||||
130 | 68 | 12µs | my ($self, $role) = @_; | ||
131 | 68 | 41µs | 68 | 453µs | $self->_inhale_if_moose($role); # spent 453µs making 68 calls to Moo::Role::_inhale_if_moose, avg 7µs/call |
132 | 68 | 102µs | 68 | 46µ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 | ||||
136 | 96 | 27µs | my ($self, $role) = @_; | ||
137 | 96 | 10µs | my $meta; | ||
138 | 96 | 375µs | 217 | 273µ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 | ||||
217 | 17 | 4µs | my ($self, $target, $role) = @_; | ||
218 | 17 | 3µs | my $m; | ||
219 | 17 | 53µs | 17 | 17µ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 | |||||
227 | sub _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 | |||||
234 | sub _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 | ||||
252 | 14 | 39µs | 14 | 18µ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 | ||||
257 | 14 | 11µs | my ($me, $to, @roles) = @_; | ||
258 | 14 | 9µs | foreach my $role (@roles) { | ||
259 | 17 | 23µs | 17 | 63.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 |
260 | 17 | 23µs | 17 | 127µs | $me->_inhale_if_moose($role); # spent 127µs making 17 calls to Moo::Role::_inhale_if_moose, avg 7µs/call |
261 | 17 | 23µs | 17 | 115µ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 | } | ||||
263 | 14 | 42µs | 14 | 5.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 | ||||
267 | 11 | 3µs | my ($me, $to, $role) = @_; | ||
268 | 11 | 7µs | 11 | 244µ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 |
269 | 11 | 26µs | 11 | 69µs | $me->_inhale_if_moose($role); # spent 69µs making 11 calls to Moo::Role::_inhale_if_moose, avg 6µs/call |
270 | 11 | 9µs | 11 | 62µ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 |
271 | 11 | 24µs | 11 | 2.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 | |||||
274 | sub 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 | |||||
312 | sub 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 | |||||
354 | sub _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 | ||||
363 | 3 | 2µs | my ($me, @args) = @_; | ||
364 | 3 | 8µs | 3 | 520µ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 | ||||
368 | 17 | 4µs | my ($me, $to) = @_; | ||
369 | |||||
370 | # If Role::Tiny actually installed the DOES, give it a name | ||||
371 | 17 | 35µs | 17 | 434µ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 |
372 | 8 | 22µs | 8 | 41µ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 | ||||
376 | 4004 | 955µs | my ($proto, $role) = @_; | ||
377 | 4004 | 14.1ms | 4004 | 21.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 | ||||
391 | 17 | 5µs | my ($me, $to, $role) = @_; | ||
392 | 17 | 12µs | my $attr_info = $INFO{$role} && $INFO{$role}{attributes}; | ||
393 | 17 | 12µs | return unless $attr_info && @$attr_info; | ||
394 | 12 | 4µs | my $info = $INFO{$to}; | ||
395 | 12 | 22µs | 12 | 759µ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} || []} | ||||
398 | 12 | 29µs | 10 | 10µ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->[$_]} } | ||||
404 | 12 | 85µs | map { 2 * $_ } 0..@$attr_info/2-1; | ||
405 | |||||
406 | 12 | 101µs | 10 | 286µ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 | |||||
415 | 1 | 4µs | 1; | ||
416 | __END__ |