Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Util.pm |
Statements | Executed 1476 statements in 8.42ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
47 | 2 | 1 | 7.46ms | 125ms | _try_load_one_class (recurses: max depth 2, inclusive time 12.1ms) | Mouse::Util::
139 | 2 | 2 | 1.61ms | 5.82ms | does_role | Mouse::Util::
1 | 1 | 1 | 916µs | 1.50ms | BEGIN@81 | Mouse::Util::
11 | 3 | 3 | 693µs | 97.4ms | apply_all_roles (recurses: max depth 2, inclusive time 19.4ms) | Mouse::Util::
45 | 3 | 1 | 613µs | 613µs | install_subroutines | Mouse::Util::
260 | 1 | 1 | 524µs | 524µs | get_code_ref (xsub) | Mouse::Util::
44 | 4 | 2 | 434µs | 125ms | load_class (recurses: max depth 2, inclusive time 12.2ms) | Mouse::Util::
136 | 5 | 3 | 386µs | 386µs | does | Mouse::Util::
1 | 1 | 1 | 346µs | 585µs | BEGIN@128 | Mouse::Util::
28 | 2 | 1 | 281µs | 387µs | resolve_metaclass_alias | Mouse::Util::
1 | 1 | 1 | 215µs | 1.57ms | BEGIN@20 | Mouse::Util::
118 | 2 | 1 | 172µs | 172µs | is_a_type_constraint (xsub) | Mouse::Util::
47 | 1 | 1 | 154µs | 154µs | is_class_loaded (xsub) | Mouse::Util::
51 | 4 | 4 | 105µs | 105µs | is_a_metarole (xsub) | Mouse::Util::
52 | 1 | 1 | 83µs | 83µs | get_code_package (xsub) | Mouse::Util::
47 | 1 | 1 | 82µs | 82µs | is_valid_class_name (xsub) | Mouse::Util::
12 | 2 | 1 | 62µs | 62µs | CORE:subst (opcode) | Mouse::Util::
12 | 1 | 1 | 55µs | 55µs | generate_isa_predicate_for (xsub) | Mouse::Util::
17 | 1 | 1 | 55µs | 55µs | is_a_metaclass (xsub) | Mouse::Util::
6 | 2 | 2 | 45µs | 132µs | meta | Mouse::Util::
3 | 1 | 1 | 42µs | 87µs | load_first_existing_class | Mouse::Util::
1 | 1 | 1 | 29µs | 42µs | BEGIN@2 | Mouse::Util::
3 | 3 | 1 | 23µs | 23µs | generate_can_predicate_for (xsub) | Mouse::Util::
1 | 1 | 1 | 13µs | 38µs | BEGIN@142 | Mouse::Util::
1 | 1 | 1 | 12µs | 42µs | BEGIN@13 | Mouse::Util::
1 | 1 | 1 | 12µs | 58µs | BEGIN@14 | Mouse::Util::
1 | 1 | 1 | 11µs | 34µs | BEGIN@12 | Mouse::Util::
4 | 1 | 1 | 9µs | 9µs | get_code_info (xsub) | Mouse::Util::
1 | 1 | 1 | 7µs | 7µs | BEGIN@80 | Mouse::Util::
1 | 1 | 1 | 4µs | 4µs | END | Mouse::Util::
1 | 1 | 1 | 2µs | 2µs | __register_metaclass_storage (xsub) | Mouse::Util::
0 | 0 | 0 | 0s | 0s | __ANON__[:151] | Mouse::Util::
0 | 0 | 0 | 0s | 0s | __ANON__[:175] | Mouse::Util::
0 | 0 | 0 | 0s | 0s | __ANON__[:77] | Mouse::Util::
0 | 0 | 0 | 0s | 0s | dump | Mouse::Util::
0 | 0 | 0 | 0s | 0s | english_list | Mouse::Util::
0 | 0 | 0 | 0s | 0s | find_meta | Mouse::Util::
0 | 0 | 0 | 0s | 0s | not_supported | Mouse::Util::
0 | 0 | 0 | 0s | 0s | quoted_english_list | Mouse::Util::
0 | 0 | 0 | 0s | 0s | throw_error | Mouse::Util::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Mouse::Util; | ||||
2 | 2 | 60µs | 2 | 55µs | # spent 42µs (29+13) within Mouse::Util::BEGIN@2 which was called:
# once (29µs+13µs) by Mouse::BEGIN@4 at line 2 # spent 42µs making 1 call to Mouse::Util::BEGIN@2
# spent 13µs making 1 call to Mouse::Exporter::import |
3 | |||||
4 | # must be here because it will be refered by other modules loaded | ||||
5 | sub get_linear_isa($;$); ## no critic | ||||
6 | |||||
7 | # must be here because it will called in Mouse::Exporter | ||||
8 | # spent 613µs within Mouse::Util::install_subroutines which was called 45 times, avg 14µs/call:
# 28 times (422µs+0s) by Mouse::Exporter::do_import at line 216 of Mouse/Exporter.pm, avg 15µs/call
# 12 times (102µs+0s) by Mouse::Exporter::do_import at line 213 of Mouse/Exporter.pm, avg 9µs/call
# 5 times (90µs+0s) by Mouse::Exporter::setup_import_methods at line 48 of Mouse/Exporter.pm, avg 18µs/call | ||||
9 | 3 | 20µs | my $into = shift; | ||
10 | |||||
11 | 4 | 19µs | while(my($name, $code) = splice @_, 0, 2){ | ||
12 | 2 | 28µs | 2 | 57µs | # spent 34µs (11+23) within Mouse::Util::BEGIN@12 which was called:
# once (11µs+23µs) by Mouse::BEGIN@4 at line 12 # spent 34µs making 1 call to Mouse::Util::BEGIN@12
# spent 23µs making 1 call to strict::unimport |
13 | 2 | 29µs | 2 | 72µs | # spent 42µs (12+30) within Mouse::Util::BEGIN@13 which was called:
# once (12µs+30µs) by Mouse::BEGIN@4 at line 13 # spent 42µs making 1 call to Mouse::Util::BEGIN@13
# spent 30µs making 1 call to warnings::unimport |
14 | 2 | 220µs | 2 | 104µs | # spent 58µs (12+46) within Mouse::Util::BEGIN@14 which was called:
# once (12µs+46µs) by Mouse::BEGIN@4 at line 14 # spent 58µs making 1 call to Mouse::Util::BEGIN@14
# spent 46µs making 1 call to warnings::import |
15 | *{$into . '::' . $name} = \&{$code}; | ||||
16 | } | ||||
17 | return; | ||||
18 | } | ||||
19 | |||||
20 | # spent 1.57ms (215µs+1.36) within Mouse::Util::BEGIN@20 which was called:
# once (215µs+1.36ms) by Mouse::BEGIN@4 at line 78 | ||||
21 | # This is used in Mouse::PurePerl | ||||
22 | 6 | 29µs | 1 | 405µs | Mouse::Exporter->setup_import_methods( # spent 405µs making 1 call to Mouse::Exporter::setup_import_methods |
23 | as_is => [qw( | ||||
24 | find_meta | ||||
25 | does_role | ||||
26 | resolve_metaclass_alias | ||||
27 | apply_all_roles | ||||
28 | english_list | ||||
29 | |||||
30 | load_class | ||||
31 | is_class_loaded | ||||
32 | |||||
33 | get_linear_isa | ||||
34 | get_code_info | ||||
35 | |||||
36 | get_code_package | ||||
37 | get_code_ref | ||||
38 | |||||
39 | not_supported | ||||
40 | |||||
41 | does meta throw_error dump | ||||
42 | )], | ||||
43 | groups => { | ||||
44 | default => [], # export no functions by default | ||||
45 | |||||
46 | # The ':meta' group is 'use metaclass' for Mouse | ||||
47 | meta => [qw(does meta dump throw_error)], | ||||
48 | }, | ||||
49 | ); | ||||
50 | |||||
51 | our $VERSION = '0.80'; | ||||
52 | |||||
53 | my $xs = !(defined(&is_valid_class_name) || $ENV{MOUSE_PUREPERL} || $ENV{PERL_ONLY}); | ||||
54 | |||||
55 | # Because Mouse::Util is loaded first in all the Mouse sub-modules, | ||||
56 | # XSLoader must be placed here, not in Mouse.pm. | ||||
57 | 3 | 133µs | if($xs){ | ||
58 | # XXX: XSLoader tries to get the object path from caller's file name | ||||
59 | # $hack_mouse_file fools its mechanism | ||||
60 | 1 | 12µs | (my $hack_mouse_file = __FILE__) =~ s/.Util//; # .../Mouse/Util.pm -> .../Mouse.pm # spent 12µs making 1 call to Mouse::Util::CORE:subst | ||
61 | $xs = eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . q{ | ||||
62 | local $^W = 0; # workaround 'redefine' warning to &install_subroutines | ||||
63 | require XSLoader; | ||||
64 | XSLoader::load('Mouse', $VERSION); | ||||
65 | Mouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta'); | ||||
66 | Mouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS' }, ':meta'); | ||||
67 | Mouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS' }, ':meta'); | ||||
68 | return 1; | ||||
69 | } || 0; | ||||
70 | warn $@ if $@ && $ENV{MOUSE_XS}; | ||||
71 | } | ||||
72 | |||||
73 | if(!$xs){ | ||||
74 | require 'Mouse/PurePerl.pm'; # we don't want to create its namespace | ||||
75 | } | ||||
76 | |||||
77 | *MOUSE_XS = sub(){ $xs }; | ||||
78 | 1 | 30µs | 1 | 1.57ms | } # spent 1.57ms making 1 call to Mouse::Util::BEGIN@20 |
79 | |||||
80 | 2 | 29µs | 1 | 7µs | # spent 7µs within Mouse::Util::BEGIN@80 which was called:
# once (7µs+0s) by Mouse::BEGIN@4 at line 80 # spent 7µs making 1 call to Mouse::Util::BEGIN@80 |
81 | 2 | 408µs | 1 | 1.50ms | # spent 1.50ms (916µs+580µs) within Mouse::Util::BEGIN@81 which was called:
# once (916µs+580µs) by Mouse::BEGIN@4 at line 81 # spent 1.50ms making 1 call to Mouse::Util::BEGIN@81 |
82 | |||||
83 | # aliases as public APIs | ||||
84 | # it must be 'require', not 'use', because Mouse::Meta::Module depends on Mouse::Util | ||||
85 | 1 | 268µs | require Mouse::Meta::Module; # for the entities of metaclass cache utilities | ||
86 | |||||
87 | # aliases | ||||
88 | { | ||||
89 | 10 | 49µs | *class_of = \&Mouse::Meta::Module::_class_of; | ||
90 | *get_metaclass_by_name = \&Mouse::Meta::Module::_get_metaclass_by_name; | ||||
91 | *get_all_metaclass_instances = \&Mouse::Meta::Module::_get_all_metaclass_instances; | ||||
92 | *get_all_metaclass_names = \&Mouse::Meta::Module::_get_all_metaclass_names; | ||||
93 | |||||
94 | *Mouse::load_class = \&load_class; | ||||
95 | *Mouse::is_class_loaded = \&is_class_loaded; | ||||
96 | |||||
97 | # is-a predicates | ||||
98 | #generate_isa_predicate_for('Mouse::Meta::TypeConstraint' => 'is_a_type_constraint'); | ||||
99 | #generate_isa_predicate_for('Mouse::Meta::Class' => 'is_a_metaclass'); | ||||
100 | #generate_isa_predicate_for('Mouse::Meta::Role' => 'is_a_metarole'); | ||||
101 | |||||
102 | # duck type predicates | ||||
103 | 1 | 16µs | generate_can_predicate_for(['_compiled_type_constraint'] => 'is_a_type_constraint'); # spent 16µs making 1 call to Mouse::Util::generate_can_predicate_for | ||
104 | 1 | 4µs | generate_can_predicate_for(['create_anon_class'] => 'is_a_metaclass'); # spent 4µs making 1 call to Mouse::Util::generate_can_predicate_for | ||
105 | 1 | 3µs | generate_can_predicate_for(['create_anon_role'] => 'is_a_metarole'); # spent 3µs making 1 call to Mouse::Util::generate_can_predicate_for | ||
106 | } | ||||
107 | |||||
108 | 1 | 1µs | our $in_global_destruction = 0; | ||
109 | 1 | 5µs | # spent 4µs within Mouse::Util::END which was called:
# once (4µs+0s) by main::RUNTIME at line 0 of bin/hailo | ||
110 | |||||
111 | # Moose::Util compatible utilities | ||||
112 | |||||
113 | sub find_meta{ | ||||
114 | return class_of( $_[0] ); | ||||
115 | } | ||||
116 | |||||
117 | # spent 5.82ms (1.61+4.21) within Mouse::Util::does_role which was called 139 times, avg 42µs/call:
# 136 times (1.56ms+3.95ms) by Mouse::Meta::Attribute::interpolate_class or MouseX::Getopt::Basic::_compute_getopt_attrs or MouseX::Getopt::Basic::_get_cmd_flags_for_attr or MouseX::Getopt::Dashes::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/MouseX/Getopt/Dashes.pm:24] at line 379, avg 40µs/call
# 3 times (51µs+258µs) by Mouse::Util::TypeConstraints::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Util/TypeConstraints.pm:217] at line 215 of Mouse/Util/TypeConstraints.pm, avg 103µs/call | ||||
118 | 556 | 1.54ms | my ($class_or_obj, $role_name) = @_; | ||
119 | |||||
120 | 139 | 740µs | my $meta = class_of($class_or_obj); # spent 740µs making 139 calls to Mouse::Meta::Module::_class_of, avg 5µs/call | ||
121 | |||||
122 | (defined $role_name) | ||||
123 | || ($meta || 'Mouse::Meta::Class')->throw_error("You must supply a role name to does()"); | ||||
124 | |||||
125 | 81 | 3.47ms | return defined($meta) && $meta->does_role($role_name); # spent 3.47ms making 81 calls to Mouse::Meta::Class::does_role, avg 43µs/call | ||
126 | } | ||||
127 | |||||
128 | # spent 585µs (346+239) within Mouse::Util::BEGIN@128 which was called:
# once (346µs+239µs) by Mouse::BEGIN@4 at line 179 | ||||
129 | 3 | 12µs | my $get_linear_isa; | ||
130 | 2 | 153µs | if ($] >= 5.009_005) { | ||
131 | require mro; | ||||
132 | $get_linear_isa = \&mro::get_linear_isa; | ||||
133 | } else { | ||||
134 | # this code is based on MRO::Compat::__get_linear_isa | ||||
135 | my $_get_linear_isa_dfs; # this recurses so it isn't pretty | ||||
136 | $_get_linear_isa_dfs = sub { | ||||
137 | my($classname) = @_; | ||||
138 | |||||
139 | my @lin = ($classname); | ||||
140 | my %stored; | ||||
141 | |||||
142 | 2 | 184µs | 2 | 63µs | # spent 38µs (13+25) within Mouse::Util::BEGIN@142 which was called:
# once (13µs+25µs) by Mouse::BEGIN@4 at line 142 # spent 38µs making 1 call to Mouse::Util::BEGIN@142
# spent 25µs making 1 call to strict::unimport |
143 | foreach my $parent (@{"$classname\::ISA"}) { | ||||
144 | foreach my $p(@{ $_get_linear_isa_dfs->($parent) }) { | ||||
145 | next if exists $stored{$p}; | ||||
146 | push(@lin, $p); | ||||
147 | $stored{$p} = 1; | ||||
148 | } | ||||
149 | } | ||||
150 | return \@lin; | ||||
151 | }; | ||||
152 | |||||
153 | { | ||||
154 | package # hide from PAUSE | ||||
155 | Class::C3; | ||||
156 | our %MRO; # avoid 'once' warnings | ||||
157 | } | ||||
158 | |||||
159 | # MRO::Compat::__get_linear_isa has no prototype, so | ||||
160 | # we define a prototyped version for compatibility with core's | ||||
161 | # See also MRO::Compat::__get_linear_isa. | ||||
162 | $get_linear_isa = sub ($;$){ | ||||
163 | my($classname, $type) = @_; | ||||
164 | |||||
165 | if(!defined $type){ | ||||
166 | $type = exists $Class::C3::MRO{$classname} ? 'c3' : 'dfs'; | ||||
167 | } | ||||
168 | if($type eq 'c3'){ | ||||
169 | require Class::C3; | ||||
170 | return [Class::C3::calculateMRO($classname)]; | ||||
171 | } | ||||
172 | else{ | ||||
173 | return $_get_linear_isa_dfs->($classname); | ||||
174 | } | ||||
175 | }; | ||||
176 | } | ||||
177 | |||||
178 | *get_linear_isa = $get_linear_isa; | ||||
179 | 1 | 878µs | 1 | 585µs | } # spent 585µs making 1 call to Mouse::Util::BEGIN@128 |
180 | |||||
181 | |||||
182 | # taken from Mouse::Util (0.90) | ||||
183 | { | ||||
184 | 2 | 3µs | my %cache; | ||
185 | |||||
186 | # spent 387µs (281+106) within Mouse::Util::resolve_metaclass_alias which was called 28 times, avg 14µs/call:
# 26 times (245µs+73µs) by Mouse::Meta::Attribute::interpolate_class at line 118 of Mouse/Meta/Attribute.pm, avg 12µs/call
# 2 times (36µs+34µs) by Mouse::Meta::Attribute::interpolate_class at line 110 of Mouse/Meta/Attribute.pm, avg 35µs/call | ||||
187 | 84 | 239µs | my ( $type, $metaclass_name, %options ) = @_; | ||
188 | |||||
189 | my $cache_key = $type . q{ } . ( $options{trait} ? '-Trait' : '' ); | ||||
190 | |||||
191 | 9 | 68µs | return $cache{$cache_key}{$metaclass_name} ||= do{ | ||
192 | |||||
193 | my $possible_full_name = join '::', | ||||
194 | 'Mouse::Meta', $type, 'Custom', ($options{trait} ? 'Trait' : ()), $metaclass_name | ||||
195 | ; | ||||
196 | |||||
197 | 3 | 87µs | my $loaded_class = load_first_existing_class( # spent 87µs making 3 calls to Mouse::Util::load_first_existing_class, avg 29µs/call | ||
198 | $possible_full_name, | ||||
199 | $metaclass_name | ||||
200 | ); | ||||
201 | |||||
202 | 6 | 19µs | $loaded_class->can('register_implementation') # spent 9µs making 3 calls to UNIVERSAL::can, avg 3µs/call
# spent 4µs making 1 call to Mouse::Meta::Attribute::Custom::Trait::NoGetopt::register_implementation
# spent 4µs making 1 call to Mouse::Meta::Attribute::Custom::Trait::Getopt::register_implementation
# spent 3µs making 1 call to Mouse::Meta::Attribute::Custom::NoGetopt::register_implementation | ||
203 | ? $loaded_class->register_implementation | ||||
204 | : $loaded_class; | ||||
205 | }; | ||||
206 | } | ||||
207 | } | ||||
208 | |||||
209 | # Utilities from Class::MOP | ||||
210 | |||||
211 | sub get_code_info; | ||||
212 | sub get_code_package; | ||||
213 | |||||
214 | sub is_valid_class_name; | ||||
215 | |||||
216 | # taken from Class/MOP.pm | ||||
217 | # spent 87µs (42+46) within Mouse::Util::load_first_existing_class which was called 3 times, avg 29µs/call:
# 3 times (42µs+46µs) by Mouse::Util::resolve_metaclass_alias at line 197, avg 29µs/call | ||||
218 | 9 | 13µs | my @classes = @_ | ||
219 | or return; | ||||
220 | |||||
221 | my %exceptions; | ||||
222 | for my $class (@classes) { | ||||
223 | 6 | 15µs | 3 | 46µs | my $e = _try_load_one_class($class); # spent 46µs making 3 calls to Mouse::Util::_try_load_one_class, avg 15µs/call |
224 | |||||
225 | 3 | 14µs | if ($e) { | ||
226 | $exceptions{$class} = $e; | ||||
227 | } | ||||
228 | else { | ||||
229 | return $class; | ||||
230 | } | ||||
231 | } | ||||
232 | |||||
233 | # not found | ||||
234 | Carp::confess join( | ||||
235 | "\n", | ||||
236 | map { | ||||
237 | sprintf( "Could not load class (%s) because : %s", | ||||
238 | $_, $exceptions{$_} ) | ||||
239 | } @classes | ||||
240 | ); | ||||
241 | } | ||||
242 | |||||
243 | # taken from Class/MOP.pm | ||||
244 | sub _try_load_one_class { | ||||
245 | 174 | 891µs | my $class = shift; | ||
246 | |||||
247 | 47 | 82µs | unless ( is_valid_class_name($class) ) { # spent 82µs making 47 calls to Mouse::Util::is_valid_class_name, avg 2µs/call | ||
248 | my $display = defined($class) ? $class : 'undef'; | ||||
249 | Carp::confess "Invalid class name ($display)"; | ||||
250 | } | ||||
251 | |||||
252 | 47 | 154µs | return '' if is_class_loaded($class); # spent 154µs making 47 calls to Mouse::Util::is_class_loaded, avg 3µs/call | ||
253 | |||||
254 | 11 | 50µs | $class =~ s{::}{/}g; # spent 50µs making 11 calls to Mouse::Util::CORE:subst, avg 5µs/call | ||
255 | $class .= '.pm'; | ||||
256 | |||||
257 | 33 | 59µs | return do { | ||
258 | local $@; | ||||
259 | 11 | 1.07ms | eval { require $class }; | ||
260 | $@; | ||||
261 | }; | ||||
262 | } | ||||
263 | |||||
264 | |||||
265 | # spent 125ms (434µs+125) within Mouse::Util::load_class which was called 44 times, avg 2.85ms/call:
# 16 times (159µs+46.6ms) by Mouse::Meta::Class::superclasses at line 58 of Mouse/Meta/Class.pm, avg 2.92ms/call
# 14 times (141µs+78.1ms) by Mouse::Util::apply_all_roles at line 292, avg 5.59ms/call
# 7 times (74µs+56µs) by Mouse::Meta::Class::make_immutable at line 290 of Mouse/Meta/Class.pm, avg 19µs/call
# 7 times (61µs+48µs) by Mouse::Meta::Class::make_immutable at line 296 of Mouse/Meta/Class.pm, avg 16µs/call | ||||
266 | 176 | 427µs | my $class = shift; | ||
267 | 44 | 125ms | my $e = _try_load_one_class($class); # spent 137ms making 44 calls to Mouse::Util::_try_load_one_class, avg 3.11ms/call, recursion: max depth 2, sum of overlapping time 12.1ms | ||
268 | Carp::confess "Could not load class ($class) because : $e" if $e; | ||||
269 | |||||
270 | return $class; | ||||
271 | } | ||||
272 | |||||
273 | sub is_class_loaded; | ||||
274 | |||||
275 | # spent 97.4ms (693µs+96.7) within Mouse::Util::apply_all_roles which was called 11 times, avg 8.85ms/call:
# 6 times (430µs+47.2ms) by Mouse::with at line 40 of Mouse.pm, avg 7.94ms/call
# 3 times (167µs+49.5ms) by Mouse::Role::with at line 32 of Mouse/Role.pm, avg 16.6ms/call
# 2 times (95µs+-95µs) by Mouse::Meta::Module::create at line 265 of Mouse/Meta/Module.pm, avg 0s/call | ||||
276 | 77 | 287µs | 22 | 89µs | my $consumer = Scalar::Util::blessed($_[0]) # spent 72µs making 11 calls to Mouse::Meta::Module::initialize, avg 7µs/call
# spent 17µs making 11 calls to Scalar::Util::blessed, avg 2µs/call |
277 | ? $_[0] # instance | ||||
278 | : Mouse::Meta::Class->initialize($_[0]); # class or role name | ||||
279 | |||||
280 | my @roles; | ||||
281 | |||||
282 | # Basis of Data::OptList | ||||
283 | my $max = scalar(@_); | ||||
284 | 70 | 197µs | for (my $i = 1; $i < $max ; $i++) { | ||
285 | my $role = $_[$i]; | ||||
286 | my $role_name; | ||||
287 | 42 | 132µs | if(ref $role) { | ||
288 | $role_name = $role->name; | ||||
289 | } | ||||
290 | else { | ||||
291 | $role_name = $role; | ||||
292 | 14 | 78.2ms | load_class($role_name); # spent 90.2ms making 14 calls to Mouse::Util::load_class, avg 6.44ms/call, recursion: max depth 2, sum of overlapping time 11.9ms | ||
293 | 14 | 48µs | $role = get_metaclass_by_name($role_name); # spent 48µs making 14 calls to Mouse::Meta::Module::_get_metaclass_by_name, avg 3µs/call | ||
294 | } | ||||
295 | |||||
296 | 14 | 24µs | if ($i + 1 < $max && ref($_[$i + 1]) eq 'HASH') { | ||
297 | push @roles, [ $role => $_[++$i] ]; | ||||
298 | } else { | ||||
299 | push @roles, [ $role => undef ]; | ||||
300 | } | ||||
301 | 14 | 40µs | is_a_metarole($role) # spent 40µs making 14 calls to Mouse::Util::is_a_metarole, avg 3µs/call | ||
302 | || $consumer->meta->throw_error("You can only consume roles, $role_name is not a Mouse role"); | ||||
303 | } | ||||
304 | |||||
305 | 19 | 75µs | if ( scalar @roles == 1 ) { | ||
306 | my ( $role, $params ) = @{ $roles[0] }; | ||||
307 | 8 | 12.6ms | $role->apply( $consumer, defined $params ? $params : () ); # spent 14.0ms making 8 calls to Mouse::Meta::Role::apply, avg 1.75ms/call, recursion: max depth 1, sum of overlapping time 1.36ms | ||
308 | } | ||||
309 | else { | ||||
310 | 6 | 11.7ms | Mouse::Meta::Role->combine(@roles)->apply($consumer); # spent 6.20ms making 3 calls to Mouse::Meta::Role::combine, avg 2.07ms/call
# spent 5.53ms making 3 calls to Mouse::Meta::Role::Composite::apply, avg 1.84ms/call | ||
311 | } | ||||
312 | return; | ||||
313 | } | ||||
314 | |||||
315 | # taken from Moose::Util 0.90 | ||||
316 | sub english_list { | ||||
317 | return $_[0] if @_ == 1; | ||||
318 | |||||
319 | my @items = sort @_; | ||||
320 | |||||
321 | return "$items[0] and $items[1]" if @items == 2; | ||||
322 | |||||
323 | my $tail = pop @items; | ||||
324 | |||||
325 | return join q{, }, @items, "and $tail"; | ||||
326 | } | ||||
327 | |||||
328 | sub quoted_english_list { | ||||
329 | return english_list(map { qq{'$_'} } @_); | ||||
330 | } | ||||
331 | |||||
332 | # common utilities | ||||
333 | |||||
334 | sub not_supported{ | ||||
335 | my($feature) = @_; | ||||
336 | |||||
337 | $feature ||= ( caller(1) )[3] . '()'; # subroutine name | ||||
338 | |||||
339 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | ||||
340 | Carp::confess("Mouse does not currently support $feature"); | ||||
341 | } | ||||
342 | |||||
343 | # general meta() method | ||||
344 | # spent 132µs (45+86) within Mouse::Util::meta which was called 6 times, avg 22µs/call:
# 3 times (26µs+47µs) by Mouse::Meta::Role::_construct_meta at line 20 of Mouse/Meta/Role.pm, avg 24µs/call
# 3 times (19µs+39µs) by Mouse::Meta::Role::Application::new at line 36 of Mouse/Meta/Role/Application.pm, avg 19µs/call | ||||
345 | 6 | 48µs | 6 | 39µs | return Mouse::Meta::Class->initialize(ref($_[0]) || $_[0]); # spent 86µs making 6 calls to Mouse::Meta::Module::initialize, avg 14µs/call, recursion: max depth 1, sum of overlapping time 47µs |
346 | } | ||||
347 | |||||
348 | # general throw_error() method | ||||
349 | # $o->throw_error($msg, depth => $leve, longmess => $croak_or_confess) | ||||
350 | sub throw_error :method { | ||||
351 | my($self, $message, %args) = @_; | ||||
352 | |||||
353 | local $Carp::CarpLevel = $Carp::CarpLevel + 1 + ($args{depth} || 0); | ||||
354 | local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though | ||||
355 | |||||
356 | if(exists $args{longmess} && !$args{longmess}) { | ||||
357 | Carp::croak($message); | ||||
358 | } | ||||
359 | else{ | ||||
360 | Carp::confess($message); | ||||
361 | } | ||||
362 | } | ||||
363 | |||||
364 | # general dump() method | ||||
365 | sub dump :method { | ||||
366 | my($self, $maxdepth) = @_; | ||||
367 | |||||
368 | require 'Data/Dumper.pm'; # we don't want to create its namespace | ||||
369 | my $dd = Data::Dumper->new([$self]); | ||||
370 | $dd->Maxdepth(defined($maxdepth) ? $maxdepth : 3); | ||||
371 | $dd->Indent(1); | ||||
372 | $dd->Sortkeys(1); | ||||
373 | $dd->Quotekeys(0); | ||||
374 | return $dd->Dump(); | ||||
375 | } | ||||
376 | |||||
377 | # general does() method | ||||
378 | # spent 386µs within Mouse::Util::does which was called 136 times, avg 3µs/call:
# 38 times (104µs+0s) by MouseX::Getopt::Basic::_compute_getopt_attrs at line 170 of MouseX/Getopt/Basic.pm, avg 3µs/call
# 28 times (77µs+0s) by MouseX::Getopt::Basic::_compute_getopt_attrs at line 168 of MouseX/Getopt/Basic.pm, avg 3µs/call
# 26 times (80µs+0s) by Mouse::Meta::Attribute::interpolate_class at line 120 of Mouse/Meta/Attribute.pm, avg 3µs/call
# 22 times (63µs+0s) by MouseX::Getopt::Dashes::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/MouseX/Getopt/Dashes.pm:24] at line 19 of MouseX/Getopt/Dashes.pm, avg 3µs/call
# 22 times (63µs+0s) by MouseX::Getopt::Basic::_get_cmd_flags_for_attr at line 185 of MouseX/Getopt/Basic.pm, avg 3µs/call | ||||
379 | 136 | 754µs | 136 | 5.51ms | goto &does_role; # spent 5.51ms making 136 calls to Mouse::Util::does_role, avg 40µs/call |
380 | } | ||||
381 | |||||
382 | 1 | 10µs | 1; | ||
383 | __END__ | ||||
sub Mouse::Util::CORE:subst; # opcode | |||||
# spent 2µs within Mouse::Util::__register_metaclass_storage which was called:
# once (2µs+0s) by Mouse::BEGIN@4 at line 11 of Mouse/Meta/Module.pm | |||||
sub Mouse::Util::generate_can_predicate_for; # xsub | |||||
# spent 55µs within Mouse::Util::generate_isa_predicate_for which was called 12 times, avg 5µs/call:
# 12 times (55µs+0s) by Mouse::Util::TypeConstraints::class_type at line 200 of Mouse/Util/TypeConstraints.pm, avg 5µs/call | |||||
# spent 9µs within Mouse::Util::get_code_info which was called 4 times, avg 2µs/call:
# 4 times (9µs+0s) by Mouse::Exporter::build_import_methods at line 91 of Mouse/Exporter.pm, avg 2µs/call | |||||
# spent 83µs within Mouse::Util::get_code_package which was called 52 times, avg 2µs/call:
# 52 times (83µs+0s) by Mouse::Meta::Module::_get_method_body at line 90 of Mouse/Meta/Module.pm, avg 2µs/call | |||||
# spent 524µs within Mouse::Util::get_code_ref which was called 260 times, avg 2µs/call:
# 260 times (524µs+0s) by Mouse::Meta::Module::_get_method_body at line 89 of Mouse/Meta/Module.pm, avg 2µs/call | |||||
# spent 55µs within Mouse::Util::is_a_metaclass which was called 17 times, avg 3µs/call:
# 17 times (55µs+0s) by Mouse::Meta::Role::Application::apply at line 46 of Mouse/Meta/Role/Application.pm, avg 3µs/call | |||||
# spent 105µs within Mouse::Util::is_a_metarole which was called 51 times, avg 2µs/call:
# 26 times (39µs+0s) by Mouse::Meta::Module::create at line 178 of Mouse/Meta/Module.pm, avg 1µs/call
# 14 times (40µs+0s) by Mouse::Util::apply_all_roles at line 301, avg 3µs/call
# 9 times (13µs+0s) by Mouse::Meta::Role::Application::apply at line 46 of Mouse/Meta/Role/Application.pm, avg 1µs/call
# 2 times (13µs+0s) by Mouse::Meta::Class::verify_superclass at line 72 of Mouse/Meta/Class.pm, avg 6µs/call | |||||
# spent 172µs within Mouse::Util::is_a_type_constraint which was called 118 times, avg 1µs/call:
# 92 times (131µs+0s) by Mouse::Util::TypeConstraints::find_or_parse_type_constraint at line 394 of Mouse/Util/TypeConstraints.pm, avg 1µs/call
# 26 times (42µs+0s) by Mouse::Util::TypeConstraints::find_type_constraint at line 376 of Mouse/Util/TypeConstraints.pm, avg 2µs/call | |||||
# spent 154µs within Mouse::Util::is_class_loaded which was called 47 times, avg 3µs/call:
# 47 times (154µs+0s) by Mouse::Util::_try_load_one_class at line 252, avg 3µs/call | |||||
# spent 82µs within Mouse::Util::is_valid_class_name which was called 47 times, avg 2µs/call:
# 47 times (82µs+0s) by Mouse::Util::_try_load_one_class at line 247, avg 2µs/call |