← Index
NYTProf Performance Profile   « block view • line view • sub view »
For reply.pl
  Run on Thu Oct 21 22:40:13 2010
Reported on Thu Oct 21 22:44:38 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Class.pm
StatementsExecuted 1099 statements in 6.41ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
36221.87ms12.1msMouse::Meta::Class::::add_attribute Mouse::Meta::Class::add_attribute
644459µs619µsMouse::Meta::Class::::_calculate_all_attributes Mouse::Meta::Class::_calculate_all_attributes
1222325µs821µsMouse::Meta::Class::::does_role Mouse::Meta::Class::does_role
1521252µs21.5msMouse::Meta::Class::::superclasses Mouse::Meta::Class::superclasses (recurses: max depth 1, inclusive time 86µs)
555251µs620µsMouse::Meta::Class::::make_immutable Mouse::Meta::Class::make_immutable
711174µs174µsMouse::Meta::Class::::_construct_meta Mouse::Meta::Class::_construct_meta
431155µs200µsMouse::Meta::Class::::_install_modifier Mouse::Meta::Class::_install_modifier
11197µs389msHailo::Storage::SQLite::::_engageHailo::Storage::SQLite::_engage
61194µs122µsMouse::Meta::Class::::verify_superclass Mouse::Meta::Class::verify_superclass
62272µs185µsMouse::Meta::Class::::_initialize_object Mouse::Meta::Class::_initialize_object (xsub)
361163µs63µsMouse::Meta::Class::::CORE:subst Mouse::Meta::Class::CORE:subst (opcode)
361159µs59µsMouse::Meta::Class::::attribute_metaclass Mouse::Meta::Class::attribute_metaclass (xsub)
21157µs117µsMouse::Meta::Class::::add_override_method_modifier Mouse::Meta::Class::add_override_method_modifier
71152µs52µsMouse::Meta::Class::::CORE:sort Mouse::Meta::Class::CORE:sort (opcode)
182138µs38µsMouse::Meta::Class::::linearized_isa Mouse::Meta::Class::linearized_isa (xsub)
11133µs109µsMouse::Meta::Class::::BEGIN@2 Mouse::Meta::Class::BEGIN@2
105531µs31µsMouse::Meta::Class::::strict_constructor Mouse::Meta::Class::strict_constructor (xsub)
51130µs30µsMouse::Meta::Class::::immutable_options Mouse::Meta::Class::immutable_options
64425µs25µsMouse::Meta::Class::::is_anon_class Mouse::Meta::Class::is_anon_class (xsub)
11120µs881µsHailo::Storage::SQLite::::initializedHailo::Storage::SQLite::initialized
131119µs19µsMouse::Meta::Class::::roles Mouse::Meta::Class::roles (xsub)
11118µs82µsMouse::Meta::Class::::add_around_method_modifier Mouse::Meta::Class::add_around_method_modifier
21116µs115µsMouse::Meta::Class::::add_before_method_modifier Mouse::Meta::Class::add_before_method_modifier
11113µs43µsHailo::Storage::SQLite::::_build_dbd_optionsHailo::Storage::SQLite::_build_dbd_options
11111µs33µsMouse::Meta::Class::::BEGIN@26 Mouse::Meta::Class::BEGIN@26
64410µs10µsMouse::Meta::Class::::is_immutable Mouse::Meta::Class::is_immutable (xsub)
1119µs192µsHailo::Storage::SQLite::::_build_dbi_optionsHailo::Storage::SQLite::_build_dbi_options
1119µs47µsMouse::Meta::Class::::add_after_method_modifier Mouse::Meta::Class::add_after_method_modifier
5119µs9µsMouse::Meta::Class::::constructor_class Mouse::Meta::Class::constructor_class (xsub)
5118µs8µsMouse::Meta::Class::::destructor_class Mouse::Meta::Class::destructor_class (xsub)
1118µs183µsMouse::Meta::Class::::__ANON__[:379] Mouse::Meta::Class::__ANON__[:379]
1116µs6µsMouse::Meta::Class::::BEGIN@6 Mouse::Meta::Class::BEGIN@6
1116µs6µsMouse::Meta::Class::::BEGIN@4 Mouse::Meta::Class::BEGIN@4
0000s0sHailo::Storage::SQLite::::start_trainingHailo::Storage::SQLite::start_training
0000s0sHailo::Storage::SQLite::::stop_trainingHailo::Storage::SQLite::stop_training
0000s0sMouse::Meta::Class::::__ANON__[:354] Mouse::Meta::Class::__ANON__[:354]
0000s0sMouse::Meta::Class::::__ANON__[:417] Mouse::Meta::Class::__ANON__[:417]
0000s0sMouse::Meta::Class::::__ANON__[:437] Mouse::Meta::Class::__ANON__[:437]
0000s0sMouse::Meta::Class::::_collect_roles Mouse::Meta::Class::_collect_roles
0000s0sMouse::Meta::Class::::_reconcile_with_superclass_meta Mouse::Meta::Class::_reconcile_with_superclass_meta
0000s0sMouse::Meta::Class::::add_augment_method_modifier Mouse::Meta::Class::add_augment_method_modifier
0000s0sMouse::Meta::Class::::calculate_all_roles Mouse::Meta::Class::calculate_all_roles
0000s0sMouse::Meta::Class::::create_anon_class Mouse::Meta::Class::create_anon_class
0000s0sMouse::Meta::Class::::find_attribute_by_name Mouse::Meta::Class::find_attribute_by_name
0000s0sMouse::Meta::Class::::find_method_by_name Mouse::Meta::Class::find_method_by_name
0000s0sMouse::Meta::Class::::get_all_method_names Mouse::Meta::Class::get_all_method_names
0000s0sMouse::Meta::Class::::get_all_methods Mouse::Meta::Class::get_all_methods
0000s0sMouse::Meta::Class::::inherit_from_foreign_class Mouse::Meta::Class::inherit_from_foreign_class
0000s0sMouse::Meta::Class::::is_mutable Mouse::Meta::Class::is_mutable
0000s0sMouse::Meta::Class::::make_mutable Mouse::Meta::Class::make_mutable
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Mouse::Meta::Class;
2230µs2184µ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
use Mouse::Util qw/:meta/; # enables strict and warnings
# spent 109µs making 1 call to Mouse::Meta::Class::BEGIN@2 # spent 76µs making 1 call to Mouse::Exporter::do_import
3
4223µs16µs
# spent 6µs within Mouse::Meta::Class::BEGIN@4 which was called: # once (6µs+0s) by Mouse::BEGIN@14 at line 4
use Scalar::Util ();
# spent 6µs making 1 call to Mouse::Meta::Class::BEGIN@4
5
6289µs16µs
# spent 6µs within Mouse::Meta::Class::BEGIN@6 which was called: # once (6µs+0s) by Mouse::BEGIN@14 at line 6
use Mouse::Meta::Module;
# spent 6µs making 1 call to Mouse::Meta::Class::BEGIN@6
717µsour @ISA = qw(Mouse::Meta::Module);
8
911µsour @CARP_NOT = qw(Mouse); # trust Mouse
10
11sub attribute_metaclass;
12sub method_metaclass;
13
14sub constructor_class;
15sub 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
sub _construct_meta {
1963186µs my($class, %args) = @_;
20
21 $args{attributes} = {};
22 $args{methods} = {};
23 $args{roles} = [];
24
25 $args{superclasses} = do {
2621.94ms255µ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
no strict 'refs';
# spent 33µs making 1 call to Mouse::Meta::Class::BEGIN@26 # spent 22µs making 1 call to strict::unimport
27 \@{ $args{package} . '::ISA' };
28 };
29
30 my $self = bless \%args, ref($class) || $class;
31 if(ref($self) ne __PACKAGE__){
32 $self->meta->_initialize_object($self, \%args);
33 }
34 return $self;
35}
36
37sub create_anon_class{
38 my $self = shift;
39 return $self->create(undef, @_);
40}
41
42sub is_anon_class;
43
44sub roles;
45
46sub 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
sub superclasses {
5469257µs my $self = shift;
55
56 if (@_) {
57 foreach my $super(@_){
58621.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
59620µ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
606122µ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 return @{ $self->{superclasses} } = @_;
64 }
65
66 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
sub verify_superclass {
7028125µs my($self, $super, $super_meta) = @_;
71
72110µ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.
82514µs my $mm = $super->can('meta');
# spent 14µs making 5 calls to UNIVERSAL::can, avg 3µs/call
83 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 return 1; # always ok
89 }
90
9112µs return $self->isa(ref $super_meta); # checks metaclass compatibility
# spent 2µs making 1 call to UNIVERSAL::isa
92}
93
94sub 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
10212µsmy @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
109sub _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
139sub _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
165sub 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
177sub get_all_methods {
178 my($self) = @_;
179 return map{ $self->find_method_by_name($_) } $self->get_all_method_names;
180}
181
182sub 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
190sub 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
sub add_attribute {
2016122.04ms my $self = shift;
202
203 my($attr, $name);
204
2053654µ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 $name = shift;
216
217 my %args = (@_ == 1) ? %{$_[0]} : @_;
218
219 defined($name)
220 or $self->throw_error('You must provide a name for the attribute');
221
2223663µ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{
22972354µ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 $args{traits} = \@traits if @traits;
231
232364.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
2363669µ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
239365.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 $attr->{insertion_order} = keys %{ $self->{attributes} };
243 $self->{attributes}{$name} = $attr;
244 delete $self->{_mouse_cache}; # clears internal cache
245
246 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 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
sub _calculate_all_attributes {
254101571µs my($self) = @_;
255 my %seen;
256 my @all_attrs;
257613µs foreach my $class($self->linearized_isa) {
# spent 13µs making 6 calls to Mouse::Meta::Class::linearized_isa, avg 2µs/call
2581442µ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
2593652µ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 {
261752µ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 push @all_attrs, @attrs;
264 }
265 return [reverse @all_attrs];
266}
267
268sub linearized_isa;
269
270sub new_object;
271sub 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
sub immutable_options {
2741038µs my ( $self, @args ) = @_;
275
276 return (
277 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
sub make_immutable {
28530322µs my $self = shift;
286530µs my %args = $self->immutable_options(@_);
# spent 30µs making 5 calls to Mouse::Meta::Class::immutable_options, avg 6µs/call
287
288 $self->{is_immutable}++;
289
29020161µ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
29620126µ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 return 1;
305}
306
307sub make_mutable {
308 my($self) = @_;
309 $self->{is_immutable} = 0;
310 return;
311}
312
313sub is_immutable;
314sub 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
sub _install_modifier {
31751206µs my( $self, $type, $name, $code ) = @_;
31846µs my $into = $self->name;
# spent 6µs making 4 calls to Mouse::Meta::Module::name, avg 1µs/call
319
320414µ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 my $modifier_table = $self->{modifiers}{$name};
324
325 if(!$modifier_table){
326 my(@before, @after, @around);
327 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
my $modified = sub {
329544µs if(@before) {
3301385ms for my $c (@before) { $c->(@_) }
331 }
33224.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 };
355
356 $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
366425µ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 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 push @{$modifier_table->{around}}, $code;
377
378 my $next = ${ $modifier_table->{cache} };
37918µs1175µ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
${ $modifier_table->{cache} } = sub{ $code->($next, @_) };
380 }
381
382 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
sub add_before_method_modifier {
386414µs my ( $self, $name, $code ) = @_;
387299µ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
sub add_around_method_modifier {
391210µs my ( $self, $name, $code ) = @_;
392164µ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
sub add_after_method_modifier {
396212µs my ( $self, $name, $code ) = @_;
397138µ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
sub add_override_method_modifier {
4011275µs my ($self, $name, $code) = @_;
402
403238µ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
40723µs my $package = $self->name;
# spent 3µs making 2 calls to Mouse::Meta::Module::name, avg 2µs/call
408
40927µ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
$self->add_method($name => sub {
413829µs local $Mouse::SUPER_PACKAGE = $package;
414 local $Mouse::SUPER_BODY = $super_body;
415 local @Mouse::SUPER_ARGS = @_;
4162892µs &{$code};
417213µs });
# spent 13µs making 2 calls to Mouse::Meta::Module::add_method, avg 6µs/call
418 return;
419}
420
421sub 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
sub does_role {
44289370µs my ($self, $role_name) = @_;
443
444 (defined $role_name)
445 || $self->throw_error("You must supply a role name to look for");
446
447912µ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
4491226µs for my $class ($self->linearized_isa) {
# spent 26µs making 12 calls to Mouse::Meta::Class::linearized_isa, avg 2µs/call
4501656µ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
4531319µs for my $role (@{ $meta->roles }) {
# spent 19µs making 13 calls to Mouse::Meta::Class::roles, avg 1µs/call
454
4559384µ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 return 0;
460}
461
46214µs1;
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
sub Mouse::Meta::Class::CORE:sort; # opcode
# 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
sub Mouse::Meta::Class::CORE:subst; # opcode
# 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
sub Mouse::Meta::Class::_initialize_object; # xsub
# 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
sub Mouse::Meta::Class::attribute_metaclass; # xsub
# 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
sub Mouse::Meta::Class::constructor_class; # xsub
# 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
sub Mouse::Meta::Class::destructor_class; # xsub
# 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
sub Mouse::Meta::Class::is_anon_class; # xsub
# 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::is_immutable; # xsub
# spent 38µs within Mouse::Meta::Class::linearized_isa which was called 18 times, avg 2µs/call: # 12 times (26µs+0s) by Mouse::Meta::Class::does_role at line 449, avg 2µs/call # 6 times (13µs+0s) by Mouse::Meta::Class::_calculate_all_attributes at line 257, avg 2µs/call
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
sub Mouse::Meta::Class::roles; # xsub
# 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
sub Mouse::Meta::Class::strict_constructor; # xsub