Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Class.pm |
Statements | Executed 1099 statements in 6.41ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
36 | 2 | 2 | 1.87ms | 12.1ms | add_attribute | Mouse::Meta::Class::
6 | 4 | 4 | 459µs | 619µs | _calculate_all_attributes | Mouse::Meta::Class::
12 | 2 | 2 | 325µs | 821µs | does_role | Mouse::Meta::Class::
15 | 2 | 1 | 252µs | 21.5ms | superclasses (recurses: max depth 1, inclusive time 86µs) | Mouse::Meta::Class::
5 | 5 | 5 | 251µs | 620µs | make_immutable | Mouse::Meta::Class::
7 | 1 | 1 | 174µs | 174µs | _construct_meta | Mouse::Meta::Class::
4 | 3 | 1 | 155µs | 200µs | _install_modifier | Mouse::Meta::Class::
1 | 1 | 1 | 97µs | 389ms | _engage | Hailo::Storage::SQLite::
6 | 1 | 1 | 94µs | 122µs | verify_superclass | Mouse::Meta::Class::
6 | 2 | 2 | 72µs | 185µs | _initialize_object (xsub) | Mouse::Meta::Class::
36 | 1 | 1 | 63µs | 63µs | CORE:subst (opcode) | Mouse::Meta::Class::
36 | 1 | 1 | 59µs | 59µs | attribute_metaclass (xsub) | Mouse::Meta::Class::
2 | 1 | 1 | 57µs | 117µs | add_override_method_modifier | Mouse::Meta::Class::
7 | 1 | 1 | 52µs | 52µs | CORE:sort (opcode) | Mouse::Meta::Class::
18 | 2 | 1 | 38µs | 38µs | linearized_isa (xsub) | Mouse::Meta::Class::
1 | 1 | 1 | 33µs | 109µs | BEGIN@2 | Mouse::Meta::Class::
10 | 5 | 5 | 31µs | 31µs | strict_constructor (xsub) | Mouse::Meta::Class::
5 | 1 | 1 | 30µs | 30µs | immutable_options | Mouse::Meta::Class::
6 | 4 | 4 | 25µs | 25µs | is_anon_class (xsub) | Mouse::Meta::Class::
1 | 1 | 1 | 20µs | 881µs | initialized | Hailo::Storage::SQLite::
13 | 1 | 1 | 19µs | 19µs | roles (xsub) | Mouse::Meta::Class::
1 | 1 | 1 | 18µs | 82µs | add_around_method_modifier | Mouse::Meta::Class::
2 | 1 | 1 | 16µs | 115µs | add_before_method_modifier | Mouse::Meta::Class::
1 | 1 | 1 | 13µs | 43µs | _build_dbd_options | Hailo::Storage::SQLite::
1 | 1 | 1 | 11µs | 33µs | BEGIN@26 | Mouse::Meta::Class::
6 | 4 | 4 | 10µs | 10µs | is_immutable (xsub) | Mouse::Meta::Class::
1 | 1 | 1 | 9µs | 192µs | _build_dbi_options | Hailo::Storage::SQLite::
1 | 1 | 1 | 9µs | 47µs | add_after_method_modifier | Mouse::Meta::Class::
5 | 1 | 1 | 9µs | 9µs | constructor_class (xsub) | Mouse::Meta::Class::
5 | 1 | 1 | 8µs | 8µs | destructor_class (xsub) | Mouse::Meta::Class::
1 | 1 | 1 | 8µs | 183µs | __ANON__[:379] | Mouse::Meta::Class::
1 | 1 | 1 | 6µs | 6µs | BEGIN@6 | Mouse::Meta::Class::
1 | 1 | 1 | 6µs | 6µs | BEGIN@4 | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | start_training | Hailo::Storage::SQLite::
0 | 0 | 0 | 0s | 0s | stop_training | Hailo::Storage::SQLite::
0 | 0 | 0 | 0s | 0s | __ANON__[:354] | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | __ANON__[:417] | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | __ANON__[:437] | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | _collect_roles | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | _reconcile_with_superclass_meta | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | add_augment_method_modifier | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | calculate_all_roles | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | create_anon_class | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | find_attribute_by_name | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | find_method_by_name | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | get_all_method_names | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | get_all_methods | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | inherit_from_foreign_class | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | is_mutable | Mouse::Meta::Class::
0 | 0 | 0 | 0s | 0s | make_mutable | Mouse::Meta::Class::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Mouse::Meta::Class; | ||||
2 | 2 | 30µs | 2 | 184µs | # spent 109µs (33+76) within Mouse::Meta::Class::BEGIN@2 which was called:
# once (33µs+76µs) by Mouse::BEGIN@14 at line 2 # spent 109µs making 1 call to Mouse::Meta::Class::BEGIN@2
# spent 76µs making 1 call to Mouse::Exporter::do_import |
3 | |||||
4 | 2 | 23µs | 1 | 6µs | # spent 6µs within Mouse::Meta::Class::BEGIN@4 which was called:
# once (6µs+0s) by Mouse::BEGIN@14 at line 4 # spent 6µs making 1 call to Mouse::Meta::Class::BEGIN@4 |
5 | |||||
6 | 2 | 89µs | 1 | 6µs | # spent 6µs within Mouse::Meta::Class::BEGIN@6 which was called:
# once (6µs+0s) by Mouse::BEGIN@14 at line 6 # spent 6µs making 1 call to Mouse::Meta::Class::BEGIN@6 |
7 | 1 | 7µs | our @ISA = qw(Mouse::Meta::Module); | ||
8 | |||||
9 | 1 | 1µs | our @CARP_NOT = qw(Mouse); # trust Mouse | ||
10 | |||||
11 | sub attribute_metaclass; | ||||
12 | sub method_metaclass; | ||||
13 | |||||
14 | sub constructor_class; | ||||
15 | sub destructor_class; | ||||
16 | |||||
17 | |||||
18 | # spent 174µs within Mouse::Meta::Class::_construct_meta which was called 7 times, avg 25µs/call:
# 7 times (174µs+0s) by Mouse::Meta::Module::initialize at line 29 of Mouse/Meta/Module.pm, avg 25µs/call | ||||
19 | 7 | 16µs | my($class, %args) = @_; | ||
20 | |||||
21 | 7 | 13µs | $args{attributes} = {}; | ||
22 | 7 | 11µs | $args{methods} = {}; | ||
23 | 7 | 12µs | $args{roles} = []; | ||
24 | |||||
25 | 7 | 23µs | $args{superclasses} = do { | ||
26 | 2 | 1.94ms | 2 | 55µs | # spent 33µs (11+22) within Mouse::Meta::Class::BEGIN@26 which was called:
# once (11µs+22µs) by Mouse::BEGIN@14 at line 26 # spent 33µs making 1 call to Mouse::Meta::Class::BEGIN@26
# spent 22µs making 1 call to strict::unimport |
27 | 7 | 30µs | \@{ $args{package} . '::ISA' }; | ||
28 | }; | ||||
29 | |||||
30 | 7 | 31µs | my $self = bless \%args, ref($class) || $class; | ||
31 | 7 | 12µs | if(ref($self) ne __PACKAGE__){ | ||
32 | $self->meta->_initialize_object($self, \%args); | ||||
33 | } | ||||
34 | 7 | 37µs | return $self; | ||
35 | } | ||||
36 | |||||
37 | sub create_anon_class{ | ||||
38 | my $self = shift; | ||||
39 | return $self->create(undef, @_); | ||||
40 | } | ||||
41 | |||||
42 | sub is_anon_class; | ||||
43 | |||||
44 | sub roles; | ||||
45 | |||||
46 | sub calculate_all_roles { | ||||
47 | my $self = shift; | ||||
48 | my %seen; | ||||
49 | return grep { !$seen{ $_->name }++ } | ||||
50 | map { $_->calculate_all_roles } @{ $self->roles }; | ||||
51 | } | ||||
52 | |||||
53 | # spent 21.5ms (252µs+21.3) within Mouse::Meta::Class::superclasses which was called 15 times, avg 1.44ms/call:
# 14 times (220µs+169µs) by Mouse::init_meta at line 139 of Mouse.pm, avg 28µs/call
# once (32µs+21.1ms) by Mouse::extends at line 35 of Mouse.pm | ||||
54 | 15 | 18µs | my $self = shift; | ||
55 | |||||
56 | 15 | 20µs | if (@_) { | ||
57 | 6 | 28µs | foreach my $super(@_){ | ||
58 | 6 | 26µs | 6 | 21.2ms | Mouse::Util::load_class($super); # spent 21.2ms making 6 calls to Mouse::Util::load_class, avg 3.54ms/call, recursion: max depth 1, sum of overlapping time 26µs |
59 | 6 | 25µs | 6 | 20µs | my $meta = Mouse::Util::get_metaclass_by_name($super); # spent 20µs making 6 calls to Mouse::Meta::Module::_get_metaclass_by_name, avg 3µs/call |
60 | 6 | 30µs | 6 | 122µs | next if $self->verify_superclass($super, $meta); # spent 122µs making 6 calls to Mouse::Meta::Class::verify_superclass, avg 20µs/call |
61 | $self->_reconcile_with_superclass_meta($meta); | ||||
62 | } | ||||
63 | 6 | 69µs | return @{ $self->{superclasses} } = @_; | ||
64 | } | ||||
65 | |||||
66 | 9 | 41µs | return @{ $self->{superclasses} }; | ||
67 | } | ||||
68 | |||||
69 | # spent 122µs (94+27) within Mouse::Meta::Class::verify_superclass which was called 6 times, avg 20µs/call:
# 6 times (94µs+27µs) by Mouse::Meta::Class::superclasses at line 60, avg 20µs/call | ||||
70 | 6 | 11µs | my($self, $super, $super_meta) = @_; | ||
71 | |||||
72 | 6 | 23µs | 1 | 10µs | if(defined $super_meta) { # spent 10µs making 1 call to Mouse::Util::is_a_metarole |
73 | if(Mouse::Util::is_a_metarole($super_meta)){ | ||||
74 | $self->throw_error("You cannot inherit from a Mouse Role ($super)"); | ||||
75 | } | ||||
76 | } | ||||
77 | else { | ||||
78 | # The metaclass of $super is not initialized. | ||||
79 | # i.e. it might be Mouse::Object, a mixin package (e.g. Exporter), | ||||
80 | # or a foreign class including Moose classes. | ||||
81 | # See also Mouse::Foreign::Meta::Role::Class. | ||||
82 | 5 | 46µs | 5 | 14µs | my $mm = $super->can('meta'); # spent 14µs making 5 calls to UNIVERSAL::can, avg 3µs/call |
83 | 5 | 11µs | if(!($mm && $mm == \&Mouse::Util::meta)) { | ||
84 | if($super->can('new') or $super->can('DESTROY')) { | ||||
85 | $self->inherit_from_foreign_class($super); | ||||
86 | } | ||||
87 | } | ||||
88 | 5 | 23µs | return 1; # always ok | ||
89 | } | ||||
90 | |||||
91 | 1 | 11µs | 1 | 2µs | return $self->isa(ref $super_meta); # checks metaclass compatibility # spent 2µs making 1 call to UNIVERSAL::isa |
92 | } | ||||
93 | |||||
94 | sub inherit_from_foreign_class { | ||||
95 | my($class, $super) = @_; | ||||
96 | Carp::carp("You inherit from non-Mouse class ($super)," | ||||
97 | . " but it is unlikely to work correctly." | ||||
98 | . " Please consider using MouseX::Foreign"); | ||||
99 | return; | ||||
100 | } | ||||
101 | |||||
102 | 1 | 2µs | my @MetaClassTypes = ( | ||
103 | 'attribute', # Mouse::Meta::Attribute | ||||
104 | 'method', # Mouse::Meta::Method | ||||
105 | 'constructor', # Mouse::Meta::Method::Constructor | ||||
106 | 'destructor', # Mouse::Meta::Method::Destructor | ||||
107 | ); | ||||
108 | |||||
109 | sub _reconcile_with_superclass_meta { | ||||
110 | my($self, $other) = @_; | ||||
111 | |||||
112 | # find incompatible traits | ||||
113 | my %metaroles; | ||||
114 | foreach my $metaclass_type(@MetaClassTypes){ | ||||
115 | my $accessor = $self->can($metaclass_type . '_metaclass') | ||||
116 | || $self->can($metaclass_type . '_class'); | ||||
117 | |||||
118 | my $other_c = $other->$accessor(); | ||||
119 | my $self_c = $self->$accessor(); | ||||
120 | |||||
121 | if(!$self_c->isa($other_c)){ | ||||
122 | $metaroles{$metaclass_type} | ||||
123 | = [ $self_c->meta->_collect_roles($other_c->meta) ]; | ||||
124 | } | ||||
125 | } | ||||
126 | |||||
127 | $metaroles{class} = [$self->meta->_collect_roles($other->meta)]; | ||||
128 | |||||
129 | #use Data::Dumper; print Data::Dumper->new([\%metaroles], ['*metaroles'])->Indent(1)->Dump; | ||||
130 | |||||
131 | require Mouse::Util::MetaRole; | ||||
132 | $_[0] = Mouse::Util::MetaRole::apply_metaroles( | ||||
133 | for => $self, | ||||
134 | class_metaroles => \%metaroles, | ||||
135 | ); | ||||
136 | return; | ||||
137 | } | ||||
138 | |||||
139 | sub _collect_roles { | ||||
140 | my ($self, $other) = @_; | ||||
141 | |||||
142 | # find common ancestor | ||||
143 | my @self_lin_isa = $self->linearized_isa; | ||||
144 | my @other_lin_isa = $other->linearized_isa; | ||||
145 | |||||
146 | my(@self_anon_supers, @other_anon_supers); | ||||
147 | push @self_anon_supers, shift @self_lin_isa while $self_lin_isa[0]->meta->is_anon_class; | ||||
148 | push @other_anon_supers, shift @other_lin_isa while $other_lin_isa[0]->meta->is_anon_class; | ||||
149 | |||||
150 | my $common_ancestor = $self_lin_isa[0] eq $other_lin_isa[0] && $self_lin_isa[0]; | ||||
151 | |||||
152 | if(!$common_ancestor){ | ||||
153 | $self->throw_error(sprintf '%s cannot have %s as a super class because of their metaclass incompatibility', | ||||
154 | $self->name, $other->name); | ||||
155 | } | ||||
156 | |||||
157 | my %seen; | ||||
158 | return sort grep { !$seen{$_}++ } ## no critic | ||||
159 | (map{ $_->name } map{ $_->meta->calculate_all_roles } @self_anon_supers), | ||||
160 | (map{ $_->name } map{ $_->meta->calculate_all_roles } @other_anon_supers), | ||||
161 | ; | ||||
162 | } | ||||
163 | |||||
164 | |||||
165 | sub find_method_by_name { | ||||
166 | my($self, $method_name) = @_; | ||||
167 | defined($method_name) | ||||
168 | or $self->throw_error('You must define a method name to find'); | ||||
169 | |||||
170 | foreach my $class( $self->linearized_isa ){ | ||||
171 | my $method = $self->initialize($class)->get_method($method_name); | ||||
172 | return $method if defined $method; | ||||
173 | } | ||||
174 | return undef; | ||||
175 | } | ||||
176 | |||||
177 | sub get_all_methods { | ||||
178 | my($self) = @_; | ||||
179 | return map{ $self->find_method_by_name($_) } $self->get_all_method_names; | ||||
180 | } | ||||
181 | |||||
182 | sub get_all_method_names { | ||||
183 | my $self = shift; | ||||
184 | my %uniq; | ||||
185 | return grep { $uniq{$_}++ == 0 } | ||||
186 | map { Mouse::Meta::Class->initialize($_)->get_method_list() } | ||||
187 | $self->linearized_isa; | ||||
188 | } | ||||
189 | |||||
190 | sub find_attribute_by_name { | ||||
191 | my($self, $name) = @_; | ||||
192 | defined($name) | ||||
193 | or $self->throw_error('You must define an attribute name to find'); | ||||
194 | foreach my $attr($self->get_all_attributes) { | ||||
195 | return $attr if $attr->name eq $name; | ||||
196 | } | ||||
197 | return undef; | ||||
198 | } | ||||
199 | |||||
200 | # spent 12.1ms (1.87+10.2) within Mouse::Meta::Class::add_attribute which was called 36 times, avg 335µs/call:
# 26 times (1.33ms+6.93ms) by Mouse::has at line 52 of Mouse.pm, avg 318µs/call
# 10 times (540µs+3.25ms) by Mouse::Meta::Role::Application::apply_attributes at line 156 of Mouse/Meta/Role/Application.pm, avg 379µs/call | ||||
201 | 36 | 39µs | my $self = shift; | ||
202 | |||||
203 | 36 | 39µs | my($attr, $name); | ||
204 | |||||
205 | 36 | 237µs | 36 | 54µs | if(Scalar::Util::blessed($_[0])){ # spent 54µs making 36 calls to Scalar::Util::blessed, avg 1µs/call |
206 | $attr = $_[0]; | ||||
207 | |||||
208 | $attr->isa('Mouse::Meta::Attribute') | ||||
209 | || $self->throw_error("Your attribute must be an instance of Mouse::Meta::Attribute (or a subclass)"); | ||||
210 | |||||
211 | $name = $attr->name; | ||||
212 | } | ||||
213 | else{ | ||||
214 | # _process_attribute | ||||
215 | 36 | 43µs | $name = shift; | ||
216 | |||||
217 | 36 | 155µs | my %args = (@_ == 1) ? %{$_[0]} : @_; | ||
218 | |||||
219 | 36 | 38µs | defined($name) | ||
220 | or $self->throw_error('You must provide a name for the attribute'); | ||||
221 | |||||
222 | 36 | 247µs | 36 | 63µs | if ($name =~ s/^\+//) { # inherited attributes # spent 63µs making 36 calls to Mouse::Meta::Class::CORE:subst, avg 2µs/call |
223 | my $inherited_attr = $self->find_attribute_by_name($name) | ||||
224 | or $self->throw_error("Could not find an attribute by the name of '$name' to inherit from in ".$self->name); | ||||
225 | |||||
226 | $attr = $inherited_attr->clone_and_inherit_options(%args); | ||||
227 | } | ||||
228 | else{ | ||||
229 | 36 | 316µs | 72 | 354µs | my($attribute_class, @traits) = $self->attribute_metaclass->interpolate_class(\%args); # spent 295µs making 36 calls to Mouse::Meta::Attribute::interpolate_class, avg 8µs/call
# spent 59µs making 36 calls to Mouse::Meta::Class::attribute_metaclass, avg 2µs/call |
230 | 36 | 37µs | $args{traits} = \@traits if @traits; | ||
231 | |||||
232 | 36 | 207µs | 36 | 4.44ms | $attr = $attribute_class->new($name, %args); # spent 4.44ms making 36 calls to Mouse::Meta::Attribute::new, avg 123µs/call |
233 | } | ||||
234 | } | ||||
235 | |||||
236 | 36 | 212µs | 36 | 69µs | Scalar::Util::weaken( $attr->{associated_class} = $self ); # spent 69µs making 36 calls to Scalar::Util::weaken, avg 2µs/call |
237 | |||||
238 | # install accessors first | ||||
239 | 36 | 137µs | 36 | 5.21ms | $attr->install_accessors(); # spent 5.21ms making 36 calls to Mouse::Meta::Attribute::install_accessors, avg 145µs/call |
240 | |||||
241 | # then register the attribute to the metaclass | ||||
242 | 36 | 68µs | $attr->{insertion_order} = keys %{ $self->{attributes} }; | ||
243 | 36 | 52µs | $self->{attributes}{$name} = $attr; | ||
244 | 36 | 44µs | delete $self->{_mouse_cache}; # clears internal cache | ||
245 | |||||
246 | 36 | 43µs | if(!$attr->{associated_methods} && ($attr->{is} || '') ne 'bare'){ | ||
247 | Carp::carp(qq{Attribute ($name) of class }.$self->name | ||||
248 | .qq{ has no associated methods (did you mean to provide an "is" argument?)}); | ||||
249 | } | ||||
250 | 36 | 126µs | return $attr; | ||
251 | } | ||||
252 | |||||
253 | # spent 619µs (459+159) within Mouse::Meta::Class::_calculate_all_attributes which was called 6 times, avg 103µs/call:
# 3 times (221µs+76µs) by Mouse::Object::new at line 207 of Hailo.pm, avg 99µs/call
# once (164µs+60µs) by Mouse::Object::new at line 9 of reply.pl
# once (44µs+14µs) by Mouse::Meta::Class::_initialize_object at line 20 of Mouse/Meta/Role.pm
# once (31µs+9µs) by Mouse::Meta::Class::_initialize_object at line 36 of Mouse/Meta/Role/Application.pm | ||||
254 | 6 | 11µs | my($self) = @_; | ||
255 | 6 | 6µs | my %seen; | ||
256 | 6 | 7µs | my @all_attrs; | ||
257 | 6 | 64µs | 6 | 13µs | foreach my $class($self->linearized_isa) { # spent 13µs making 6 calls to Mouse::Meta::Class::linearized_isa, avg 2µs/call |
258 | 14 | 59µs | 14 | 42µs | my $meta = Mouse::Util::get_metaclass_by_name($class) or next; # spent 42µs making 14 calls to Mouse::Meta::Module::_get_metaclass_by_name, avg 3µs/call |
259 | 43 | 282µs | 36 | 52µs | my @attrs = grep { !$seen{$_->name}++ } values %{$meta->{attributes}}; # spent 52µs making 36 calls to Mouse::Meta::Attribute::name, avg 1µs/call |
260 | @attrs = sort { | ||||
261 | 7 | 84µs | 7 | 52µs | $b->{insertion_order} <=> $a->{insertion_order} # spent 52µs making 7 calls to Mouse::Meta::Class::CORE:sort, avg 7µs/call |
262 | } @attrs; | ||||
263 | 7 | 21µs | push @all_attrs, @attrs; | ||
264 | } | ||||
265 | 6 | 38µs | return [reverse @all_attrs]; | ||
266 | } | ||||
267 | |||||
268 | sub linearized_isa; | ||||
269 | |||||
270 | sub new_object; | ||||
271 | sub clone_object; | ||||
272 | |||||
273 | # spent 30µs within Mouse::Meta::Class::immutable_options which was called 5 times, avg 6µs/call:
# 5 times (30µs+0s) by Mouse::Meta::Class::make_immutable at line 286, avg 6µs/call | ||||
274 | 5 | 10µs | my ( $self, @args ) = @_; | ||
275 | |||||
276 | return ( | ||||
277 | 5 | 28µs | inline_constructor => 1, | ||
278 | inline_destructor => 1, | ||||
279 | constructor_name => 'new', | ||||
280 | @args, | ||||
281 | ); | ||||
282 | } | ||||
283 | |||||
284 | # spent 620µs (251+369) within Mouse::Meta::Class::make_immutable which was called 5 times, avg 124µs/call:
# once (67µs+75µs) by main::BEGIN@6 at line 349 of Hailo.pm
# once (50µs+75µs) by Mouse::Util::_try_load_one_class at line 271 of Hailo/Storage.pm
# once (47µs+75µs) by Hailo::_new_class at line 208 of Hailo/Tokenizer/Words.pm
# once (45µs+73µs) by Hailo::_new_class at line 133 of Hailo/Storage/SQLite.pm
# once (43µs+71µs) by Hailo::_new_class at line 318 of Hailo/Engine/Default.pm | ||||
285 | 5 | 7µs | my $self = shift; | ||
286 | 5 | 37µs | 5 | 30µs | my %args = $self->immutable_options(@_); # spent 30µs making 5 calls to Mouse::Meta::Class::immutable_options, avg 6µs/call |
287 | |||||
288 | 5 | 10µs | $self->{is_immutable}++; | ||
289 | |||||
290 | 5 | 131µs | 20 | 161µs | if ($args{inline_constructor}) { # spent 146µs making 5 calls to Mouse::Util::load_class, avg 29µs/call, recursion: max depth 1, sum of overlapping time 30µs
# spent 27µs making 5 calls to Mouse::Meta::Module::add_method, avg 5µs/call
# spent 9µs making 5 calls to Mouse::Meta::Class::constructor_class, avg 2µs/call
# spent 9µs making 5 calls to Mouse::Meta::Method::Constructor::XS::_generate_constructor, avg 2µs/call |
291 | $self->add_method($args{constructor_name} => | ||||
292 | Mouse::Util::load_class($self->constructor_class) | ||||
293 | ->_generate_constructor($self, \%args)); | ||||
294 | } | ||||
295 | |||||
296 | 5 | 111µs | 20 | 126µs | if ($args{inline_destructor}) { # spent 110µs making 5 calls to Mouse::Util::load_class, avg 22µs/call, recursion: max depth 1, sum of overlapping time 22µs
# spent 23µs making 5 calls to Mouse::Meta::Module::add_method, avg 5µs/call
# spent 8µs making 5 calls to Mouse::Meta::Class::destructor_class, avg 2µs/call
# spent 7µs making 5 calls to Mouse::Meta::Method::Destructor::XS::_generate_destructor, avg 1µs/call |
297 | $self->add_method(DESTROY => | ||||
298 | Mouse::Util::load_class($self->destructor_class) | ||||
299 | ->_generate_destructor($self, \%args)); | ||||
300 | } | ||||
301 | |||||
302 | # Moose's make_immutable returns true allowing calling code to skip | ||||
303 | # setting an explicit true value at the end of a source file. | ||||
304 | 5 | 25µs | return 1; | ||
305 | } | ||||
306 | |||||
307 | sub make_mutable { | ||||
308 | my($self) = @_; | ||||
309 | $self->{is_immutable} = 0; | ||||
310 | return; | ||||
311 | } | ||||
312 | |||||
313 | sub is_immutable; | ||||
314 | sub is_mutable { !$_[0]->is_immutable } | ||||
315 | |||||
316 | # spent 200µs (155+45) within Mouse::Meta::Class::_install_modifier which was called 4 times, avg 50µs/call:
# 2 times (76µs+23µs) by Mouse::Meta::Class::add_before_method_modifier at line 387, avg 49µs/call
# once (51µs+13µs) by Mouse::Meta::Class::add_around_method_modifier at line 392
# once (28µs+9µs) by Mouse::Meta::Class::add_after_method_modifier at line 397 | ||||
317 | 4 | 7µs | my( $self, $type, $name, $code ) = @_; | ||
318 | 4 | 23µs | 4 | 6µs | my $into = $self->name; # spent 6µs making 4 calls to Mouse::Meta::Module::name, avg 1µs/call |
319 | |||||
320 | 4 | 29µs | 4 | 14µs | my $original = $into->can($name) # spent 14µs making 4 calls to UNIVERSAL::can, avg 3µs/call |
321 | or $self->throw_error("The method '$name' was not found in the inheritance hierarchy for $into"); | ||||
322 | |||||
323 | 4 | 7µs | my $modifier_table = $self->{modifiers}{$name}; | ||
324 | |||||
325 | 4 | 9µs | if(!$modifier_table){ | ||
326 | 4 | 5µs | my(@before, @after, @around); | ||
327 | 4 | 4µs | my $cache = $original; | ||
328 | # spent 389ms (97µs+389) within Hailo::Storage::SQLite::_engage which was called:
# once (97µs+389ms) by Hailo::reply at line 314 of Hailo.pm
# spent 192µs (9+183) within Hailo::Storage::SQLite::_build_dbi_options which was called:
# once (9µs+183µs) by Hailo::Storage::dbi_options at line 45 of Hailo/Storage.pm | ||||
329 | 2 | 11µs | if(@before) { | ||
330 | 1 | 10µs | 1 | 385ms | for my $c (@before) { $c->(@_) } # spent 385ms making 1 call to Hailo::Storage::SQLite::__ANON__[Hailo/Storage/SQLite.pm:65] |
331 | } | ||||
332 | 2 | 24µs | 2 | 4.39ms | unless(@after) { # spent 4.21ms making 1 call to Hailo::Storage::_engage
# spent 183µs making 1 call to Mouse::Meta::Class::__ANON__[Mouse/Meta/Class.pm:379] |
333 | return $cache->(@_); | ||||
334 | } | ||||
335 | |||||
336 | if(wantarray){ # list context | ||||
337 | my @rval = $cache->(@_); | ||||
338 | |||||
339 | for my $c(@after){ $c->(@_) } | ||||
340 | return @rval; | ||||
341 | } | ||||
342 | elsif(defined wantarray){ # scalar context | ||||
343 | my $rval = $cache->(@_); | ||||
344 | |||||
345 | for my $c(@after){ $c->(@_) } | ||||
346 | return $rval; | ||||
347 | } | ||||
348 | else{ # void context | ||||
349 | $cache->(@_); | ||||
350 | |||||
351 | for my $c(@after){ $c->(@_) } | ||||
352 | return; | ||||
353 | } | ||||
354 | 4 | 26µs | }; | ||
355 | |||||
356 | 4 | 20µs | $self->{modifiers}{$name} = $modifier_table = { | ||
357 | original => $original, | ||||
358 | |||||
359 | before => \@before, | ||||
360 | after => \@after, | ||||
361 | around => \@around, | ||||
362 | |||||
363 | cache => \$cache, # cache for around modifiers | ||||
364 | }; | ||||
365 | |||||
366 | 4 | 44µs | 4 | 25µs | $self->add_method($name => $modified); # spent 25µs making 4 calls to Mouse::Meta::Module::add_method, avg 6µs/call |
367 | } | ||||
368 | |||||
369 | 4 | 8µs | if($type eq 'before'){ | ||
370 | unshift @{$modifier_table->{before}}, $code; | ||||
371 | } | ||||
372 | elsif($type eq 'after'){ | ||||
373 | push @{$modifier_table->{after}}, $code; | ||||
374 | } | ||||
375 | else{ # around | ||||
376 | 1 | 2µs | push @{$modifier_table->{around}}, $code; | ||
377 | |||||
378 | 1 | 1µs | my $next = ${ $modifier_table->{cache} }; | ||
379 | 2 | 11µs | 1 | 175µs | # spent 183µs (8+175) within Mouse::Meta::Class::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Class.pm:379] which was called:
# once (8µs+175µs) by Hailo::Storage::SQLite::_build_dbi_options at line 332 # spent 175µs making 1 call to Hailo::Storage::SQLite::__ANON__[Hailo/Storage/SQLite.pm:42] |
380 | } | ||||
381 | |||||
382 | 4 | 18µs | return; | ||
383 | } | ||||
384 | |||||
385 | # spent 115µs (16+99) within Mouse::Meta::Class::add_before_method_modifier which was called 2 times, avg 58µs/call:
# 2 times (16µs+99µs) by Mouse::before at line 61 of Mouse.pm, avg 58µs/call | ||||
386 | 2 | 3µs | my ( $self, $name, $code ) = @_; | ||
387 | 2 | 11µs | 2 | 99µs | $self->_install_modifier( 'before', $name, $code ); # spent 99µs making 2 calls to Mouse::Meta::Class::_install_modifier, avg 49µs/call |
388 | } | ||||
389 | |||||
390 | # spent 82µs (18+64) within Mouse::Meta::Class::add_around_method_modifier which was called:
# once (18µs+64µs) by Mouse::around at line 79 of Mouse.pm | ||||
391 | 1 | 2µs | my ( $self, $name, $code ) = @_; | ||
392 | 1 | 8µs | 1 | 64µs | $self->_install_modifier( 'around', $name, $code ); # spent 64µs making 1 call to Mouse::Meta::Class::_install_modifier |
393 | } | ||||
394 | |||||
395 | # spent 47µs (9+38) within Mouse::Meta::Class::add_after_method_modifier which was called:
# once (9µs+38µs) by Mouse::after at line 70 of Mouse.pm | ||||
396 | 1 | 2µs | my ( $self, $name, $code ) = @_; | ||
397 | 1 | 10µs | 1 | 38µs | $self->_install_modifier( 'after', $name, $code ); # spent 38µs making 1 call to Mouse::Meta::Class::_install_modifier |
398 | } | ||||
399 | |||||
400 | # spent 117µs (57+61) within Mouse::Meta::Class::add_override_method_modifier which was called 2 times, avg 59µs/call:
# 2 times (57µs+61µs) by Mouse::override at line 98 of Mouse.pm, avg 59µs/call | ||||
401 | 2 | 4µs | my ($self, $name, $code) = @_; | ||
402 | |||||
403 | 2 | 8µs | 2 | 38µs | if($self->has_method($name)){ # spent 38µs making 2 calls to Mouse::Meta::Module::has_method, avg 19µs/call |
404 | $self->throw_error("Cannot add an override method if a local method is already present"); | ||||
405 | } | ||||
406 | |||||
407 | 2 | 11µs | 2 | 3µs | my $package = $self->name; # spent 3µs making 2 calls to Mouse::Meta::Module::name, avg 2µs/call |
408 | |||||
409 | 2 | 16µs | 2 | 7µs | my $super_body = $package->can($name) # spent 7µs making 2 calls to UNIVERSAL::can, avg 3µs/call |
410 | or $self->throw_error("You cannot override '$name' because it has no super method"); | ||||
411 | |||||
412 | # spent 881µs (20+861) within Hailo::Storage::SQLite::initialized which was called:
# once (20µs+861µs) by Hailo::Storage::_engage at line 102 of Hailo/Storage.pm
# spent 43µs (13+30) within Hailo::Storage::SQLite::_build_dbd_options which was called:
# once (13µs+30µs) by Hailo::Storage::dbd_options at line 61 of Hailo/Storage.pm | ||||
413 | 2 | 5µs | local $Mouse::SUPER_PACKAGE = $package; | ||
414 | 2 | 3µs | local $Mouse::SUPER_BODY = $super_body; | ||
415 | 2 | 5µs | local @Mouse::SUPER_ARGS = @_; | ||
416 | 2 | 16µs | 2 | 892µs | &{$code}; # spent 861µs making 1 call to Hailo::Storage::SQLite::__ANON__[Hailo/Storage/SQLite.pm:88]
# spent 31µs making 1 call to Hailo::Storage::SQLite::__ANON__[Hailo/Storage/SQLite.pm:24] |
417 | 2 | 29µs | 2 | 13µs | }); # spent 13µs making 2 calls to Mouse::Meta::Module::add_method, avg 6µs/call |
418 | 2 | 7µs | return; | ||
419 | } | ||||
420 | |||||
421 | sub add_augment_method_modifier { | ||||
422 | my ($self, $name, $code) = @_; | ||||
423 | if($self->has_method($name)){ | ||||
424 | $self->throw_error("Cannot add an augment method if a local method is already present"); | ||||
425 | } | ||||
426 | |||||
427 | my $super = $self->find_method_by_name($name) | ||||
428 | or $self->throw_error("You cannot augment '$name' because it has no super method"); | ||||
429 | |||||
430 | my $super_package = $super->package_name; | ||||
431 | my $super_body = $super->body; | ||||
432 | |||||
433 | $self->add_method($name => sub { | ||||
434 | local $Mouse::INNER_BODY{$super_package} = $code; | ||||
435 | local $Mouse::INNER_ARGS{$super_package} = [@_]; | ||||
436 | &{$super_body}; | ||||
437 | }); | ||||
438 | return; | ||||
439 | } | ||||
440 | |||||
441 | # spent 821µs (325+496) within Mouse::Meta::Class::does_role which was called 12 times, avg 68µs/call:
# 9 times (260µs+327µs) by Mouse::Meta::Role::Application::_append_roles at line 194 of Mouse/Meta/Role/Application.pm, avg 65µs/call
# 3 times (65µs+169µs) by Mouse::Util::does_role at line 125 of Mouse/Util.pm, avg 78µs/call | ||||
442 | 12 | 18µs | my ($self, $role_name) = @_; | ||
443 | |||||
444 | 12 | 12µs | (defined $role_name) | ||
445 | || $self->throw_error("You must supply a role name to look for"); | ||||
446 | |||||
447 | 12 | 51µs | 9 | 12µs | $role_name = $role_name->name if ref $role_name; # spent 12µs making 9 calls to Mouse::Meta::Module::name, avg 1µs/call |
448 | |||||
449 | 12 | 80µs | 12 | 26µs | for my $class ($self->linearized_isa) { # spent 26µs making 12 calls to Mouse::Meta::Class::linearized_isa, avg 2µs/call |
450 | 16 | 60µs | 16 | 56µs | my $meta = Mouse::Util::get_metaclass_by_name($class) # spent 56µs making 16 calls to Mouse::Meta::Module::_get_metaclass_by_name, avg 4µs/call |
451 | or next; | ||||
452 | |||||
453 | 13 | 79µs | 13 | 19µs | for my $role (@{ $meta->roles }) { # spent 19µs making 13 calls to Mouse::Meta::Class::roles, avg 1µs/call |
454 | |||||
455 | 9 | 58µs | 9 | 384µs | return 1 if $role->does_role($role_name); # spent 384µs making 9 calls to Mouse::Meta::Role::does_role, avg 43µs/call |
456 | } | ||||
457 | } | ||||
458 | |||||
459 | 3 | 12µs | return 0; | ||
460 | } | ||||
461 | |||||
462 | 1 | 4µs | 1; | ||
463 | __END__ | ||||
# spent 52µs within Mouse::Meta::Class::CORE:sort which was called 7 times, avg 7µs/call:
# 7 times (52µs+0s) by Mouse::Meta::Class::_calculate_all_attributes at line 261, avg 7µs/call | |||||
# spent 63µs within Mouse::Meta::Class::CORE:subst which was called 36 times, avg 2µs/call:
# 36 times (63µs+0s) by Mouse::Meta::Class::add_attribute at line 222, avg 2µs/call | |||||
# spent 185µs (72+112) within Mouse::Meta::Class::_initialize_object which was called 6 times, avg 31µs/call:
# 3 times (41µs+66µs) by Mouse::Meta::Role::_construct_meta at line 20 of Mouse/Meta/Role.pm, avg 36µs/call
# 3 times (31µs+46µs) by Mouse::Meta::Role::Application::new at line 36 of Mouse/Meta/Role/Application.pm, avg 26µs/call | |||||
# spent 59µs within Mouse::Meta::Class::attribute_metaclass which was called 36 times, avg 2µs/call:
# 36 times (59µs+0s) by Mouse::Meta::Class::add_attribute at line 229, avg 2µs/call | |||||
# spent 9µs within Mouse::Meta::Class::constructor_class which was called 5 times, avg 2µs/call:
# 5 times (9µs+0s) by Mouse::Meta::Class::make_immutable at line 290, avg 2µs/call | |||||
# spent 8µs within Mouse::Meta::Class::destructor_class which was called 5 times, avg 2µs/call:
# 5 times (8µs+0s) by Mouse::Meta::Class::make_immutable at line 296, avg 2µs/call | |||||
# spent 25µs within Mouse::Meta::Class::is_anon_class which was called 6 times, avg 4µs/call:
# 3 times (4µs+0s) by Mouse::Object::new at line 207 of Hailo.pm, avg 1µs/call
# once (16µs+0s) by Mouse::Object::new at line 9 of reply.pl
# once (3µs+0s) by Mouse::Meta::Class::_initialize_object at line 20 of Mouse/Meta/Role.pm
# once (2µs+0s) by Mouse::Meta::Class::_initialize_object at line 36 of Mouse/Meta/Role/Application.pm | |||||
# spent 10µs within Mouse::Meta::Class::is_immutable which was called 6 times, avg 2µs/call:
# 3 times (5µs+0s) by Mouse::Object::new at line 207 of Hailo.pm, avg 2µs/call
# once (2µs+0s) by Mouse::Meta::Class::_initialize_object at line 20 of Mouse/Meta/Role.pm
# once (2µs+0s) by Mouse::Object::new at line 9 of reply.pl
# once (2µs+0s) by Mouse::Meta::Class::_initialize_object at line 36 of Mouse/Meta/Role/Application.pm | |||||
sub Mouse::Meta::Class::linearized_isa; # xsub | |||||
# spent 19µs within Mouse::Meta::Class::roles which was called 13 times, avg 1µs/call:
# 13 times (19µs+0s) by Mouse::Meta::Class::does_role at line 453, avg 1µs/call | |||||
# spent 31µs within Mouse::Meta::Class::strict_constructor which was called 10 times, avg 3µs/call:
# 4 times (15µs+0s) by MouseX::StrictConstructor::init_meta at line 14 of MouseX/StrictConstructor.pm, avg 4µs/call
# 3 times (7µs+0s) by Mouse::Object::new at line 207 of Hailo.pm, avg 2µs/call
# once (3µs+0s) by Mouse::Meta::Class::_initialize_object at line 20 of Mouse/Meta/Role.pm
# once (3µs+0s) by Mouse::Meta::Class::_initialize_object at line 36 of Mouse/Meta/Role/Application.pm
# once (2µs+0s) by Mouse::Object::new at line 9 of reply.pl |