← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 16:10:05 2022
Reported on Wed Dec 14 16:12:57 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Role/Tiny.pm
StatementsExecuted 5347 statements in 14.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
731115.26ms5.26msJSON::Schema::Modern::Vocabulary::FormatAssertion::::CORE:regcomp JSON::Schema::Modern::Vocabulary::FormatAssertion::CORE:regcomp (opcode)
2113.87ms5.13msRole::Tiny::::_load_module Role::Tiny::_load_module
603111.97ms2.45msRole::Tiny::::does_role Role::Tiny::does_role
24421.09ms1.26msRole::Tiny::::_all_subs Role::Tiny::_all_subs
1211668µs3.15msRole::Tiny::::_install_methods Role::Tiny::_install_methods
1233493µs16.6msRole::Tiny::::apply_roles_to_package Role::Tiny::apply_roles_to_package
1222345µs618µsRole::Tiny::::_install_does Role::Tiny::_install_does
14851309µs309µsRole::Tiny::::_getglob Role::Tiny::_getglob
7955283µs1.19msJSON::Schema::Modern::Vocabulary::Core::::DOES JSON::Schema::Modern::Vocabulary::Core::DOES
7955278µs639µsJSON::Schema::Modern::Vocabulary::Content::::DOES JSON::Schema::Modern::Vocabulary::Content::DOES
7955259µs640µsJSON::Schema::Modern::Vocabulary::Validation::::DOES JSON::Schema::Modern::Vocabulary::Validation::DOES
7955257µs583µsJSON::Schema::Modern::Vocabulary::FormatAnnotation::::DOES JSON::Schema::Modern::Vocabulary::FormatAnnotation::DOES
7955241µs597µsJSON::Schema::Modern::Vocabulary::Applicator::::DOES JSON::Schema::Modern::Vocabulary::Applicator::DOES
1921220µs13.1msRole::Tiny::::_check_roles Role::Tiny::_check_roles
7955217µs604µsJSON::Schema::Modern::Vocabulary::MetaData::::DOES JSON::Schema::Modern::Vocabulary::MetaData::DOES
9383180µs180µsRole::Tiny::::is_role Role::Tiny::is_role
7655175µs547µsJSON::Schema::Modern::Vocabulary::Unevaluated::::DOES JSON::Schema::Modern::Vocabulary::Unevaluated::DOES
411119µs383µsRole::Tiny::::make_role Role::Tiny::make_role
1211118µs648µsRole::Tiny::::_concrete_methods_of Role::Tiny::_concrete_methods_of
56731111µs111µsRole::Tiny::::CORE:match Role::Tiny::CORE:match (opcode)
74121106µs106µsJSON::Schema::Modern::Vocabulary::FormatAssertion::::CORE:qr JSON::Schema::Modern::Vocabulary::FormatAssertion::CORE:qr (opcode)
2621101µs101µsRole::Tiny::::_getstash Role::Tiny::_getstash
71189µs4.49msRole::Tiny::::create_class_with_roles Role::Tiny::create_class_with_roles
43388µs1.15msRole::Tiny::::import Role::Tiny::import
83278µs78µsRole::Tiny::::_non_methods Role::Tiny::_non_methods
121176µs90µsRole::Tiny::::_check_requires Role::Tiny::_check_requires
21167µs133µsRole::Tiny::::_install_subs Role::Tiny::_install_subs
121162µs65µsRole::Tiny::::_want_backcompat_hack Role::Tiny::_want_backcompat_hack
71159µs4.55msRole::Tiny::::apply_roles_to_object Role::Tiny::apply_roles_to_object
121149µs49µsRole::Tiny::::_copy_applied_list Role::Tiny::_copy_applied_list
121144µs893µsRole::Tiny::::_install_modifiers Role::Tiny::_install_modifiers
71135µs35µsRole::Tiny::::_composite_name Role::Tiny::_composite_name
21130µs30µsRole::Tiny::::_gen_subs Role::Tiny::_gen_subs
11128µs30µsRole::Tiny::::BEGIN@2 Role::Tiny::BEGIN@2
11128µs1.68msRole::Tiny::::_build_class_with_roles Role::Tiny::_build_class_with_roles
21118µs5.15msRole::Tiny::::_require_module Role::Tiny::_require_module
122218µs18µsRole::Tiny::::role_application_steps Role::Tiny::role_application_steps
11116µs66µsRole::Tiny::::BEGIN@484 Role::Tiny::BEGIN@484
53315µs37µsJSON::Schema::Modern::Vocabulary::OpenAPI::::DOES JSON::Schema::Modern::Vocabulary::OpenAPI::DOES
11113µs74µsRole::Tiny::::BEGIN@242 Role::Tiny::BEGIN@242
2119µs9µsRole::Tiny::::CORE:subst Role::Tiny::CORE:subst (opcode)
1117µs7µsRole::Tiny::::BEGIN@16 Role::Tiny::BEGIN@16
1117µs36µsRole::Tiny::::BEGIN@3 Role::Tiny::BEGIN@3
1116µs14µsRole::Tiny::::BEGIN@24 Role::Tiny::BEGIN@24
2116µs6µsRole::Tiny::::CORE:sort Role::Tiny::CORE:sort (opcode)
1115µs8µsRole::Tiny::::BEGIN@25 Role::Tiny::BEGIN@25
1115µs26µsRole::Tiny::::BEGIN@29 Role::Tiny::BEGIN@29
1115µs9µsRole::Tiny::::BEGIN@65 Role::Tiny::BEGIN@65
1114µs8µsJSON::Schema::Modern::Vocabulary::FormatAssertion::::DOES JSON::Schema::Modern::Vocabulary::FormatAssertion::DOES
0000s0sMethod::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::::DOESMethod::Generate::Accessor__WITH__MooX::TypeTiny::Role::GenerateAccessor::DOES
0000s0sRole::Tiny::::__ANON__[:145] Role::Tiny::__ANON__[:145]
0000s0sRole::Tiny::::__ANON__[:150] Role::Tiny::__ANON__[:150]
0000s0sRole::Tiny::::__ANON__[:154] Role::Tiny::__ANON__[:154]
0000s0sRole::Tiny::::__ANON__[:465] Role::Tiny::__ANON__[:465]
0000s0sRole::Tiny::::__ANON__[:483] Role::Tiny::__ANON__[:483]
0000s0sRole::Tiny::__GUARD__::::DESTROY Role::Tiny::__GUARD__::DESTROY
0000s0sRole::Tiny::::_composite_info_for Role::Tiny::_composite_info_for
0000s0sRole::Tiny::::_install_single_modifier Role::Tiny::_install_single_modifier
0000s0sRole::Tiny::::_mark_new_non_methods Role::Tiny::_mark_new_non_methods
0000s0sRole::Tiny::::apply_role_to_package Role::Tiny::apply_role_to_package
0000s0sRole::Tiny::::apply_single_role_to_package Role::Tiny::apply_single_role_to_package
0000s0sRole::Tiny::::croak Role::Tiny::croak
0000s0sRole::Tiny::::methods_provided_by Role::Tiny::methods_provided_by
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Role::Tiny;
2246µs232µs
# spent 30µs (28+2) within Role::Tiny::BEGIN@2 which was called: # once (28µs+2µs) by Mojo::Base::BEGIN@17 at line 2
use strict;
# spent 30µs making 1 call to Role::Tiny::BEGIN@2 # spent 2µs making 1 call to strict::import
32207µs265µs
# spent 36µs (7+29) within Role::Tiny::BEGIN@3 which was called: # once (7µs+29µs) by Mojo::Base::BEGIN@17 at line 3
use warnings;
# spent 36µs making 1 call to Role::Tiny::BEGIN@3 # spent 29µs making 1 call to warnings::import
4
511µsour $VERSION = '2.002004';
612µs$VERSION =~ tr/_//d;
7
8our %INFO;
9our %APPLIED_TO;
10our %COMPOSED;
11our %COMPOSITE_INFO;
12our @ON_ROLE_CREATE;
13
14# Module state workaround totally stolen from Zefram's Module::Runtime.
15
16
# spent 7µs within Role::Tiny::BEGIN@16 which was called: # once (7µs+0s) by Mojo::Base::BEGIN@17 at line 22
BEGIN {
1713µs *_WORK_AROUND_BROKEN_MODULE_STATE = "$]" < 5.009 ? sub(){1} : sub(){0};
18 *_WORK_AROUND_HINT_LEAKAGE
19 = "$]" < 5.011 && !("$]" >= 5.009004 && "$]" < 5.010001)
2010s ? sub(){1} : sub(){0};
2115µs *_CONSTANTS_DEFLATE = "$]" >= 5.012 && "$]" < 5.020 ? sub(){1} : sub(){0};
22130µs17µs}
# spent 7µs making 1 call to Role::Tiny::BEGIN@16
23
24150489µs222µs
# spent 14µs (6+8) within Role::Tiny::BEGIN@24 which was called: # once (6µs+8µs) by Mojo::Base::BEGIN@17 at line 24 # spent 309µs within Role::Tiny::_getglob which was called 148 times, avg 2µs/call: # 123 times (256µs+0s) by Role::Tiny::_install_methods at line 411, avg 2µs/call # 12 times (15µs+0s) by Role::Tiny::_install_does at line 485, avg 1µs/call # 10 times (26µs+0s) by Role::Tiny::_install_subs at line 131, avg 3µs/call # 2 times (2µs+0s) by Role::Tiny::_install_does at line 474, avg 1µs/call # once (10µs+0s) by Role::Tiny::_build_class_with_roles at line 215
sub _getglob { no strict 'refs'; \*{$_[0]} }
# spent 14µs making 1 call to Role::Tiny::BEGIN@24 # spent 8µs making 1 call to strict::unimport
2528171µs211µs
# spent 101µs within Role::Tiny::_getstash which was called 26 times, avg 4µs/call: # 24 times (85µs+0s) by Role::Tiny::_all_subs at line 62, avg 4µs/call # 2 times (16µs+0s) by Role::Tiny::_load_module at line 47, avg 8µs/call # spent 8µs (5+3) within Role::Tiny::BEGIN@25 which was called: # once (5µs+3µs) by Mojo::Base::BEGIN@17 at line 25
sub _getstash { no strict 'refs'; \%{"$_[0]::"} }
# spent 8µs making 1 call to Role::Tiny::BEGIN@25 # spent 3µs making 1 call to strict::unimport
26
27sub croak {
28 require Carp;
292231µs247µs
# spent 26µs (5+21) within Role::Tiny::BEGIN@29 which was called: # once (5µs+21µs) by Mojo::Base::BEGIN@17 at line 29
no warnings 'redefine';
# spent 26µs making 1 call to Role::Tiny::BEGIN@29 # spent 21µs making 1 call to warnings::unimport
30 *croak = \&Carp::croak;
31 goto &Carp::croak;
32}
33
34sub Role::Tiny::__GUARD__::DESTROY {
35 delete $INC{$_[0]->[0]} if @{$_[0]};
36}
37
38
# spent 5.13ms (3.87+1.26) within Role::Tiny::_load_module which was called 2 times, avg 2.57ms/call: # 2 times (3.87ms+1.26ms) by Role::Tiny::_require_module at line 57, avg 2.57ms/call
sub _load_module {
3921µs my ($module) = @_;
40220µs29µ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
4223µ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
4729µs216µs if grep !/::\z/, keys %{_getstash($module)};
# spent 16µs making 2 calls to Role::Tiny::_getstash, avg 8µs/call
4821µs my $guard = _WORK_AROUND_BROKEN_MODULE_STATE
49 && bless([ $file ], 'Role::Tiny::__GUARD__');
50 local %^H if _WORK_AROUND_HINT_LEAKAGE;
512852µs require $file;
52 pop @$guard if _WORK_AROUND_BROKEN_MODULE_STATE;
53213µs return 1;
54}
55
56
# spent 5.15ms (18µs+5.13) within Role::Tiny::_require_module which was called 2 times, avg 2.58ms/call: # 2 times (18µs+5.13ms) by Role::Tiny::_check_roles at line 231, avg 2.58ms/call
sub _require_module {
57211µs25.13ms _load_module($_[1]);
# spent 5.13ms making 2 calls to Role::Tiny::_load_module, avg 2.57ms/call
58}
59
60
# spent 1.26ms (1.09+168µs) within Role::Tiny::_all_subs which was called 24 times, avg 52µs/call: # 12 times (606µs+98µs) by Role::Tiny::_install_methods at line 401, avg 59µs/call # 4 times (234µs+24µs) by Role::Tiny::_concrete_methods_of at line 375, avg 64µs/call # 4 times (130µs+25µs) by Moo::Role::_non_methods at line 150 of Moo/Role.pm, avg 39µs/call # 4 times (122µs+21µs) by Role::Tiny::make_role at line 115, avg 36µs/call
sub _all_subs {
61249µs my ($me, $package) = @_;
622445µs2485µs my $stash = _getstash($package);
# spent 85µs making 24 calls to Role::Tiny::_getstash, avg 4µs/call
63 return {
64 map {;
6521.07ms213µs
# spent 9µs (5+4) within Role::Tiny::BEGIN@65 which was called: # once (5µs+4µs) by Mojo::Base::BEGIN@17 at line 65
no strict 'refs';
# spent 9µs making 1 call to Role::Tiny::BEGIN@65 # spent 4µ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;
73292204µs $_ => \&{"${package}::${_}"}
74 }
7524923µs42083µs grep exists &{"${package}::${_}"},
# spent 83µs making 420 calls to Role::Tiny::CORE:match, avg 198ns/call
76 grep !/::\z/,
77 keys %$stash
78 };
79}
80
81
# spent 1.15ms (88µs+1.06) within Role::Tiny::import which was called 4 times, avg 287µs/call: # 2 times (49µs+779µs) by JSON::Schema::Modern::Vocabulary::BEGIN@10 or MooX::TypeTiny::Role::GenerateAccessor::BEGIN@2 at line 55 of Moo/Role.pm, avg 414µs/call # once (18µs+156µs) by Data::Perl::Role::Collection::Array::BEGIN@7 at line 7 of Data/Perl/Role/Collection/Array.pm # once (21µs+125µs) by Data::Perl::Role::Collection::Hash::BEGIN@7 at line 7 of Data/Perl/Role/Collection/Hash.pm
sub import {
8242µs my $target = caller;
8341µs my $me = shift;
84421µs46µs strict->import;
# spent 6µs making 4 calls to strict::import, avg 2µs/call
8547µs485µs warnings->import;
# spent 85µs making 4 calls to warnings::import, avg 21µs/call
86411µs4114µs my $non_methods = $me->_non_methods($target);
# spent 108µs making 2 calls to Moo::Role::_non_methods, avg 54µs/call # spent 6µs making 2 calls to Role::Tiny::_non_methods, avg 3µs/call
8745µs4472µs $me->_install_subs($target, @_);
# spent 339µs making 2 calls to Moo::Role::_install_subs, avg 170µs/call # spent 133µs making 2 calls to Role::Tiny::_install_subs, avg 66µs/call
88428µs4383µs $me->make_role($target);
# spent 383µs making 4 calls to Role::Tiny::make_role, avg 96µs/call
8944µs $me->_mark_new_non_methods($target, $non_methods)
90 if $non_methods && %$non_methods;
91421µs return;
92}
93
94sub _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 383µs (119+264) within Role::Tiny::make_role which was called 4 times, avg 96µs/call: # 4 times (119µs+264µs) by Role::Tiny::import at line 88, avg 96µs/call
sub make_role {
11042µs my ($me, $target) = @_;
111
11246µs4108µs return if $me->is_role($target);
# spent 105µs making 2 calls to Moo::Role::is_role, avg 52µs/call # spent 3µs making 2 calls to Role::Tiny::is_role, avg 2µs/call
11345µs $INFO{$target}{is_role} = 1;
114
115410µs4143µs my $non_methods = $me->_all_subs($target);
# spent 143µs making 4 calls to Role::Tiny::_all_subs, avg 36µs/call
116436µs243µs delete @{$non_methods}{grep /\A\(/, keys %$non_methods};
# spent 3µs making 24 calls to Role::Tiny::CORE:match, avg 125ns/call
11748µs $INFO{$target}{non_methods} = $non_methods;
118
119 # a role does itself
12046µs $APPLIED_TO{$target} = { $target => undef };
121414µs foreach my $hook (@ON_ROLE_CREATE) {
12249µs410µs $hook->($target);
# spent 10µs making 4 calls to Moo::Role::__ANON__[Moo/Role.pm:123], avg 2µs/call
123 }
124}
125
126
# spent 133µs (67+66) within Role::Tiny::_install_subs which was called 2 times, avg 66µs/call: # 2 times (67µs+66µs) by Role::Tiny::import at line 87, avg 66µs/call
sub _install_subs {
12720s my ($me, $target) = @_;
12824µs24µs return if $me->is_role($target);
# spent 4µs making 2 calls to Role::Tiny::is_role, avg 2µs/call
12928µs230µs my %install = $me->_gen_subs($target);
# spent 30µs making 2 calls to Role::Tiny::_gen_subs, avg 15µs/call
130 *{_getglob("${target}::${_}")} = $install{$_}
131234µs1232µs for sort keys %install;
# spent 26µs making 10 calls to Role::Tiny::_getglob, avg 3µs/call # spent 6µs making 2 calls to Role::Tiny::CORE:sort, avg 3µs/call
13226µs return;
133}
134
135
# spent 30µs within Role::Tiny::_gen_subs which was called 2 times, avg 15µs/call: # 2 times (30µs+0s) by Role::Tiny::_install_subs at line 129, avg 15µs/call
sub _gen_subs {
13621µs my ($me, $target) = @_;
137 (
138 (map {;
13964µ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;
145611µ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 },
155217µs );
156}
157
158
# spent 18µs within Role::Tiny::role_application_steps which was called 12 times, avg 2µs/call: # 10 times (16µ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
sub role_application_steps {
1591225µs qw(
160 _install_methods
161 _check_requires
162 _install_modifiers
163 _copy_applied_list
164 );
165}
166
167
# spent 49µs within Role::Tiny::_copy_applied_list which was called 12 times, avg 4µs/call: # 12 times (49µs+0s) by Role::Tiny::apply_roles_to_package at line 312, avg 4µs/call
sub _copy_applied_list {
168128µs my ($me, $to, $role) = @_;
169 # copy our role list into the target's
1701275µs @{$APPLIED_TO{$to}||={}}{keys %{$APPLIED_TO{$role}}} = ();
171}
172
173
# spent 4.55ms (59µs+4.49) within Role::Tiny::apply_roles_to_object which was called 7 times, avg 650µs/call: # 7 times (59µs+4.49ms) by Moo::Role::apply_roles_to_object at line 376 of Moo/Role.pm, avg 650µs/call
sub apply_roles_to_object {
17473µs my ($me, $object, @roles) = @_;
175713µ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
178750µs74.49ms bless($_[1], $me->create_class_with_roles($class, @roles));
# spent 4.49ms making 7 calls to Role::Tiny::create_class_with_roles, avg 641µs/call
179}
180
18110smy $role_suffix = 'A000';
182
# spent 35µs within Role::Tiny::_composite_name which was called 7 times, avg 5µs/call: # 7 times (35µs+0s) by Role::Tiny::create_class_with_roles at line 203, avg 5µs/call
sub _composite_name {
18373µs my ($me, $superclass, @roles) = @_;
184
185713µs my $new_name = $superclass . '__WITH__' . join '__AND__', @roles;
186
18776µ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 }
194719µs return $new_name;
195}
196
197
# spent 4.49ms (89µs+4.40) within Role::Tiny::create_class_with_roles which was called 7 times, avg 641µs/call: # 7 times (89µs+4.40ms) by Role::Tiny::apply_roles_to_object at line 178, avg 641µs/call
sub create_class_with_roles {
19874µs my ($me, $superclass, @roles) = @_;
199
200713µs7153µs $me->_require_module($superclass);
# spent 153µs making 7 calls to Moo::Role::_require_module, avg 22µs/call
201713µs72.47ms $me->_check_roles(@roles);
# spent 2.47ms making 7 calls to Role::Tiny::_check_roles, avg 352µs/call
202
203720µs735µs my $new_name = $me->_composite_name($superclass, @roles);
# spent 35µs making 7 calls to Role::Tiny::_composite_name, avg 5µs/call
204
205 return $new_name
206722µs if $COMPOSED{class}{$new_name};
207
20817µs11.75ms return $me->_build_class_with_roles($new_name, $superclass, @roles);
# spent 1.75ms making 1 call to Moo::Role::_build_class_with_roles
209}
210
211
# spent 1.68ms (28µs+1.66) within Role::Tiny::_build_class_with_roles which was called: # once (28µs+1.66ms) by Moo::Role::_build_class_with_roles at line 301 of Moo/Role.pm
sub _build_class_with_roles {
21211µs my ($me, $new_name, $superclass, @roles) = @_;
213
21411µs $COMPOSED{base}{$new_name} = $superclass;
215111µs110µs @{*{_getglob("${new_name}::ISA")}} = ( $superclass );
# spent 10µs making 1 call to Role::Tiny::_getglob
21614µs11.65ms $me->apply_roles_to_package($new_name, @roles);
# spent 1.65ms making 1 call to Role::Tiny::apply_roles_to_package
21712µs $COMPOSED{class}{$new_name} = 1;
21814µs return $new_name;
219}
220
221
# spent 13.1ms (220µs+12.8) within Role::Tiny::_check_roles which was called 19 times, avg 688µs/call: # 12 times (137µs+10.5ms) by Role::Tiny::apply_roles_to_package at line 268, avg 883µs/call # 7 times (83µs+2.38ms) by Role::Tiny::create_class_with_roles at line 201, avg 352µs/call
sub _check_roles {
2221914µs my ($me, @roles) = @_;
223194µs croak "No roles supplied!" unless @roles;
224
225196µs my %seen;
2261941µs if (my @dupes = grep 1 == $seen{$_}++, @roles) {
227 croak "Duplicated roles: ".join(', ', @dupes);
228 }
229
2301960µs foreach my $role (@roles) {
2311923µs1912.5ms $me->_require_module($role);
# spent 7.36ms making 17 calls to Moo::Role::_require_module, avg 433µs/call # spent 5.15ms making 2 calls to Role::Tiny::_require_module, avg 2.58ms/call
2321952µs19339µs croak "${role} is not a ${me}" unless $me->is_role($role);
# spent 329µs making 17 calls to Moo::Role::is_role, avg 19µs/call # spent 10µs making 2 calls to Role::Tiny::is_role, avg 5µs/call
233 }
234}
235
236our %BACKCOMPAT_HACK;
23711µs$BACKCOMPAT_HACK{+__PACKAGE__} = 0;
238
# spent 65µs (62+3) within Role::Tiny::_want_backcompat_hack which was called 12 times, avg 5µs/call: # 12 times (62µs+3µs) by Role::Tiny::apply_roles_to_package at line 293, avg 5µs/call
sub _want_backcompat_hack {
239123µs my $me = shift;
240 return $BACKCOMPAT_HACK{$me}
2411224µs if exists $BACKCOMPAT_HACK{$me};
24221.94ms2135µs
# spent 74µs (13+61) within Role::Tiny::BEGIN@242 which was called: # once (13µs+61µs) by Mojo::Base::BEGIN@17 at line 242
no warnings 'uninitialized';
# spent 74µs making 1 call to Role::Tiny::BEGIN@242 # spent 61µs making 1 call to warnings::unimport
243150µs13µs $BACKCOMPAT_HACK{$me} =
# spent 3µ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
248our $IN_APPLY_ROLES;
249sub 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
258sub apply_role_to_package {
259 my ($me, $to, $role) = @_;
260 $me->apply_roles_to_package($to, $role);
261}
262
263
# spent 16.6ms (493µs+16.1) within Role::Tiny::apply_roles_to_package which was called 12 times, avg 1.38ms/call: # 9 times (319µs+8.55ms) by Moo::with at line 104 of Moo.pm, avg 986µs/call # 2 times (61µs+5.98ms) by Role::Tiny::With::with at line 16 of Role/Tiny/With.pm, avg 3.02ms/call # once (113µs+1.53ms) by Role::Tiny::_build_class_with_roles at line 216
sub apply_roles_to_package {
2641225µs my ($me, $to, @roles) = @_;
265125µs croak "Can't apply roles to object with apply_roles_to_package"
266 if ref $to;
267
2681230µs1210.6ms $me->_check_roles(@roles);
# spent 10.6ms making 12 calls to Role::Tiny::_check_roles, avg 883µs/call
269
270124µs my @have_conflicts;
271 my %role_methods;
272
273127µ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
2931220µs1265µs if (!$IN_APPLY_ROLES and _want_backcompat_hack($me)) {
# spent 65µs making 12 calls to Role::Tiny::_want_backcompat_hack, avg 5µ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
300124µs my $role_methods;
3011229µs1259µs foreach my $step ($me->role_application_steps) {
# spent 57µs making 10 calls to Moo::Role::role_application_steps, avg 6µs/call # spent 2µs making 2 calls to Role::Tiny::role_application_steps, avg 1µs/call
3027836µ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}),
3097813µs (delete @{$role_methods}{@have_conflicts}),
310 );
311
31278179µs785.34ms $me->$step($to, $role);
# spent 3.15ms making 12 calls to Role::Tiny::_install_methods, avg 262µs/call # spent 893µs making 12 calls to Role::Tiny::_install_modifiers, avg 74µs/call # spent 715µs making 10 calls to Moo::Role::_undefer_subs, avg 72µs/call # spent 385µs making 10 calls to Moo::Role::_maybe_make_accessors, avg 38µs/call # spent 90µs making 12 calls to Role::Tiny::_check_requires, avg 8µs/call # spent 57µs making 10 calls to Moo::Role::_handle_constructor, avg 6µs/call # spent 49µs making 12 calls to Role::Tiny::_copy_applied_list, avg 4µs/call
313 }
314 }
3151248µs $APPLIED_TO{$to}{join('|',@roles)} = 1;
316}
317
318sub _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 90µs (76+14) within Role::Tiny::_check_requires which was called 12 times, avg 8µs/call: # 12 times (76µs+14µs) by Role::Tiny::apply_roles_to_package at line 312, avg 8µs/call
sub _check_requires {
332129µs my ($me, $to, $name, $requires) = @_;
3331216µs $requires ||= $INFO{$name}{requires} || [];
3341271µs1814µs if (my @requires_fail = grep !$to->can($_), @$requires) {
# spent 14µs making 18 calls to UNIVERSAL::can, avg 778ns/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 78µs within Role::Tiny::_non_methods which was called 8 times, avg 10µs/call: # 4 times (56µs+0s) by Moo::Role::_non_methods at line 148 of Moo/Role.pm, avg 14µs/call # 2 times (16µs+0s) by Role::Tiny::_concrete_methods_of at line 373, avg 8µs/call # 2 times (6µs+0s) by Role::Tiny::import at line 86, avg 3µs/call
sub _non_methods {
34581µs my ($me, $role) = @_;
346840µs my $info = $INFO{$role} or return {};
347
348417µ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
35249µs my %not_methods = reverse %{ $info->{not_methods} || {} };
353420µ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 648µs (118+530) within Role::Tiny::_concrete_methods_of which was called 12 times, avg 54µs/call: # 12 times (118µs+530µs) by Role::Tiny::_install_methods at line 398, avg 54µs/call
sub _concrete_methods_of {
367128µs my ($me, $role) = @_;
368126µs my $info = $INFO{$role};
369
370 return $info->{methods}
3711216µs if $info && $info->{methods};
372
373419µs4272µs my $non_methods = $me->_non_methods($role);
# spent 256µs making 2 calls to Moo::Role::_non_methods, avg 128µs/call # spent 16µs making 2 calls to Role::Tiny::_non_methods, avg 8µs/call
374
37548µs4258µs my $subs = $me->_all_subs($role);
# spent 258µs making 4 calls to Role::Tiny::_all_subs, avg 64µs/call
37649µs for my $sub (keys %$subs) {
3778430µs if ( exists $non_methods->{$sub} && $non_methods->{$sub} == $subs->{$sub} ) {
378 delete $subs->{$sub};
379 }
380 }
381
38244µs if ($info) {
383 $info->{methods} = $subs;
384 }
385413µs return $subs;
386}
387
388sub 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 3.15ms (668µs+2.48) within Role::Tiny::_install_methods which was called 12 times, avg 262µs/call: # 12 times (668µs+2.48ms) by Role::Tiny::apply_roles_to_package at line 312, avg 262µs/call
sub _install_methods {
396126µs my ($me, $to, $role) = @_;
397
3981220µs12648µs my $methods = $me->_concrete_methods_of($role);
# spent 648µs making 12 calls to Role::Tiny::_concrete_methods_of, avg 54µs/call
399
400122µs my %existing_methods;
4011269µs12704µs @existing_methods{keys %{ $me->_all_subs($to) }} = ();
# spent 704µs making 12 calls to Role::Tiny::_all_subs, avg 59µs/call
402
403 # _concrete_methods_of caches its result on roles. that cache needs to be
404 # invalidated after applying roles
405127µs delete $INFO{$to}{methods} if $INFO{$to};
406
4071248µs foreach my $i (keys %$methods) {
408 next
40913148µs if exists $existing_methods{$i};
410
411123122µs123256µs my $glob = _getglob "${to}::${i}";
# spent 256µs making 123 calls to Role::Tiny::_getglob, avg 2µs/call
41212348µ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)
419123184µs12325µs || (defined &overload::_nil && $methods->{$i} == \&overload::_nil));
# spent 25µs making 123 calls to Role::Tiny::CORE:match, avg 203ns/call
420
421 my $overload = ${ _getglob "${role}::${i}" };
422 next
423 unless defined $overload;
424
425 *$glob = \$overload;
426 }
427
4281255µs12848µs $me->_install_does($to);
# spent 766µs making 10 calls to Moo::Role::_install_does, avg 77µs/call # spent 82µs making 2 calls to Role::Tiny::_install_does, avg 41µs/call
429}
430
431
# spent 893µs (44+849) within Role::Tiny::_install_modifiers which was called 12 times, avg 74µs/call: # 12 times (44µs+849µs) by Role::Tiny::apply_roles_to_package at line 312, avg 74µs/call
sub _install_modifiers {
432128µs my ($me, $to, $name) = @_;
4331225µs return unless my $modifiers = $INFO{$name}{modifiers};
43411µs my $info = $INFO{$to};
43512µs my $existing = ($info ? $info->{modifiers} : $COMPOSED{modifiers}{$to}) ||= [];
436 my @modifiers = grep {
43721µs my $modifier = $_;
43820s !grep $_ == $modifier, @$existing;
43912µs } @{$modifiers||[]};
44011µs push @$existing, @modifiers;
441
44217µs if (!$info) {
443 foreach my $modifier (@modifiers) {
44426µs2849µs $me->_install_single_modifier($to, @$modifier);
# spent 849µs making 2 calls to Moo::Role::_install_single_modifier, avg 424µs/call
445 }
446 }
447}
448
44910smy $vcheck_error;
450
451sub _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
46515µsmy $FALLBACK = sub { 0 };
466
# spent 618µs (345+273) within Role::Tiny::_install_does which was called 12 times, avg 52µs/call: # 10 times (288µs+248µs) by Moo::Role::_install_does at line 400 of Moo/Role.pm, avg 54µs/call # 2 times (57µs+25µs) by Role::Tiny::_install_methods at line 428, avg 41µs/call
sub _install_does {
4671241µs my ($me, $to) = @_;
468
469 # only add does() method to classes
4701211µs12182µs return if $me->is_role($to);
# spent 179µs making 10 calls to Moo::Role::is_role, avg 18µs/call # spent 3µs making 2 calls to Role::Tiny::is_role, avg 2µs/call
471
4721274µs1212µs my $does = $me->can('does_role');
# spent 12µs making 12 calls to UNIVERSAL::can, avg 1µs/call
473 # add does() only if they don't have one
4741283µs1425µs *{_getglob "${to}::does"} = $does unless $to->can('does');
# spent 23µs making 12 calls to UNIVERSAL::can, avg 2µs/call # spent 2µs making 2 calls to Role::Tiny::_getglob, avg 1µs/call
475
476 return
4771287µs3632µs if $to->can('DOES') and $to->can('DOES') != (UNIVERSAL->can('DOES') || 0);
# spent 32µs making 36 calls to UNIVERSAL::can, avg 889ns/call
478
4791234µs127µs my $existing = $to->can('DOES') || $to->can('isa') || $FALLBACK;
# spent 7µs making 12 calls to UNIVERSAL::can, avg 583ns/call
480
# spent 604µs (217+387) within JSON::Schema::Modern::Vocabulary::MetaData::DOES which was called 79 times, avg 8µs/call: # 36 times (114µs+212µ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+99µ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 (32µs+56µ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 (10µs+14µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 8µs/call # 2 times (3µs+6µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 4µs/call # spent 640µs (259+381) within JSON::Schema::Modern::Vocabulary::Validation::DOES which was called 79 times, avg 8µs/call: # 36 times (147µs+176µ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 (59µs+129µ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 (40µs+57µ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 (8µs+14µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 7µs/call # 2 times (5µs+5µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 5µs/call # spent 639µs (278+361) within JSON::Schema::Modern::Vocabulary::Content::DOES which was called 79 times, avg 8µs/call: # 36 times (117µs+177µ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 (82µs+94µ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 (60µs+54µ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 (14µs+23µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 12µs/call # 2 times (5µs+13µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3], avg 9µs/call # spent 597µs (241+356) within JSON::Schema::Modern::Vocabulary::Applicator::DOES which was called 79 times, avg 8µs/call: # 36 times (144µs+172µ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 (52µs+98µ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 6µs/call # 14 times (32µs+60µ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 (8µs+19µ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 (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 583µs (257+326) within JSON::Schema::Modern::Vocabulary::FormatAnnotation::DOES which was called 79 times, avg 7µs/call: # 36 times (162µs+155µ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 (46µs+91µ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 6µs/call # 14 times (32µs+49µ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 (13µs+23µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 12µs/call # 2 times (4µ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 37µs (15+22) within JSON::Schema::Modern::Vocabulary::OpenAPI::DOES which was called 5 times, avg 7µs/call: # 2 times (8µs+8µ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 # 2 times (3µs+6µ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 4µs/call # once (4µs+8µ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] # spent 1.19ms (283µs+902µs) within JSON::Schema::Modern::Vocabulary::Core::DOES which was called 79 times, avg 15µs/call: # 36 times (157µs+490µ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 18µs/call # 24 times (64µs+221µ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 12µs/call # 14 times (48µs+128µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 13µs/call # 3 times (10µs+29µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3], avg 13µ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 547µs (175+372) within JSON::Schema::Modern::Vocabulary::Unevaluated::DOES which was called 76 times, avg 7µs/call: # 36 times (96µs+153µ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 (43µs+153µ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 (28µs+57µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 303)[Sub/Quote.pm:3], avg 6µs/call # once (4µs+6µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 364)[Sub/Quote.pm:3] # once (4µs+3µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3] # spent 8µs (4+4) within JSON::Schema::Modern::Vocabulary::FormatAssertion::DOES which was called: # once (4µs+4µs) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 359)[Sub/Quote.pm:3]
my $new_sub = sub {
481556186µs my ($proto, $role) = @_;
4825561.27ms5563.11ms $proto->$does($role) or $proto->$existing($role);
# spent 3.11ms making 556 calls to Moo::Role::does_role, avg 6µs/call
4831233µs };
4842347µs2116µs
# spent 66µs (16+50) within Role::Tiny::BEGIN@484 which was called: # once (16µs+50µs) by Mojo::Base::BEGIN@17 at line 484
no warnings 'redefine';
# spent 66µs making 1 call to Role::Tiny::BEGIN@484 # spent 50µs making 1 call to warnings::unimport
4851250µs1215µs return *{_getglob "${to}::DOES"} = $new_sub;
# spent 15µs making 12 calls to Role::Tiny::_getglob, avg 1µs/call
486}
487
488# optimize for newer perls
489require mro
49012µs if "$]" >= 5.009_005;
491
49212µsif (defined &mro::get_linear_isa) {
493 *_linear_isa = \&mro::get_linear_isa;
494}
495else {
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 = $@;
502sub _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
5221;
523END_CODE
524 }
525 die $e if defined $e;
526}
527
528
# spent 2.45ms (1.97+481µs) within Role::Tiny::does_role which was called 603 times, avg 4µs/call: # 603 times (1.97ms+481µs) by Moo::Role::does_role at line 406 of Moo/Role.pm, avg 4µs/call
sub does_role {
529603103µs my ($proto, $role) = @_;
5306031.55ms603481µs foreach my $class (@{_linear_isa(ref($proto)||$proto)}) {
# spent 481µs making 603 calls to mro::get_linear_isa, avg 798ns/call
5316101.32ms return 1 if exists $APPLIED_TO{$class}{$role};
532 }
533721µs return 0;
534}
535
536
# spent 180µs within Role::Tiny::is_role which was called 93 times, avg 2µs/call: # 34 times (86µs+0s) by Moo::Role::_inhale_if_moose at line 166 of Moo/Role.pm, avg 3µs/call # 34 times (30µs+0s) by Moo::Role::is_role at line 160 of Moo/Role.pm, avg 882ns/call # 15 times (38µs+0s) by Moo::import at line 40 of Moo.pm, avg 3µs/call # 2 times (10µs+0s) by Role::Tiny::_check_roles at line 232, avg 5µs/call # 2 times (6µs+0s) by Moo::_set_superclasses at line 149 of Moo.pm, avg 3µs/call # 2 times (4µs+0s) by Role::Tiny::_install_subs at line 128, avg 2µs/call # 2 times (3µs+0s) by Role::Tiny::_install_does at line 470, avg 2µs/call # 2 times (3µs+0s) by Role::Tiny::make_role at line 112, avg 2µs/call
sub is_role {
5379338µ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}
54593285µs ));
546}
547
548110µs1;
549__END__
 
# spent 106µs within JSON::Schema::Modern::Vocabulary::FormatAssertion::CORE:qr which was called 74 times, avg 1µs/call: # 63 times (100µs+0s) by JSON::Schema::Modern::Vocabulary::FormatAssertion::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Vocabulary/FormatAssertion.pm:132] at line 131 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 2µs/call # once (2µs+0s) by Module::Runtime::require_module at line 55 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (1µs+0s) by Module::Runtime::require_module at line 61 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (1µs+0s) by Module::Runtime::require_module at line 64 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (1µs+0s) by Module::Runtime::require_module at line 60 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (1µs+0s) by Module::Runtime::require_module at line 65 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (0s+0s) by Module::Runtime::require_module at line 56 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (0s+0s) by Module::Runtime::require_module at line 63 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (0s+0s) by Module::Runtime::require_module at line 58 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (0s+0s) by Module::Runtime::require_module at line 62 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (0s+0s) by Module::Runtime::require_module at line 59 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (0s+0s) by Module::Runtime::require_module at line 57 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm
sub JSON::Schema::Modern::Vocabulary::FormatAssertion::CORE:qr; # opcode
# spent 5.26ms within JSON::Schema::Modern::Vocabulary::FormatAssertion::CORE:regcomp which was called 73 times, avg 72µs/call: # 63 times (5.07ms+0s) by JSON::Schema::Modern::Vocabulary::FormatAssertion::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Vocabulary/FormatAssertion.pm:132] at line 131 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 80µs/call # once (48µs+0s) by Module::Runtime::require_module at line 65 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (38µs+0s) by Module::Runtime::require_module at line 58 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (23µs+0s) by Module::Runtime::require_module at line 59 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (21µs+0s) by Module::Runtime::require_module at line 64 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (19µs+0s) by Module::Runtime::require_module at line 56 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (15µs+0s) by Module::Runtime::require_module at line 62 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (7µs+0s) by Module::Runtime::require_module at line 60 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (7µs+0s) by Module::Runtime::require_module at line 57 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (6µs+0s) by Module::Runtime::require_module at line 61 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm # once (6µs+0s) by Module::Runtime::require_module at line 63 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm
sub JSON::Schema::Modern::Vocabulary::FormatAssertion::CORE:regcomp; # opcode
# spent 111µs within Role::Tiny::CORE:match which was called 567 times, avg 196ns/call: # 420 times (83µs+0s) by Role::Tiny::_all_subs at line 75, avg 198ns/call # 123 times (25µs+0s) by Role::Tiny::_install_methods at line 419, avg 203ns/call # 24 times (3µs+0s) by Role::Tiny::make_role at line 116, avg 125ns/call
sub Role::Tiny::CORE:match; # opcode
# 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
sub Role::Tiny::CORE:sort; # opcode
# 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
sub Role::Tiny::CORE:subst; # opcode