Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Role/Tiny.pm |
Statements | Executed 5347 statements in 11.9ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
178934 | 1 | 1 | 70.9ms | 70.9ms | CORE:subst (opcode) | JSON::Schema::Modern::Vocabulary::Core::
2 | 1 | 1 | 3.63ms | 4.82ms | _load_module | Role::Tiny::
603 | 1 | 1 | 1.95ms | 2.42ms | does_role | Role::Tiny::
24 | 4 | 2 | 870µs | 1.03ms | _all_subs | Role::Tiny::
12 | 1 | 1 | 547µs | 2.48ms | _install_methods | Role::Tiny::
12 | 3 | 3 | 407µs | 13.1ms | apply_roles_to_package | Role::Tiny::
79 | 5 | 5 | 308µs | 1.19ms | DOES | JSON::Schema::Modern::Vocabulary::Core::
79 | 5 | 5 | 305µs | 663µs | DOES | JSON::Schema::Modern::Vocabulary::Applicator::
12 | 2 | 2 | 250µs | 482µs | _install_does | Role::Tiny::
76 | 5 | 5 | 239µs | 527µs | DOES | JSON::Schema::Modern::Vocabulary::Unevaluated::
148 | 5 | 1 | 217µs | 217µs | _getglob | Role::Tiny::
79 | 5 | 5 | 216µs | 651µs | DOES | JSON::Schema::Modern::Vocabulary::FormatAnnotation::
19 | 2 | 1 | 211µs | 10.2ms | _check_roles | Role::Tiny::
79 | 5 | 5 | 200µs | 592µs | DOES | JSON::Schema::Modern::Vocabulary::Validation::
79 | 5 | 5 | 197µs | 702µs | DOES | JSON::Schema::Modern::Vocabulary::MetaData::
79 | 5 | 5 | 186µs | 535µs | DOES | JSON::Schema::Modern::Vocabulary::Content::
93 | 8 | 3 | 160µs | 160µs | is_role | Role::Tiny::
26 | 2 | 1 | 118µs | 118µs | _getstash | Role::Tiny::
12 | 1 | 1 | 93µs | 509µs | _concrete_methods_of | Role::Tiny::
4 | 3 | 3 | 90µs | 891µs | import | Role::Tiny::
12 | 1 | 1 | 83µs | 103µs | _check_requires | Role::Tiny::
567 | 3 | 1 | 82µs | 82µs | CORE:match (opcode) | Role::Tiny::
4 | 1 | 1 | 82µs | 217µs | make_role | Role::Tiny::
13 | 3 | 1 | 69µs | 85µs | CORE:sort (opcode) | JSON::Schema::Modern::Vocabulary::Core::
7 | 1 | 1 | 64µs | 2.57ms | create_class_with_roles | Role::Tiny::
2 | 1 | 1 | 53µs | 115µs | _install_subs | Role::Tiny::
30 | 1 | 1 | 51µs | 51µs | CORE:match (opcode) | JSON::Schema::Modern::Vocabulary::Core::
12 | 1 | 1 | 45µs | 45µs | _copy_applied_list | Role::Tiny::
7 | 1 | 1 | 40µs | 2.61ms | apply_roles_to_object | Role::Tiny::
8 | 3 | 2 | 34µs | 34µs | _non_methods | Role::Tiny::
2 | 1 | 1 | 32µs | 32µs | _gen_subs | Role::Tiny::
12 | 1 | 1 | 32µs | 332µs | _install_modifiers | Role::Tiny::
5 | 3 | 3 | 29µs | 70µs | DOES | JSON::Schema::Modern::Vocabulary::OpenAPI::
12 | 1 | 1 | 27µs | 29µs | _want_backcompat_hack | Role::Tiny::
7 | 1 | 1 | 25µs | 25µs | _composite_name | Role::Tiny::
12 | 2 | 2 | 20µs | 20µs | role_application_steps | Role::Tiny::
1 | 1 | 1 | 17µs | 19µs | BEGIN@2 | Role::Tiny::
1 | 1 | 1 | 17µs | 660µs | _build_class_with_roles | Role::Tiny::
2 | 1 | 1 | 12µs | 4.83ms | _require_module | Role::Tiny::
2 | 1 | 1 | 9µs | 9µs | CORE:subst (opcode) | Role::Tiny::
1 | 1 | 1 | 6µs | 18µs | BEGIN@484 | Role::Tiny::
2 | 1 | 1 | 6µs | 6µs | CORE:sort (opcode) | Role::Tiny::
1 | 1 | 1 | 5µs | 5µs | BEGIN@16 | Role::Tiny::
1 | 1 | 1 | 5µs | 11µs | BEGIN@24 | Role::Tiny::
1 | 1 | 1 | 5µs | 6µs | BEGIN@25 | Role::Tiny::
1 | 1 | 1 | 5µs | 8µs | BEGIN@65 | Role::Tiny::
1 | 1 | 1 | 4µs | 16µs | BEGIN@242 | Role::Tiny::
1 | 1 | 1 | 3µs | 15µs | BEGIN@29 | Role::Tiny::
1 | 1 | 1 | 2µs | 5µs | DOES | JSON::Schema::Modern::Vocabulary::FormatAssertion::
1 | 1 | 1 | 2µs | 18µs | BEGIN@3 | Role::Tiny::
0 | 0 | 0 | 0s | 0s | DOES | Method::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:145] | Role::Tiny::
0 | 0 | 0 | 0s | 0s | __ANON__[:150] | Role::Tiny::
0 | 0 | 0 | 0s | 0s | __ANON__[:154] | Role::Tiny::
0 | 0 | 0 | 0s | 0s | __ANON__[:465] | Role::Tiny::
0 | 0 | 0 | 0s | 0s | __ANON__[:483] | Role::Tiny::
0 | 0 | 0 | 0s | 0s | DESTROY | Role::Tiny::__GUARD__::
0 | 0 | 0 | 0s | 0s | _composite_info_for | Role::Tiny::
0 | 0 | 0 | 0s | 0s | _install_single_modifier | Role::Tiny::
0 | 0 | 0 | 0s | 0s | _mark_new_non_methods | Role::Tiny::
0 | 0 | 0 | 0s | 0s | apply_role_to_package | Role::Tiny::
0 | 0 | 0 | 0s | 0s | apply_single_role_to_package | Role::Tiny::
0 | 0 | 0 | 0s | 0s | croak | Role::Tiny::
0 | 0 | 0 | 0s | 0s | methods_provided_by | Role::Tiny::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Role::Tiny; | ||||
2 | 2 | 18µs | 2 | 21µs | # spent 19µs (17+2) within Role::Tiny::BEGIN@2 which was called:
# once (17µs+2µs) by Mojo::Base::BEGIN@17 at line 2 # spent 19µs making 1 call to Role::Tiny::BEGIN@2
# spent 2µs making 1 call to strict::import |
3 | 2 | 137µs | 2 | 34µs | # spent 18µs (2+16) within Role::Tiny::BEGIN@3 which was called:
# once (2µs+16µs) by Mojo::Base::BEGIN@17 at line 3 # spent 18µs making 1 call to Role::Tiny::BEGIN@3
# spent 16µs making 1 call to warnings::import |
4 | |||||
5 | 1 | 0s | our $VERSION = '2.002004'; | ||
6 | 1 | 1µs | $VERSION =~ tr/_//d; | ||
7 | |||||
8 | our %INFO; | ||||
9 | our %APPLIED_TO; | ||||
10 | our %COMPOSED; | ||||
11 | our %COMPOSITE_INFO; | ||||
12 | our @ON_ROLE_CREATE; | ||||
13 | |||||
14 | # Module state workaround totally stolen from Zefram's Module::Runtime. | ||||
15 | |||||
16 | # spent 5µs within Role::Tiny::BEGIN@16 which was called:
# once (5µs+0s) by Mojo::Base::BEGIN@17 at line 22 | ||||
17 | 1 | 2µs | *_WORK_AROUND_BROKEN_MODULE_STATE = "$]" < 5.009 ? sub(){1} : sub(){0}; | ||
18 | *_WORK_AROUND_HINT_LEAKAGE | ||||
19 | = "$]" < 5.011 && !("$]" >= 5.009004 && "$]" < 5.010001) | ||||
20 | 1 | 0s | ? sub(){1} : sub(){0}; | ||
21 | 1 | 21µs | *_CONSTANTS_DEFLATE = "$]" >= 5.012 && "$]" < 5.020 ? sub(){1} : sub(){0}; | ||
22 | 1 | 21µs | 1 | 5µs | } # spent 5µs making 1 call to Role::Tiny::BEGIN@16 |
23 | |||||
24 | 150 | 330µs | 2 | 17µs | # spent 11µs (5+6) within Role::Tiny::BEGIN@24 which was called:
# once (5µs+6µs) by Mojo::Base::BEGIN@17 at line 24
# spent 217µs within Role::Tiny::_getglob which was called 148 times, avg 1µs/call:
# 123 times (176µs+0s) by Role::Tiny::_install_methods at line 411, avg 1µs/call
# 12 times (14µs+0s) by Role::Tiny::_install_does at line 485, avg 1µs/call
# 10 times (17µs+0s) by Role::Tiny::_install_subs at line 131, avg 2µs/call
# 2 times (1µs+0s) by Role::Tiny::_install_does at line 474, avg 500ns/call
# once (9µs+0s) by Role::Tiny::_build_class_with_roles at line 215 # spent 11µs making 1 call to Role::Tiny::BEGIN@24
# spent 6µs making 1 call to strict::unimport |
25 | 28 | 123µs | 2 | 7µs | # spent 118µs within Role::Tiny::_getstash which was called 26 times, avg 5µs/call:
# 24 times (95µs+0s) by Role::Tiny::_all_subs at line 62, avg 4µs/call
# 2 times (23µs+0s) by Role::Tiny::_load_module at line 47, avg 12µs/call
# spent 6µs (5+1000ns) within Role::Tiny::BEGIN@25 which was called:
# once (5µs+1000ns) by Mojo::Base::BEGIN@17 at line 25 # spent 6µs making 1 call to Role::Tiny::BEGIN@25
# spent 1µs making 1 call to strict::unimport |
26 | |||||
27 | sub croak { | ||||
28 | require Carp; | ||||
29 | 2 | 163µs | 2 | 27µs | # spent 15µs (3+12) within Role::Tiny::BEGIN@29 which was called:
# once (3µs+12µs) by Mojo::Base::BEGIN@17 at line 29 # spent 15µs making 1 call to Role::Tiny::BEGIN@29
# spent 12µs making 1 call to warnings::unimport |
30 | *croak = \&Carp::croak; | ||||
31 | goto &Carp::croak; | ||||
32 | } | ||||
33 | |||||
34 | sub Role::Tiny::__GUARD__::DESTROY { | ||||
35 | delete $INC{$_[0]->[0]} if @{$_[0]}; | ||||
36 | } | ||||
37 | |||||
38 | # spent 4.82ms (3.63+1.19) within Role::Tiny::_load_module which was called 2 times, avg 2.41ms/call:
# 2 times (3.63ms+1.19ms) by Role::Tiny::_require_module at line 57, avg 2.41ms/call | ||||
39 | 2 | 1µs | my ($module) = @_; | ||
40 | 2 | 23µs | 2 | 9µs | (my $file = "$module.pm") =~ s{::}{/}g; # spent 9µs making 2 calls to Role::Tiny::CORE:subst, avg 4µs/call |
41 | return 1 | ||||
42 | 2 | 2µs | if $INC{$file}; | ||
43 | |||||
44 | # can't just ->can('can') because a sub-package Foo::Bar::Baz | ||||
45 | # creates a 'Baz::' key in Foo::Bar's symbol table | ||||
46 | return 1 | ||||
47 | 2 | 5µs | 2 | 23µs | if grep !/::\z/, keys %{_getstash($module)}; # spent 23µs making 2 calls to Role::Tiny::_getstash, avg 12µs/call |
48 | 2 | 1µs | my $guard = _WORK_AROUND_BROKEN_MODULE_STATE | ||
49 | && bless([ $file ], 'Role::Tiny::__GUARD__'); | ||||
50 | local %^H if _WORK_AROUND_HINT_LEAKAGE; | ||||
51 | 2 | 1.35ms | require $file; | ||
52 | pop @$guard if _WORK_AROUND_BROKEN_MODULE_STATE; | ||||
53 | 2 | 10µs | return 1; | ||
54 | } | ||||
55 | |||||
56 | # spent 4.83ms (12µs+4.82) within Role::Tiny::_require_module which was called 2 times, avg 2.42ms/call:
# 2 times (12µs+4.82ms) by Role::Tiny::_check_roles at line 231, avg 2.42ms/call | ||||
57 | 2 | 8µs | 2 | 4.82ms | _load_module($_[1]); # spent 4.82ms making 2 calls to Role::Tiny::_load_module, avg 2.41ms/call |
58 | } | ||||
59 | |||||
60 | # spent 1.03ms (870µs+156µs) within Role::Tiny::_all_subs which was called 24 times, avg 43µs/call:
# 12 times (509µs+71µs) by Role::Tiny::_install_methods at line 401, avg 48µs/call
# 4 times (188µs+52µs) by Role::Tiny::_concrete_methods_of at line 375, avg 60µs/call
# 4 times (101µs+16µs) by Moo::Role::_non_methods at line 150 of Moo/Role.pm, avg 29µs/call
# 4 times (72µs+17µs) by Role::Tiny::make_role at line 115, avg 22µs/call | ||||
61 | 24 | 8µs | my ($me, $package) = @_; | ||
62 | 24 | 64µs | 24 | 95µs | my $stash = _getstash($package); # spent 95µs making 24 calls to Role::Tiny::_getstash, avg 4µs/call |
63 | return { | ||||
64 | map {; | ||||
65 | 2 | 635µs | 2 | 11µs | # spent 8µs (5+3) within Role::Tiny::BEGIN@65 which was called:
# once (5µs+3µs) by Mojo::Base::BEGIN@17 at line 65 # spent 8µs making 1 call to Role::Tiny::BEGIN@65
# spent 3µs making 1 call to strict::unimport |
66 | # this is an ugly hack to populate the scalar slot of any globs, to | ||||
67 | # prevent perl from converting constants back into scalar refs in the | ||||
68 | # stash when they are used (perl 5.12 - 5.18). scalar slots on their own | ||||
69 | # aren't detectable through pure perl, so this seems like an acceptable | ||||
70 | # compromise. | ||||
71 | ${"${package}::${_}"} = ${"${package}::${_}"} | ||||
72 | if _CONSTANTS_DEFLATE; | ||||
73 | 292 | 152µs | $_ => \&{"${package}::${_}"} | ||
74 | } | ||||
75 | 24 | 749µs | 420 | 61µs | grep exists &{"${package}::${_}"}, # spent 61µs making 420 calls to Role::Tiny::CORE:match, avg 145ns/call |
76 | grep !/::\z/, | ||||
77 | keys %$stash | ||||
78 | }; | ||||
79 | } | ||||
80 | |||||
81 | # spent 891µs (90+801) within Role::Tiny::import which was called 4 times, avg 223µs/call:
# 2 times (37µs+517µs) by JSON::Schema::Modern::Vocabulary::BEGIN@10 or MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 at line 55 of Moo/Role.pm, avg 277µs/call
# once (37µs+196µs) by Data::Perl::Role::Collection::Array::BEGIN@7 at line 7 of Data/Perl/Role/Collection/Array.pm
# once (16µs+88µs) by Data::Perl::Role::Collection::Hash::BEGIN@7 at line 7 of Data/Perl/Role/Collection/Hash.pm | ||||
82 | 4 | 5µs | my $target = caller; | ||
83 | 4 | 3µs | my $me = shift; | ||
84 | 4 | 41µs | 4 | 23µs | strict->import; # spent 23µs making 4 calls to strict::import, avg 6µs/call |
85 | 4 | 9µs | 4 | 82µs | warnings->import; # spent 82µs making 4 calls to warnings::import, avg 20µs/call |
86 | 4 | 10µs | 4 | 76µs | my $non_methods = $me->_non_methods($target); # spent 68µs making 2 calls to Moo::Role::_non_methods, avg 34µs/call
# spent 8µs making 2 calls to Role::Tiny::_non_methods, avg 4µs/call |
87 | 4 | 8µs | 4 | 403µs | $me->_install_subs($target, @_); # spent 288µs making 2 calls to Moo::Role::_install_subs, avg 144µs/call
# spent 115µs making 2 calls to Role::Tiny::_install_subs, avg 58µs/call |
88 | 4 | 12µs | 4 | 217µs | $me->make_role($target); # spent 217µs making 4 calls to Role::Tiny::make_role, avg 54µs/call |
89 | 4 | 1µs | $me->_mark_new_non_methods($target, $non_methods) | ||
90 | if $non_methods && %$non_methods; | ||||
91 | 4 | 15µs | return; | ||
92 | } | ||||
93 | |||||
94 | sub _mark_new_non_methods { | ||||
95 | my ($me, $target, $old_non_methods) = @_; | ||||
96 | |||||
97 | my $non_methods = $INFO{$target}{non_methods}; | ||||
98 | |||||
99 | my $subs = $me->_all_subs($target); | ||||
100 | for my $sub (keys %$subs) { | ||||
101 | if ( exists $old_non_methods->{$sub} && $non_methods->{$sub} != $subs->{$sub} ) { | ||||
102 | $non_methods->{$sub} = $subs->{$sub}; | ||||
103 | } | ||||
104 | } | ||||
105 | |||||
106 | return; | ||||
107 | } | ||||
108 | |||||
109 | # spent 217µs (82+135) within Role::Tiny::make_role which was called 4 times, avg 54µs/call:
# 4 times (82µs+135µs) by Role::Tiny::import at line 88, avg 54µs/call | ||||
110 | 4 | 4µs | my ($me, $target) = @_; | ||
111 | |||||
112 | 4 | 3µs | 4 | 32µs | return if $me->is_role($target); # spent 31µs making 2 calls to Moo::Role::is_role, avg 16µs/call
# spent 1µs making 2 calls to Role::Tiny::is_role, avg 500ns/call |
113 | 4 | 14µs | $INFO{$target}{is_role} = 1; | ||
114 | |||||
115 | 4 | 9µs | 4 | 89µs | my $non_methods = $me->_all_subs($target); # spent 89µs making 4 calls to Role::Tiny::_all_subs, avg 22µs/call |
116 | 4 | 25µs | 24 | 1µs | delete @{$non_methods}{grep /\A\(/, keys %$non_methods}; # spent 1µs making 24 calls to Role::Tiny::CORE:match, avg 42ns/call |
117 | 4 | 2µs | $INFO{$target}{non_methods} = $non_methods; | ||
118 | |||||
119 | # a role does itself | ||||
120 | 4 | 8µs | $APPLIED_TO{$target} = { $target => undef }; | ||
121 | 4 | 12µs | foreach my $hook (@ON_ROLE_CREATE) { | ||
122 | 4 | 9µs | 4 | 13µs | $hook->($target); # spent 13µs making 4 calls to Moo::Role::__ANON__[Moo/Role.pm:123], avg 3µs/call |
123 | } | ||||
124 | } | ||||
125 | |||||
126 | # spent 115µs (53+62) within Role::Tiny::_install_subs which was called 2 times, avg 58µs/call:
# 2 times (53µs+62µs) by Role::Tiny::import at line 87, avg 58µs/call | ||||
127 | 2 | 1µs | my ($me, $target) = @_; | ||
128 | 2 | 9µs | 2 | 7µs | return if $me->is_role($target); # spent 7µs making 2 calls to Role::Tiny::is_role, avg 4µs/call |
129 | 2 | 9µs | 2 | 32µs | my %install = $me->_gen_subs($target); # spent 32µs making 2 calls to Role::Tiny::_gen_subs, avg 16µs/call |
130 | *{_getglob("${target}::${_}")} = $install{$_} | ||||
131 | 2 | 28µs | 12 | 23µs | for sort keys %install; # spent 17µs making 10 calls to Role::Tiny::_getglob, avg 2µs/call
# spent 6µs making 2 calls to Role::Tiny::CORE:sort, avg 3µs/call |
132 | 2 | 6µs | return; | ||
133 | } | ||||
134 | |||||
135 | # spent 32µs within Role::Tiny::_gen_subs which was called 2 times, avg 16µs/call:
# 2 times (32µs+0s) by Role::Tiny::_install_subs at line 129, avg 16µs/call | ||||
136 | 2 | 1µs | my ($me, $target) = @_; | ||
137 | ( | ||||
138 | (map {; | ||||
139 | 6 | 3µs | my $type = $_; | ||
140 | $type => sub { | ||||
141 | my $code = pop; | ||||
142 | my @names = ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_; | ||||
143 | push @{$INFO{$target}{modifiers}||=[]}, [ $type, @names, $code ]; | ||||
144 | return; | ||||
145 | 6 | 12µs | }; | ||
146 | } qw(before after around)), | ||||
147 | requires => sub { | ||||
148 | push @{$INFO{$target}{requires}||=[]}, @_; | ||||
149 | return; | ||||
150 | }, | ||||
151 | with => sub { | ||||
152 | $me->apply_roles_to_package($target, @_); | ||||
153 | return; | ||||
154 | }, | ||||
155 | 2 | 18µs | ); | ||
156 | } | ||||
157 | |||||
158 | # spent 20µs within Role::Tiny::role_application_steps which was called 12 times, avg 2µs/call:
# 10 times (18µs+0s) by Moo::Role::role_application_steps at line 294 of Moo/Role.pm, avg 2µs/call
# 2 times (2µs+0s) by Role::Tiny::apply_roles_to_package at line 301, avg 1µs/call | ||||
159 | 12 | 22µs | qw( | ||
160 | _install_methods | ||||
161 | _check_requires | ||||
162 | _install_modifiers | ||||
163 | _copy_applied_list | ||||
164 | ); | ||||
165 | } | ||||
166 | |||||
167 | # spent 45µs within Role::Tiny::_copy_applied_list which was called 12 times, avg 4µs/call:
# 12 times (45µs+0s) by Role::Tiny::apply_roles_to_package at line 312, avg 4µs/call | ||||
168 | 12 | 5µs | my ($me, $to, $role) = @_; | ||
169 | # copy our role list into the target's | ||||
170 | 12 | 46µs | @{$APPLIED_TO{$to}||={}}{keys %{$APPLIED_TO{$role}}} = (); | ||
171 | } | ||||
172 | |||||
173 | # spent 2.61ms (40µs+2.57) within Role::Tiny::apply_roles_to_object which was called 7 times, avg 373µs/call:
# 7 times (40µs+2.57ms) by Moo::Role::apply_roles_to_object at line 376 of Moo/Role.pm, avg 373µs/call | ||||
174 | 7 | 3µs | my ($me, $object, @roles) = @_; | ||
175 | 7 | 3µs | my $class = ref($object); | ||
176 | # on perl < 5.8.9, magic isn't copied to all ref copies. bless the parameter | ||||
177 | # directly, so at least the variable passed to us will get any magic applied | ||||
178 | 7 | 27µs | 7 | 2.57ms | bless($_[1], $me->create_class_with_roles($class, @roles)); # spent 2.57ms making 7 calls to Role::Tiny::create_class_with_roles, avg 367µs/call |
179 | } | ||||
180 | |||||
181 | 1 | 1µs | my $role_suffix = 'A000'; | ||
182 | # spent 25µs within Role::Tiny::_composite_name which was called 7 times, avg 4µs/call:
# 7 times (25µs+0s) by Role::Tiny::create_class_with_roles at line 203, avg 4µs/call | ||||
183 | 7 | 2µs | my ($me, $superclass, @roles) = @_; | ||
184 | |||||
185 | 7 | 10µs | my $new_name = $superclass . '__WITH__' . join '__AND__', @roles; | ||
186 | |||||
187 | 7 | 6µs | if (length($new_name) > 252) { | ||
188 | $new_name = $COMPOSED{abbrev}{$new_name} ||= do { | ||||
189 | my $abbrev = substr $new_name, 0, 250 - length $role_suffix; | ||||
190 | $abbrev =~ s/(?<!:):$//; | ||||
191 | $abbrev.'__'.$role_suffix++; | ||||
192 | }; | ||||
193 | } | ||||
194 | 7 | 10µs | return $new_name; | ||
195 | } | ||||
196 | |||||
197 | # spent 2.57ms (64µs+2.51) within Role::Tiny::create_class_with_roles which was called 7 times, avg 367µs/call:
# 7 times (64µs+2.51ms) by Role::Tiny::apply_roles_to_object at line 178, avg 367µs/call | ||||
198 | 7 | 4µs | my ($me, $superclass, @roles) = @_; | ||
199 | |||||
200 | 7 | 13µs | 7 | 116µs | $me->_require_module($superclass); # spent 116µs making 7 calls to Moo::Role::_require_module, avg 17µs/call |
201 | 7 | 13µs | 7 | 1.67ms | $me->_check_roles(@roles); # spent 1.67ms making 7 calls to Role::Tiny::_check_roles, avg 239µs/call |
202 | |||||
203 | 7 | 12µs | 7 | 25µs | my $new_name = $me->_composite_name($superclass, @roles); # spent 25µs making 7 calls to Role::Tiny::_composite_name, avg 4µs/call |
204 | |||||
205 | return $new_name | ||||
206 | 7 | 19µs | if $COMPOSED{class}{$new_name}; | ||
207 | |||||
208 | 1 | 4µs | 1 | 693µs | return $me->_build_class_with_roles($new_name, $superclass, @roles); # spent 693µs making 1 call to Moo::Role::_build_class_with_roles |
209 | } | ||||
210 | |||||
211 | # spent 660µs (17+643) within Role::Tiny::_build_class_with_roles which was called:
# once (17µs+643µs) by Moo::Role::_build_class_with_roles at line 301 of Moo/Role.pm | ||||
212 | 1 | 1µs | my ($me, $new_name, $superclass, @roles) = @_; | ||
213 | |||||
214 | 1 | 1µs | $COMPOSED{base}{$new_name} = $superclass; | ||
215 | 1 | 10µs | 1 | 9µs | @{*{_getglob("${new_name}::ISA")}} = ( $superclass ); # spent 9µs making 1 call to Role::Tiny::_getglob |
216 | 1 | 2µs | 1 | 634µs | $me->apply_roles_to_package($new_name, @roles); # spent 634µs making 1 call to Role::Tiny::apply_roles_to_package |
217 | 1 | 1µs | $COMPOSED{class}{$new_name} = 1; | ||
218 | 1 | 2µs | return $new_name; | ||
219 | } | ||||
220 | |||||
221 | sub _check_roles { | ||||
222 | 19 | 9µs | my ($me, @roles) = @_; | ||
223 | 19 | 8µs | croak "No roles supplied!" unless @roles; | ||
224 | |||||
225 | 19 | 1µs | my %seen; | ||
226 | 19 | 40µs | if (my @dupes = grep 1 == $seen{$_}++, @roles) { | ||
227 | croak "Duplicated roles: ".join(', ', @dupes); | ||||
228 | } | ||||
229 | |||||
230 | 19 | 48µs | foreach my $role (@roles) { | ||
231 | 19 | 36µs | 19 | 9.69ms | $me->_require_module($role); # spent 4.86ms making 17 calls to Moo::Role::_require_module, avg 286µs/call
# spent 4.83ms making 2 calls to Role::Tiny::_require_module, avg 2.42ms/call |
232 | 19 | 44µs | 19 | 307µs | croak "${role} is not a ${me}" unless $me->is_role($role); # spent 301µs making 17 calls to Moo::Role::is_role, avg 18µs/call
# spent 6µs making 2 calls to Role::Tiny::is_role, avg 3µs/call |
233 | } | ||||
234 | } | ||||
235 | |||||
236 | our %BACKCOMPAT_HACK; | ||||
237 | 1 | 0s | $BACKCOMPAT_HACK{+__PACKAGE__} = 0; | ||
238 | # spent 29µs (27+2) within Role::Tiny::_want_backcompat_hack which was called 12 times, avg 2µs/call:
# 12 times (27µs+2µs) by Role::Tiny::apply_roles_to_package at line 293, avg 2µs/call | ||||
239 | 12 | 4µs | my $me = shift; | ||
240 | return $BACKCOMPAT_HACK{$me} | ||||
241 | 12 | 25µs | if exists $BACKCOMPAT_HACK{$me}; | ||
242 | 2 | 1.08ms | 2 | 28µs | # spent 16µs (4+12) within Role::Tiny::BEGIN@242 which was called:
# once (4µs+12µs) by Mojo::Base::BEGIN@17 at line 242 # spent 16µs making 1 call to Role::Tiny::BEGIN@242
# spent 12µs making 1 call to warnings::unimport |
243 | 1 | 7µs | 1 | 2µs | $BACKCOMPAT_HACK{$me} = # spent 2µs making 1 call to UNIVERSAL::can |
244 | $me->can('apply_single_role_to_package') != \&apply_single_role_to_package | ||||
245 | && $me->can('role_application_steps') == \&role_application_steps | ||||
246 | } | ||||
247 | |||||
248 | our $IN_APPLY_ROLES; | ||||
249 | sub apply_single_role_to_package { | ||||
250 | return | ||||
251 | if $IN_APPLY_ROLES; | ||||
252 | local $IN_APPLY_ROLES = 1; | ||||
253 | |||||
254 | my ($me, $to, $role) = @_; | ||||
255 | $me->apply_roles_to_package($to, $role); | ||||
256 | } | ||||
257 | |||||
258 | sub apply_role_to_package { | ||||
259 | my ($me, $to, $role) = @_; | ||||
260 | $me->apply_roles_to_package($to, $role); | ||||
261 | } | ||||
262 | |||||
263 | # spent 13.1ms (407µs+12.7) within Role::Tiny::apply_roles_to_package which was called 12 times, avg 1.09ms/call:
# 9 times (313µs+6.62ms) by Moo::with at line 104 of Moo.pm, avg 770µs/call
# 2 times (55µs+5.48ms) by Role::Tiny::With::with at line 16 of Role/Tiny/With.pm, avg 2.77ms/call
# once (39µs+595µs) by Role::Tiny::_build_class_with_roles at line 216 | ||||
264 | 12 | 12µs | my ($me, $to, @roles) = @_; | ||
265 | 12 | 5µs | croak "Can't apply roles to object with apply_roles_to_package" | ||
266 | if ref $to; | ||||
267 | |||||
268 | 12 | 24µs | 12 | 8.53ms | $me->_check_roles(@roles); # spent 8.53ms making 12 calls to Role::Tiny::_check_roles, avg 711µs/call |
269 | |||||
270 | 12 | 2µs | my @have_conflicts; | ||
271 | my %role_methods; | ||||
272 | |||||
273 | 12 | 8µs | if (@roles > 1) { | ||
274 | my %conflicts = %{$me->_composite_info_for(@roles)->{conflicts}}; | ||||
275 | @have_conflicts = grep $to->can($_), keys %conflicts; | ||||
276 | delete @conflicts{@have_conflicts}; | ||||
277 | |||||
278 | if (keys %conflicts) { | ||||
279 | my $class = $COMPOSED{base}{$to} || $to; | ||||
280 | my $fail = | ||||
281 | join "\n", | ||||
282 | map { | ||||
283 | "Due to a method name conflict between roles " | ||||
284 | .join(' and ', map "'$_'", sort values %{$conflicts{$_}}) | ||||
285 | .", the method '$_' must be implemented by '$class'" | ||||
286 | } sort keys %conflicts; | ||||
287 | croak $fail; | ||||
288 | } | ||||
289 | |||||
290 | %role_methods = map +($_ => $me->_concrete_methods_of($_)), @roles; | ||||
291 | } | ||||
292 | |||||
293 | 12 | 26µs | 12 | 29µs | if (!$IN_APPLY_ROLES and _want_backcompat_hack($me)) { # spent 29µs making 12 calls to Role::Tiny::_want_backcompat_hack, avg 2µs/call |
294 | local $IN_APPLY_ROLES = 1; | ||||
295 | foreach my $role (@roles) { | ||||
296 | $me->apply_single_role_to_package($to, $role); | ||||
297 | } | ||||
298 | } | ||||
299 | |||||
300 | 12 | 4µs | my $role_methods; | ||
301 | 12 | 25µs | 12 | 50µs | foreach my $step ($me->role_application_steps) { # spent 48µs making 10 calls to Moo::Role::role_application_steps, avg 5µs/call
# spent 2µs making 2 calls to Role::Tiny::role_application_steps, avg 1µs/call |
302 | 78 | 31µs | foreach my $role (@roles) { | ||
303 | # conflicting methods are supposed to be treated as required by the | ||||
304 | # composed role. we don't have an actual composed role, but because | ||||
305 | # we know the target class already provides them, we can instead | ||||
306 | # pretend that the roles don't do for the duration of application. | ||||
307 | $role_methods = $role_methods{$role} and ( | ||||
308 | (local @{$role_methods}{@have_conflicts}), | ||||
309 | 78 | 21µs | (delete @{$role_methods}{@have_conflicts}), | ||
310 | ); | ||||
311 | |||||
312 | 78 | 145µs | 78 | 4.08ms | $me->$step($to, $role); # spent 2.48ms making 12 calls to Role::Tiny::_install_methods, avg 207µs/call
# spent 734µs making 10 calls to Moo::Role::_undefer_subs, avg 73µs/call
# spent 348µs making 10 calls to Moo::Role::_maybe_make_accessors, avg 35µs/call
# spent 332µs making 12 calls to Role::Tiny::_install_modifiers, avg 28µs/call
# spent 103µs making 12 calls to Role::Tiny::_check_requires, avg 9µs/call
# spent 45µs making 12 calls to Role::Tiny::_copy_applied_list, avg 4µs/call
# spent 34µs making 10 calls to Moo::Role::_handle_constructor, avg 3µs/call |
313 | } | ||||
314 | } | ||||
315 | 12 | 49µs | $APPLIED_TO{$to}{join('|',@roles)} = 1; | ||
316 | } | ||||
317 | |||||
318 | sub _composite_info_for { | ||||
319 | my ($me, @roles) = @_; | ||||
320 | $COMPOSITE_INFO{join('|', sort @roles)} ||= do { | ||||
321 | my %methods; | ||||
322 | foreach my $role (@roles) { | ||||
323 | my $this_methods = $me->_concrete_methods_of($role); | ||||
324 | $methods{$_}{$this_methods->{$_}} = $role for keys %$this_methods; | ||||
325 | } | ||||
326 | delete $methods{$_} for grep keys(%{$methods{$_}}) == 1, keys %methods; | ||||
327 | +{ conflicts => \%methods } | ||||
328 | }; | ||||
329 | } | ||||
330 | |||||
331 | # spent 103µs (83+20) within Role::Tiny::_check_requires which was called 12 times, avg 9µs/call:
# 12 times (83µs+20µs) by Role::Tiny::apply_roles_to_package at line 312, avg 9µs/call | ||||
332 | 12 | 6µs | my ($me, $to, $name, $requires) = @_; | ||
333 | 12 | 13µs | $requires ||= $INFO{$name}{requires} || []; | ||
334 | 12 | 92µs | 18 | 20µs | if (my @requires_fail = grep !$to->can($_), @$requires) { # spent 20µs making 18 calls to UNIVERSAL::can, avg 1µs/call |
335 | # role -> role, add to requires, role -> class, error out | ||||
336 | if (my $to_info = $INFO{$to}) { | ||||
337 | push @{$to_info->{requires}||=[]}, @requires_fail; | ||||
338 | } else { | ||||
339 | croak "Can't apply ${name} to ${to} - missing ".join(', ', @requires_fail); | ||||
340 | } | ||||
341 | } | ||||
342 | } | ||||
343 | |||||
344 | # spent 34µs within Role::Tiny::_non_methods which was called 8 times, avg 4µs/call:
# 4 times (17µs+0s) by Moo::Role::_non_methods at line 148 of Moo/Role.pm, avg 4µs/call
# 2 times (9µs+0s) by Role::Tiny::_concrete_methods_of at line 373, avg 4µs/call
# 2 times (8µs+0s) by Role::Tiny::import at line 86, avg 4µs/call | ||||
345 | 8 | 4µs | my ($me, $role) = @_; | ||
346 | 8 | 17µs | my $info = $INFO{$role} or return {}; | ||
347 | |||||
348 | 4 | 10µs | my %non_methods = %{ $info->{non_methods} || {} }; | ||
349 | |||||
350 | # this is only for backwards compatibility with older Moo, which | ||||
351 | # reimplements method tracking rather than calling our method | ||||
352 | 4 | 4µs | my %not_methods = reverse %{ $info->{not_methods} || {} }; | ||
353 | 4 | 7µs | return \%non_methods unless keys %not_methods; | ||
354 | |||||
355 | my $subs = $me->_all_subs($role); | ||||
356 | for my $sub (grep !/\A\(/, keys %$subs) { | ||||
357 | my $code = $subs->{$sub}; | ||||
358 | if (exists $not_methods{$code}) { | ||||
359 | $non_methods{$sub} = $code; | ||||
360 | } | ||||
361 | } | ||||
362 | |||||
363 | return \%non_methods; | ||||
364 | } | ||||
365 | |||||
366 | # spent 509µs (93+416) within Role::Tiny::_concrete_methods_of which was called 12 times, avg 42µs/call:
# 12 times (93µs+416µs) by Role::Tiny::_install_methods at line 398, avg 42µs/call | ||||
367 | 12 | 5µs | my ($me, $role) = @_; | ||
368 | 12 | 8µs | my $info = $INFO{$role}; | ||
369 | |||||
370 | return $info->{methods} | ||||
371 | 12 | 20µs | if $info && $info->{methods}; | ||
372 | |||||
373 | 4 | 6µs | 4 | 176µs | my $non_methods = $me->_non_methods($role); # spent 167µs making 2 calls to Moo::Role::_non_methods, avg 84µs/call
# spent 9µs making 2 calls to Role::Tiny::_non_methods, avg 4µs/call |
374 | |||||
375 | 4 | 5µs | 4 | 240µs | my $subs = $me->_all_subs($role); # spent 240µs making 4 calls to Role::Tiny::_all_subs, avg 60µs/call |
376 | 4 | 5µs | for my $sub (keys %$subs) { | ||
377 | 84 | 24µs | if ( exists $non_methods->{$sub} && $non_methods->{$sub} == $subs->{$sub} ) { | ||
378 | delete $subs->{$sub}; | ||||
379 | } | ||||
380 | } | ||||
381 | |||||
382 | 4 | 4µs | if ($info) { | ||
383 | $info->{methods} = $subs; | ||||
384 | } | ||||
385 | 4 | 11µs | return $subs; | ||
386 | } | ||||
387 | |||||
388 | sub methods_provided_by { | ||||
389 | my ($me, $role) = @_; | ||||
390 | $me->_require_module($role); | ||||
391 | croak "${role} is not a ${me}" unless $me->is_role($role); | ||||
392 | sort (keys %{$me->_concrete_methods_of($role)}, @{$INFO{$role}->{requires}||[]}); | ||||
393 | } | ||||
394 | |||||
395 | # spent 2.48ms (547µs+1.93) within Role::Tiny::_install_methods which was called 12 times, avg 207µs/call:
# 12 times (547µs+1.93ms) by Role::Tiny::apply_roles_to_package at line 312, avg 207µs/call | ||||
396 | 12 | 5µs | my ($me, $to, $role) = @_; | ||
397 | |||||
398 | 12 | 22µs | 12 | 509µs | my $methods = $me->_concrete_methods_of($role); # spent 509µs making 12 calls to Role::Tiny::_concrete_methods_of, avg 42µs/call |
399 | |||||
400 | 12 | 6µs | my %existing_methods; | ||
401 | 12 | 60µs | 12 | 580µs | @existing_methods{keys %{ $me->_all_subs($to) }} = (); # spent 580µs making 12 calls to Role::Tiny::_all_subs, avg 48µs/call |
402 | |||||
403 | # _concrete_methods_of caches its result on roles. that cache needs to be | ||||
404 | # invalidated after applying roles | ||||
405 | 12 | 7µs | delete $INFO{$to}{methods} if $INFO{$to}; | ||
406 | |||||
407 | 12 | 40µs | foreach my $i (keys %$methods) { | ||
408 | next | ||||
409 | 131 | 19µs | if exists $existing_methods{$i}; | ||
410 | |||||
411 | 123 | 89µs | 123 | 176µs | my $glob = _getglob "${to}::${i}"; # spent 176µs making 123 calls to Role::Tiny::_getglob, avg 1µs/call |
412 | 123 | 39µs | *$glob = $methods->{$i}; | ||
413 | |||||
414 | # overloads using method names have the method stored in the scalar slot | ||||
415 | # and &overload::nil in the code slot. | ||||
416 | next | ||||
417 | unless $i =~ /^\(/ | ||||
418 | && ((defined &overload::nil && $methods->{$i} == \&overload::nil) | ||||
419 | 123 | 160µs | 123 | 20µs | || (defined &overload::_nil && $methods->{$i} == \&overload::_nil)); # spent 20µs making 123 calls to Role::Tiny::CORE:match, avg 163ns/call |
420 | |||||
421 | my $overload = ${ _getglob "${role}::${i}" }; | ||||
422 | next | ||||
423 | unless defined $overload; | ||||
424 | |||||
425 | *$glob = \$overload; | ||||
426 | } | ||||
427 | |||||
428 | 12 | 47µs | 12 | 649µs | $me->_install_does($to); # spent 590µs making 10 calls to Moo::Role::_install_does, avg 59µs/call
# spent 59µs making 2 calls to Role::Tiny::_install_does, avg 30µs/call |
429 | } | ||||
430 | |||||
431 | # spent 332µs (32+300) within Role::Tiny::_install_modifiers which was called 12 times, avg 28µs/call:
# 12 times (32µs+300µs) by Role::Tiny::apply_roles_to_package at line 312, avg 28µs/call | ||||
432 | 12 | 8µs | my ($me, $to, $name) = @_; | ||
433 | 12 | 28µs | return unless my $modifiers = $INFO{$name}{modifiers}; | ||
434 | 1 | 0s | my $info = $INFO{$to}; | ||
435 | 1 | 1µs | my $existing = ($info ? $info->{modifiers} : $COMPOSED{modifiers}{$to}) ||= []; | ||
436 | my @modifiers = grep { | ||||
437 | 2 | 0s | my $modifier = $_; | ||
438 | 2 | 1µs | !grep $_ == $modifier, @$existing; | ||
439 | 1 | 1µs | } @{$modifiers||[]}; | ||
440 | 1 | 0s | push @$existing, @modifiers; | ||
441 | |||||
442 | 1 | 3µs | if (!$info) { | ||
443 | foreach my $modifier (@modifiers) { | ||||
444 | 2 | 3µs | 2 | 300µs | $me->_install_single_modifier($to, @$modifier); # spent 300µs making 2 calls to Moo::Role::_install_single_modifier, avg 150µs/call |
445 | } | ||||
446 | } | ||||
447 | } | ||||
448 | |||||
449 | 1 | 0s | my $vcheck_error; | ||
450 | |||||
451 | sub _install_single_modifier { | ||||
452 | my ($me, @args) = @_; | ||||
453 | defined($vcheck_error) or $vcheck_error = do { | ||||
454 | local $@; | ||||
455 | eval { | ||||
456 | require Class::Method::Modifiers; | ||||
457 | Class::Method::Modifiers->VERSION(1.05); | ||||
458 | 1; | ||||
459 | } ? 0 : $@; | ||||
460 | }; | ||||
461 | $vcheck_error and die $vcheck_error; | ||||
462 | Class::Method::Modifiers::install_modifier(@args); | ||||
463 | } | ||||
464 | |||||
465 | 1 | 1µs | my $FALLBACK = sub { 0 }; | ||
466 | # spent 482µs (250+232) within Role::Tiny::_install_does which was called 12 times, avg 40µs/call:
# 10 times (203µs+220µs) by Moo::Role::_install_does at line 400 of Moo/Role.pm, avg 42µs/call
# 2 times (47µs+12µs) by Role::Tiny::_install_methods at line 428, avg 30µs/call | ||||
467 | 12 | 6µs | my ($me, $to) = @_; | ||
468 | |||||
469 | # only add does() method to classes | ||||
470 | 12 | 13µs | 12 | 132µs | return if $me->is_role($to); # spent 132µs making 10 calls to Moo::Role::is_role, avg 13µs/call
# spent 0s making 2 calls to Role::Tiny::is_role, avg 0s/call |
471 | |||||
472 | 12 | 37µs | 12 | 14µs | my $does = $me->can('does_role'); # spent 14µs making 12 calls to UNIVERSAL::can, avg 1µs/call |
473 | # add does() only if they don't have one | ||||
474 | 12 | 68µs | 14 | 21µs | *{_getglob "${to}::does"} = $does unless $to->can('does'); # spent 20µs making 12 calls to UNIVERSAL::can, avg 2µs/call
# spent 1µs making 2 calls to Role::Tiny::_getglob, avg 500ns/call |
475 | |||||
476 | return | ||||
477 | 12 | 103µs | 36 | 46µs | if $to->can('DOES') and $to->can('DOES') != (UNIVERSAL->can('DOES') || 0); # spent 46µs making 36 calls to UNIVERSAL::can, avg 1µs/call |
478 | |||||
479 | 12 | 26µs | 12 | 5µs | my $existing = $to->can('DOES') || $to->can('isa') || $FALLBACK; # spent 5µs making 12 calls to UNIVERSAL::can, avg 417ns/call |
480 | # spent 535µs (186+349) within JSON::Schema::Modern::Vocabulary::Content::DOES which was called 79 times, avg 7µs/call:
# 36 times (96µs+165µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 7µs/call
# 24 times (51µs+125µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 7µs/call
# 14 times (24µs+45µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 5µs/call
# 3 times (6µs+8µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 5µs/call
# 2 times (9µs+6µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 8µs/call
# spent 527µs (239+288) within JSON::Schema::Modern::Vocabulary::Unevaluated::DOES which was called 76 times, avg 7µs/call:
# 36 times (128µs+141µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 7µs/call
# 24 times (85µs+93µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 7µs/call
# 14 times (19µs+46µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 5µs/call
# once (4µs+4µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3]
# once (3µs+4µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3]
# spent 663µs (305+358) within JSON::Schema::Modern::Vocabulary::Applicator::DOES which was called 79 times, avg 8µs/call:
# 36 times (121µs+156µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 8µs/call
# 24 times (114µs+130µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 10µs/call
# 14 times (62µs+56µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 8µs/call
# 3 times (4µs+10µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 5µs/call
# 2 times (4µs+6µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 5µs/call
# spent 592µs (200+392) within JSON::Schema::Modern::Vocabulary::Validation::DOES which was called 79 times, avg 7µs/call:
# 36 times (92µs+169µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 7µs/call
# 24 times (55µs+144µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 8µs/call
# 14 times (42µs+44µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 6µs/call
# 3 times (6µs+27µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 11µs/call
# 2 times (5µs+8µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 6µs/call
# spent 651µs (216+435) within JSON::Schema::Modern::Vocabulary::FormatAnnotation::DOES which was called 79 times, avg 8µs/call:
# 36 times (123µs+186µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 9µs/call
# 24 times (60µs+179µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 10µs/call
# 14 times (24µs+48µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 5µs/call
# 3 times (4µs+15µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 6µs/call
# 2 times (5µs+7µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 6µs/call
# spent 1.19ms (308µs+882µs) within JSON::Schema::Modern::Vocabulary::Core::DOES which was called 79 times, avg 15µs/call:
# 36 times (160µs+421µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 16µs/call
# 24 times (101µs+295µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 16µs/call
# 14 times (32µs+142µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 12µs/call
# 3 times (9µs+18µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 9µs/call
# 2 times (6µs+6µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 6µs/call
# spent 5µs (2+3) within JSON::Schema::Modern::Vocabulary::FormatAssertion::DOES which was called:
# once (2µs+3µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3]
# spent 702µs (197+505) within JSON::Schema::Modern::Vocabulary::MetaData::DOES which was called 79 times, avg 9µs/call:
# 36 times (108µs+217µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 9µs/call
# 24 times (58µs+165µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 9µs/call
# 14 times (22µs+79µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 7µs/call
# 3 times (5µs+10µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 5µs/call
# 2 times (4µs+34µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 19µs/call
# spent 70µs (29+41) within JSON::Schema::Modern::Vocabulary::OpenAPI::DOES which was called 5 times, avg 14µs/call:
# 2 times (14µs+7µs) by Type::Tiny::__ANON__[(eval 432)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 432)[Sub/Quote.pm:3], avg 10µs/call
# 2 times (7µs+13µs) by Type::Tiny::__ANON__[(eval 434)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 434)[Sub/Quote.pm:3], avg 10µs/call
# once (8µs+21µs) by Type::Tiny::__ANON__[(eval 423)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 423)[Sub/Quote.pm:3] | ||||
481 | 556 | 205µs | my ($proto, $role) = @_; | ||
482 | 556 | 1.22ms | 556 | 3.25ms | $proto->$does($role) or $proto->$existing($role); # spent 3.25ms making 556 calls to Moo::Role::does_role, avg 6µs/call |
483 | 12 | 32µs | }; | ||
484 | 2 | 192µs | 2 | 30µs | # spent 18µs (6+12) within Role::Tiny::BEGIN@484 which was called:
# once (6µs+12µs) by Mojo::Base::BEGIN@17 at line 484 # spent 18µs making 1 call to Role::Tiny::BEGIN@484
# spent 12µs making 1 call to warnings::unimport |
485 | 12 | 47µs | 12 | 14µs | return *{_getglob "${to}::DOES"} = $new_sub; # spent 14µs making 12 calls to Role::Tiny::_getglob, avg 1µs/call |
486 | } | ||||
487 | |||||
488 | # optimize for newer perls | ||||
489 | require mro | ||||
490 | 1 | 2µs | if "$]" >= 5.009_005; | ||
491 | |||||
492 | 1 | 1µs | if (defined &mro::get_linear_isa) { | ||
493 | *_linear_isa = \&mro::get_linear_isa; | ||||
494 | } | ||||
495 | else { | ||||
496 | my $e; | ||||
497 | { | ||||
498 | local $@; | ||||
499 | # this routine is simplified and not fully compatible with mro::get_linear_isa | ||||
500 | # but for our use the order doesn't matter, so we don't need to care | ||||
501 | eval <<'END_CODE' or $e = $@; | ||||
502 | sub _linear_isa($;$) { | ||||
503 | if (defined &mro::get_linear_isa) { | ||||
504 | no warnings 'redefine', 'prototype'; | ||||
505 | *_linear_isa = \&mro::get_linear_isa; | ||||
506 | goto &mro::get_linear_isa; | ||||
507 | } | ||||
508 | |||||
509 | my @check = shift; | ||||
510 | my @lin; | ||||
511 | |||||
512 | my %found; | ||||
513 | while (defined(my $check = shift @check)) { | ||||
514 | push @lin, $check; | ||||
515 | no strict 'refs'; | ||||
516 | unshift @check, grep !$found{$_}++, @{"$check\::ISA"}; | ||||
517 | } | ||||
518 | |||||
519 | return \@lin; | ||||
520 | } | ||||
521 | |||||
522 | 1; | ||||
523 | END_CODE | ||||
524 | } | ||||
525 | die $e if defined $e; | ||||
526 | } | ||||
527 | |||||
528 | # spent 2.42ms (1.95+468µs) within Role::Tiny::does_role which was called 603 times, avg 4µs/call:
# 603 times (1.95ms+468µs) by Moo::Role::does_role at line 406 of Moo/Role.pm, avg 4µs/call | ||||
529 | 603 | 151µs | my ($proto, $role) = @_; | ||
530 | 603 | 1.47ms | 603 | 468µs | foreach my $class (@{_linear_isa(ref($proto)||$proto)}) { # spent 468µs making 603 calls to mro::get_linear_isa, avg 776ns/call |
531 | 610 | 1.27ms | return 1 if exists $APPLIED_TO{$class}{$role}; | ||
532 | } | ||||
533 | 7 | 15µs | return 0; | ||
534 | } | ||||
535 | |||||
536 | # spent 160µs within Role::Tiny::is_role which was called 93 times, avg 2µs/call:
# 34 times (81µs+0s) by Moo::Role::_inhale_if_moose at line 166 of Moo/Role.pm, avg 2µs/call
# 34 times (24µs+0s) by Moo::Role::is_role at line 160 of Moo/Role.pm, avg 706ns/call
# 15 times (39µs+0s) by Moo::import at line 40 of Moo.pm, avg 3µs/call
# 2 times (7µs+0s) by Role::Tiny::_install_subs at line 128, avg 4µs/call
# 2 times (6µs+0s) by Role::Tiny::_check_roles at line 232, avg 3µs/call
# 2 times (2µs+0s) by Moo::_set_superclasses at line 149 of Moo.pm, avg 1µs/call
# 2 times (1µs+0s) by Role::Tiny::make_role at line 112, avg 500ns/call
# 2 times (0s+0s) by Role::Tiny::_install_does at line 470, avg 0s/call | ||||
537 | 93 | 35µs | my ($me, $role) = @_; | ||
538 | return !!($INFO{$role} && ( | ||||
539 | $INFO{$role}{is_role} | ||||
540 | # these are for backward compatibility with older Moo that overrode some | ||||
541 | # methods without calling the originals, thus not getting is_role set | ||||
542 | || $INFO{$role}{requires} | ||||
543 | || $INFO{$role}{not_methods} | ||||
544 | || $INFO{$role}{non_methods} | ||||
545 | 93 | 232µs | )); | ||
546 | } | ||||
547 | |||||
548 | 1 | 6µs | 1; | ||
549 | __END__ | ||||
# spent 51µs within JSON::Schema::Modern::Vocabulary::Core::CORE:match which was called 30 times, avg 2µs/call:
# 30 times (51µs+0s) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 166 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 2µs/call | |||||
# spent 85µs (69+16) within JSON::Schema::Modern::Vocabulary::Core::CORE:sort which was called 13 times, avg 7µs/call:
# 11 times (13µs+0s) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 270 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 1µs/call
# once (54µs+16µs) by JSON::Schema::Modern::Vocabulary::Core::__fetch_vocabulary_data at line 337 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm
# once (2µs+0s) by JSON::Schema::Modern::Vocabulary::Core::__fetch_vocabulary_data at line 321 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm | |||||
# spent 70.9ms within JSON::Schema::Modern::Vocabulary::Core::CORE:subst which was called 178934 times, avg 396ns/call:
# 178934 times (70.9ms+0s) by JSON::Schema::Modern::Vocabulary::Core::_eval_keyword_id at line 107 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 396ns/call | |||||
# spent 82µs within Role::Tiny::CORE:match which was called 567 times, avg 145ns/call:
# 420 times (61µs+0s) by Role::Tiny::_all_subs at line 75, avg 145ns/call
# 123 times (20µs+0s) by Role::Tiny::_install_methods at line 419, avg 163ns/call
# 24 times (1µs+0s) by Role::Tiny::make_role at line 116, avg 42ns/call | |||||
# spent 6µs within Role::Tiny::CORE:sort which was called 2 times, avg 3µs/call:
# 2 times (6µs+0s) by Role::Tiny::_install_subs at line 131, avg 3µs/call | |||||
# spent 9µs within Role::Tiny::CORE:subst which was called 2 times, avg 4µs/call:
# 2 times (9µs+0s) by Role::Tiny::_load_module at line 40, avg 4µs/call |