← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/hailo
  Run on Thu Oct 21 22:50:37 2010
Reported on Thu Oct 21 22:52:12 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 3228 statements in 15.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
222412ms104sHailo::Command::::train_progress Hailo::Command::train_progress
68223.44ms30.7msMouse::Meta::Class::::add_attribute Mouse::Meta::Class::add_attribute (recurses: max depth 1, inclusive time 588µs)
16762.48ms3.42msMouse::Meta::Class::::_calculate_all_attributes Mouse::Meta::Class::_calculate_all_attributes
97332.39ms4.51msMouse::Meta::Class::::does_role Mouse::Meta::Class::does_role
3132581µs47.7msMouse::Meta::Class::::superclasses Mouse::Meta::Class::superclasses (recurses: max depth 1, inclusive time 174µs)
931351µs450µsMouse::Meta::Class::::_install_modifier Mouse::Meta::Class::_install_modifier
777335µs837µsMouse::Meta::Class::::make_immutable Mouse::Meta::Class::make_immutable
1411320µs320µsMouse::Meta::Class::::_construct_meta Mouse::Meta::Class::_construct_meta
3433308µs1.13msMouse::Meta::Class::::_initialize_object Mouse::Meta::Class::_initialize_object (xsub)
2511306µs306µsMouse::Meta::Class::::CORE:sort Mouse::Meta::Class::CORE:sort (opcode)
11321253µs253µsMouse::Meta::Class::::linearized_isa Mouse::Meta::Class::linearized_isa (xsub)
2633236µs3.22msMouse::Meta::Class::::get_all_attributes Mouse::Meta::Class::get_all_attributes (xsub)
1611222µs276µsMouse::Meta::Class::::verify_superclass Mouse::Meta::Class::verify_superclass
711216µs2.90msMouse::Meta::Class::::find_attribute_by_name Mouse::Meta::Class::find_attribute_by_name
2611199µs3.01msMouse::Meta::Class::::create_anon_class Mouse::Meta::Class::create_anon_class
2511184µs52.3msMouse::Meta::Class::::__ANON__[:379] Mouse::Meta::Class::__ANON__[:379]
2211167µs3.76msHailo::Command::::_get_cmd_flags_for_attr Hailo::Command::_get_cmd_flags_for_attr
10011145µs145µsMouse::Meta::Class::::roles Mouse::Meta::Class::roles (xsub)
222107µs104sHailo::Command::::run Hailo::Command::run
6811104µs104µsMouse::Meta::Class::::CORE:subst Mouse::Meta::Class::CORE:subst (opcode)
6111103µs103µsMouse::Meta::Class::::attribute_metaclass Mouse::Meta::Class::attribute_metaclass (xsub)
31175µs170µsMouse::Meta::Class::::add_override_method_modifier Mouse::Meta::Class::add_override_method_modifier
218759µs59µsMouse::Meta::Class::::strict_constructor Mouse::Meta::Class::strict_constructor (xsub)
11141µs4.47msHailo::Storage::SQLite::::stop_trainingHailo::Storage::SQLite::stop_training
71141µs41µsMouse::Meta::Class::::immutable_options Mouse::Meta::Class::immutable_options
42237µs275µsMouse::Meta::Class::::add_around_method_modifier Mouse::Meta::Class::add_around_method_modifier
41134µs205µsMouse::Meta::Class::::add_before_method_modifier Mouse::Meta::Class::add_before_method_modifier
167626µs26µsMouse::Meta::Class::::is_immutable Mouse::Meta::Class::is_immutable (xsub)
11124µs102µsMouse::Meta::Class::::BEGIN@2 Mouse::Meta::Class::BEGIN@2
167623µs23µsMouse::Meta::Class::::is_anon_class Mouse::Meta::Class::is_anon_class (xsub)
11119µs53.0msHailo::Storage::SQLite::::start_trainingHailo::Storage::SQLite::start_training
11118µs5.51msHailo::Storage::SQLite::::_engageHailo::Storage::SQLite::_engage
11115µs51.8sHailo::Command::::_train_fh Hailo::Command::_train_fh
11114µs316µsHailo::Storage::SQLite::::initializedHailo::Storage::SQLite::initialized
71113µs13µsMouse::Meta::Class::::constructor_class Mouse::Meta::Class::constructor_class (xsub)
11113µs38µsHailo::Storage::SQLite::::_build_dbd_optionsHailo::Storage::SQLite::_build_dbd_options
11111µs48.2msHailo::Command::::_getopt_get_options Hailo::Command::_getopt_get_options
11111µs32µsMouse::Meta::Class::::BEGIN@26 Mouse::Meta::Class::BEGIN@26
71110µs10µsMouse::Meta::Class::::destructor_class Mouse::Meta::Class::destructor_class (xsub)
1119µs51µsMouse::Meta::Class::::add_after_method_modifier Mouse::Meta::Class::add_after_method_modifier
1119µs176µsHailo::Storage::SQLite::::_build_dbi_optionsHailo::Storage::SQLite::_build_dbi_options
1119µs282µsHailo::Command::::_getopt_spec Hailo::Command::_getopt_spec
1116µs6µsMouse::Meta::Class::::BEGIN@6 Mouse::Meta::Class::BEGIN@6
1116µs6µsMouse::Meta::Class::::BEGIN@4 Mouse::Meta::Class::BEGIN@4
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::::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;
2228µs2180µs
# spent 102µs (24+78) within Mouse::Meta::Class::BEGIN@2 which was called: # once (24µs+78µs) by Mouse::BEGIN@14 at line 2
use Mouse::Util qw/:meta/; # enables strict and warnings
# spent 102µs making 1 call to Mouse::Meta::Class::BEGIN@2 # spent 78µs making 1 call to Mouse::Exporter::do_import
3
4224µ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
716µ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 320µs within Mouse::Meta::Class::_construct_meta which was called 14 times, avg 23µs/call: # 14 times (320µs+0s) by Mouse::Meta::Module::initialize at line 29 of Mouse/Meta/Module.pm, avg 23µs/call
sub _construct_meta {
191433µs my($class, %args) = @_;
20
211426µs $args{attributes} = {};
221422µs $args{methods} = {};
231423µs $args{roles} = [];
24
251435µs $args{superclasses} = do {
2621.94ms254µs
# spent 32µ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 32µs making 1 call to Mouse::Meta::Class::BEGIN@26 # spent 22µs making 1 call to strict::unimport
271464µs \@{ $args{package} . '::ISA' };
28 };
29
301448µs my $self = bless \%args, ref($class) || $class;
311423µs if(ref($self) ne __PACKAGE__){
32 $self->meta->_initialize_object($self, \%args);
33 }
341471µs return $self;
35}
36
37
# spent 3.01ms (199µs+2.81) within Mouse::Meta::Class::create_anon_class which was called 26 times, avg 116µs/call: # 26 times (199µs+2.81ms) by Mouse::Meta::Attribute::interpolate_class at line 129 of Mouse/Meta/Attribute.pm, avg 116µs/call
sub create_anon_class{
382631µs my $self = shift;
3926162µs262.81ms return $self->create(undef, @_);
# spent 2.81ms making 26 calls to Mouse::Meta::Module::create, avg 108µs/call
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 47.7ms (581µs+47.1) within Mouse::Meta::Class::superclasses which was called 31 times, avg 1.54ms/call: # 25 times (401µs+285µs) by Mouse::init_meta at line 139 of Mouse.pm, avg 27µs/call # 4 times (125µs+46.7ms) by Mouse::extends at line 35 of Mouse.pm, avg 11.7ms/call # 2 times (55µs+78µs) by Mouse::Meta::Module::create at line 238 of Mouse/Meta/Module.pm, avg 67µs/call
sub superclasses {
543138µs my $self = shift;
55
563139µs if (@_) {
571667µs foreach my $super(@_){
581663µs1646.8ms Mouse::Util::load_class($super);
# spent 46.9ms making 16 calls to Mouse::Util::load_class, avg 2.93ms/call, recursion: max depth 2, sum of overlapping time 169µs
591663µs1650µs my $meta = Mouse::Util::get_metaclass_by_name($super);
# spent 50µs making 16 calls to Mouse::Meta::Module::_get_metaclass_by_name, avg 3µs/call
601674µs16276µs next if $self->verify_superclass($super, $meta);
# spent 276µs making 16 calls to Mouse::Meta::Class::verify_superclass, avg 17µs/call
61 $self->_reconcile_with_superclass_meta($meta);
62 }
6316169µs return @{ $self->{superclasses} } = @_;
64 }
65
661567µs return @{ $self->{superclasses} };
67}
68
69
# spent 276µs (222+54) within Mouse::Meta::Class::verify_superclass which was called 16 times, avg 17µs/call: # 16 times (222µs+54µs) by Mouse::Meta::Class::superclasses at line 60, avg 17µs/call
sub verify_superclass {
701628µs my($self, $super, $super_meta) = @_;
71
721642µs213µs if(defined $super_meta) {
# spent 13µs making 2 calls to Mouse::Util::is_a_metarole, avg 6µs/call
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.
8214114µs1437µs my $mm = $super->can('meta');
# spent 37µs making 14 calls to UNIVERSAL::can, avg 3µs/call
831429µ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 }
881456µs return 1; # always ok
89 }
90
91221µs25µs return $self->isa(ref $super_meta); # checks metaclass compatibility
# spent 5µs making 2 calls to UNIVERSAL::isa, avg 2µs/call
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
190
# spent 2.90ms (216µs+2.68) within Mouse::Meta::Class::find_attribute_by_name which was called 7 times, avg 414µs/call: # 7 times (216µs+2.68ms) by Mouse::Meta::Class::add_attribute at line 223, avg 414µs/call
sub find_attribute_by_name {
191711µs my($self, $name) = @_;
19278µs defined($name)
193 or $self->throw_error('You must define an attribute name to find');
1947204µs355.12ms foreach my $attr($self->get_all_attributes) {
# spent 2.63ms making 7 calls to Mouse::Meta::Class::get_all_attributes, avg 376µs/call # spent 2.45ms making 7 calls to Mouse::Meta::Class::_calculate_all_attributes, avg 350µs/call # spent 14µs making 7 calls to Mouse::Meta::Class::strict_constructor, avg 2µs/call # spent 11µs making 7 calls to Mouse::Meta::Class::is_immutable, avg 2µs/call # spent 10µs making 7 calls to Mouse::Meta::Class::is_anon_class, avg 1µs/call
19539226µs3951µs return $attr if $attr->name eq $name;
# spent 51µs making 39 calls to Mouse::Meta::Attribute::name, avg 1µs/call
196 }
197 return undef;
198}
199
200
# spent 30.7ms (3.44+27.2) within Mouse::Meta::Class::add_attribute which was called 68 times, avg 451µs/call: # 50 times (2.46ms+19.7ms) by Mouse::has at line 52 of Mouse.pm, avg 443µs/call # 18 times (983µs+7.54ms) by Mouse::Meta::Role::Application::apply_attributes at line 156 of Mouse/Meta/Role/Application.pm, avg 474µs/call
sub add_attribute {
2016874µs my $self = shift;
202
2036870µs my($attr, $name);
204
20568435µs6898µs if(Scalar::Util::blessed($_[0])){
# spent 98µs making 68 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
2156880µs $name = shift;
216
21768305µs my %args = (@_ == 1) ? %{$_[0]} : @_;
218
2196871µs defined($name)
220 or $self->throw_error('You must provide a name for the attribute');
221
22268444µs68104µs if ($name =~ s/^\+//) { # inherited attributes
# spent 104µs making 68 calls to Mouse::Meta::Class::CORE:subst, avg 2µs/call
223728µs72.90ms my $inherited_attr = $self->find_attribute_by_name($name)
# spent 2.90ms making 7 calls to Mouse::Meta::Class::find_attribute_by_name, avg 414µs/call
224 or $self->throw_error("Could not find an attribute by the name of '$name' to inherit from in ".$self->name);
225
226733µs72.29ms $attr = $inherited_attr->clone_and_inherit_options(%args);
# spent 2.29ms making 7 calls to Mouse::Meta::Attribute::clone_and_inherit_options, avg 328µs/call
227 }
228 else{
22961536µs1224.60ms my($attribute_class, @traits) = $self->attribute_metaclass->interpolate_class(\%args);
# spent 4.52ms making 61 calls to Mouse::Meta::Attribute::interpolate_class, avg 74µs/call, recursion: max depth 1, sum of overlapping time 28µs # spent 103µs making 61 calls to Mouse::Meta::Class::attribute_metaclass, avg 2µs/call
2306176µs $args{traits} = \@traits if @traits;
231
23261324µs618.46ms $attr = $attribute_class->new($name, %args);
# spent 8.46ms making 61 calls to Mouse::Meta::Attribute::new, avg 139µs/call
233 }
234 }
235
23668391µs68128µs Scalar::Util::weaken( $attr->{associated_class} = $self );
# spent 128µs making 68 calls to Scalar::Util::weaken, avg 2µs/call
237
238 # install accessors first
23968254µs689.20ms $attr->install_accessors();
# spent 9.20ms making 68 calls to Mouse::Meta::Attribute::install_accessors, avg 135µs/call
240
241 # then register the attribute to the metaclass
24268121µs $attr->{insertion_order} = keys %{ $self->{attributes} };
2436897µs $self->{attributes}{$name} = $attr;
2446887µs delete $self->{_mouse_cache}; # clears internal cache
245
2466882µ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 }
25068235µs return $attr;
251}
252
253
# spent 3.42ms (2.48+935µs) within Mouse::Meta::Class::_calculate_all_attributes which was called 16 times, avg 213µs/call: # 7 times (1.76ms+685µs) by Mouse::Meta::Class::get_all_attributes at line 194, avg 350µs/call # 3 times (215µs+78µs) by Mouse::Object::new at line 201 of lib/Hailo.pm, avg 97µs/call # 2 times (68µs+19µs) by Mouse::Meta::Class::_initialize_object at line 83 of Mouse/Meta/Attribute.pm, avg 43µs/call # once (318µs+114µs) by Mouse::Meta::Class::get_all_attributes at line 174 of MouseX/Getopt/Basic.pm # once (43µs+15µs) by Mouse::Meta::Class::get_all_attributes at line 69 of Mouse/Meta/Attribute.pm # once (42µs+14µs) by Mouse::Meta::Class::_initialize_object at line 20 of Mouse/Meta/Role.pm # once (31µs+10µs) by Mouse::Meta::Class::_initialize_object at line 36 of Mouse/Meta/Role/Application.pm
sub _calculate_all_attributes {
2541621µs my($self) = @_;
2551616µs my %seen;
2561617µs my @all_attrs;
25716146µs1633µs foreach my $class($self->linearized_isa) {
# spent 33µs making 16 calls to Mouse::Meta::Class::linearized_isa, avg 2µs/call
25842163µs42125µs my $meta = Mouse::Util::get_metaclass_by_name($class) or next;
# spent 125µs making 42 calls to Mouse::Meta::Module::_get_metaclass_by_name, avg 3µs/call
2593772.32ms352471µs my @attrs = grep { !$seen{$_->name}++ } values %{$meta->{attributes}};
# spent 471µs making 352 calls to Mouse::Meta::Attribute::name, avg 1µs/call
260 @attrs = sort {
26125397µs25306µs $b->{insertion_order} <=> $a->{insertion_order}
# spent 306µs making 25 calls to Mouse::Meta::Class::CORE:sort, avg 12µs/call
262 } @attrs;
2632583µs push @all_attrs, @attrs;
264 }
26516113µs return [reverse @all_attrs];
266}
267
268sub linearized_isa;
269
270sub new_object;
271sub clone_object;
272
273
# spent 41µs within Mouse::Meta::Class::immutable_options which was called 7 times, avg 6µs/call: # 7 times (41µs+0s) by Mouse::Meta::Class::make_immutable at line 286, avg 6µs/call
sub immutable_options {
274713µs my ( $self, @args ) = @_;
275
276 return (
277738µs inline_constructor => 1,
278 inline_destructor => 1,
279 constructor_name => 'new',
280 @args,
281 );
282}
283
284
# spent 837µs (335+502) within Mouse::Meta::Class::make_immutable which was called 7 times, avg 120µs/call: # once (65µs+77µs) by Mouse::Util::_try_load_one_class at line 343 of lib/Hailo.pm # once (49µs+75µs) by Mouse::Util::_try_load_one_class at line 265 of lib/Hailo/Storage.pm # once (49µs+70µs) by Hailo::_new_class at line 312 of lib/Hailo/Engine/Default.pm # once (46µs+72µs) by Hailo::_new_class at line 202 of lib/Hailo/Tokenizer/Words.pm # once (44µs+70µs) by Hailo::_new_class at line 127 of lib/Hailo/Storage/SQLite.pm # once (42µs+68µs) by hailo::BEGIN@8 at line 405 of lib/Hailo/Command.pm # once (41µs+69µs) by main::RUNTIME at line 12 of bin/hailo
sub make_immutable {
285710µs my $self = shift;
286753µs741µs my %args = $self->immutable_options(@_);
# spent 41µs making 7 calls to Mouse::Meta::Class::immutable_options, avg 6µs/call
287
288714µs $self->{is_immutable}++;
289
2907173µs28195µs if ($args{inline_constructor}) {
# spent 192µs making 7 calls to Mouse::Util::load_class, avg 27µs/call, recursion: max depth 1, sum of overlapping time 62µs # spent 42µs making 7 calls to Mouse::Meta::Module::add_method, avg 6µs/call # spent 13µs making 7 calls to Mouse::Meta::Class::constructor_class, avg 2µs/call # spent 11µs making 7 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
2967154µs28160µs if ($args{inline_destructor}) {
# spent 153µs making 7 calls to Mouse::Util::load_class, avg 22µs/call, recursion: max depth 1, sum of overlapping time 44µs # spent 31µs making 7 calls to Mouse::Meta::Module::add_method, avg 4µs/call # spent 10µs making 7 calls to Mouse::Meta::Class::destructor_class, avg 1µs/call # spent 10µs making 7 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.
304735µs 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 450µs (351+99) within Mouse::Meta::Class::_install_modifier which was called 9 times, avg 50µs/call: # 4 times (195µs+42µs) by Mouse::Meta::Class::add_around_method_modifier at line 392, avg 59µs/call # 4 times (124µs+47µs) by Mouse::Meta::Class::add_before_method_modifier at line 387, avg 43µs/call # once (31µs+10µs) by Mouse::Meta::Class::add_after_method_modifier at line 397
sub _install_modifier {
317914µs my( $self, $type, $name, $code ) = @_;
318948µs912µs my $into = $self->name;
# spent 12µs making 9 calls to Mouse::Meta::Module::name, avg 1µs/call
319
320967µs928µs my $original = $into->can($name)
# spent 28µs making 9 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
323915µs my $modifier_table = $self->{modifiers}{$name};
324
325920µs if(!$modifier_table){
326913µs my(@before, @after, @around);
327910µs my $cache = $original;
328
# spent 104s (412ms+103) within Hailo::Command::train_progress which was called 2 times, avg 51.8s/call: # once (21µs+51.8s) by Hailo::Command::__ANON__[lib/Hailo/Command.pm:298] at line 293 of lib/Hailo/Command.pm # once (412ms+51.4s) by Hailo::Command::train_progress at line 332 # spent 53.0ms (19µs+53.0) within Hailo::Storage::SQLite::start_training which was called: # once (19µs+53.0ms) by Hailo::train at line 213 of lib/Hailo.pm # spent 4.47ms (41µs+4.43) within Hailo::Storage::SQLite::stop_training which was called: # once (41µs+4.43ms) by Hailo::train at line 240 of lib/Hailo.pm # spent 104s (107µs+104) within Hailo::Command::run which was called 2 times, avg 51.9s/call: # once (22µs+51.9s) by main::RUNTIME at line 35 of bin/hailo # once (86µs+51.9s) by Hailo::Command::run at line 332 # spent 3.76ms (167µs+3.59) within Hailo::Command::_get_cmd_flags_for_attr which was called 22 times, avg 171µs/call: # 22 times (167µs+3.59ms) by MouseX::Getopt::Basic::_attrs_to_options at line 200 of MouseX/Getopt/Basic.pm, avg 171µs/call # spent 282µs (9+274) within Hailo::Command::_getopt_spec which was called: # once (9µs+274µs) by MouseX::Getopt::Basic::_parse_argv at line 93 of MouseX/Getopt/Basic.pm # spent 5.51ms (18µs+5.49) within Hailo::Storage::SQLite::_engage which was called: # once (18µs+5.49ms) by Hailo::Storage::start_training at line 202 of lib/Hailo/Storage.pm # spent 48.2ms (11µs+48.2) within Hailo::Command::_getopt_get_options which was called: # once (11µs+48.2ms) by MouseX::Getopt::Basic::_parse_argv at line 102 of MouseX/Getopt/Basic.pm # spent 176µs (9+167) within Hailo::Storage::SQLite::_build_dbi_options which was called: # once (9µs+167µs) by Hailo::Storage::dbi_options at line 39 of lib/Hailo/Storage.pm
my $modified = sub {
3293042µs if(@before) {
330425µs4105ms for my $c (@before) { $c->(@_) }
331 }
33230224µs30104s unless(@after) {
# spent 51.9s making 1 call to Hailo::Command::run # spent 51.8s making 1 call to Hailo::Command::train_progress # spent 52.3ms making 25 calls to Mouse::Meta::Class::__ANON__[Mouse/Meta/Class.pm:379], avg 2.09ms/call # spent 5.61ms making 1 call to Hailo::Storage::start_training # spent 5.18ms making 1 call to Hailo::Storage::_engage # spent 40µs making 1 call to Term::Sk::DESTROY
333 return $cache->(@_);
334 }
335
33611µs 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
34915µs14.07ms $cache->(@_);
# spent 4.07ms making 1 call to Hailo::Storage::stop_training
350
351223µs1360µs for my $c(@after){ $c->(@_) }
35216µs return;
353 }
354934µs };
355
356943µ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
3669108µs958µs $self->add_method($name => $modified);
# spent 58µs making 9 calls to Mouse::Meta::Module::add_method, avg 6µs/call
367 }
368
369921µ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
37647µs push @{$modifier_table->{around}}, $code;
377
37846µs my $next = ${ $modifier_table->{cache} };
37929180µs2552.1ms
# spent 52.3ms (184µs+52.1) 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 25 times, avg 2.09ms/call: # 25 times (184µs+52.1ms) by Hailo::Command::_get_cmd_flags_for_attr or Hailo::Command::_getopt_get_options or Hailo::Command::_getopt_spec or Hailo::Storage::SQLite::_build_dbi_options at line 332, avg 2.09ms/call
${ $modifier_table->{cache} } = sub{ $code->($next, @_) };
380 }
381
382938µs return;
383}
384
385
# spent 205µs (34+170) within Mouse::Meta::Class::add_before_method_modifier which was called 4 times, avg 51µs/call: # 4 times (34µs+170µs) by Mouse::before at line 61 of Mouse.pm, avg 51µs/call
sub add_before_method_modifier {
38647µs my ( $self, $name, $code ) = @_;
387425µs4170µs $self->_install_modifier( 'before', $name, $code );
# spent 170µs making 4 calls to Mouse::Meta::Class::_install_modifier, avg 43µs/call
388}
389
390
# spent 275µs (37+238) within Mouse::Meta::Class::add_around_method_modifier which was called 4 times, avg 69µs/call: # 3 times (27µs+175µs) by Mouse::Meta::Role::Application::apply_modifiers at line 182 of Mouse/Meta/Role/Application.pm, avg 67µs/call # once (10µs+63µs) by Mouse::around at line 79 of Mouse.pm
sub add_around_method_modifier {
39147µs my ( $self, $name, $code ) = @_;
392429µs4238µs $self->_install_modifier( 'around', $name, $code );
# spent 238µs making 4 calls to Mouse::Meta::Class::_install_modifier, avg 59µs/call
393}
394
395
# spent 51µs (9+41) within Mouse::Meta::Class::add_after_method_modifier which was called: # once (9µs+41µs) by Mouse::after at line 70 of Mouse.pm
sub add_after_method_modifier {
39612µs my ( $self, $name, $code ) = @_;
39717µs141µs $self->_install_modifier( 'after', $name, $code );
# spent 41µs making 1 call to Mouse::Meta::Class::_install_modifier
398}
399
400
# spent 170µs (75+95) within Mouse::Meta::Class::add_override_method_modifier which was called 3 times, avg 57µs/call: # 3 times (75µs+95µs) by Mouse::override at line 98 of Mouse.pm, avg 57µs/call
sub add_override_method_modifier {
40136µs my ($self, $name, $code) = @_;
402
403311µs358µs if($self->has_method($name)){
# spent 58µs making 3 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
407317µs35µs my $package = $self->name;
# spent 5µs making 3 calls to Mouse::Meta::Module::name, avg 2µs/call
408
409323µs310µs my $super_body = $package->can($name)
# spent 10µs making 3 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 316µs (14+302) within Hailo::Storage::SQLite::initialized which was called: # once (14µs+302µs) by Hailo::Storage::_engage at line 96 of lib/Hailo/Storage.pm # spent 38µs (13+25) within Hailo::Storage::SQLite::_build_dbd_options which was called: # once (13µs+25µs) by Hailo::Storage::dbd_options at line 55 of lib/Hailo/Storage.pm # spent 51.8s (15µs+51.8) within Hailo::Command::_train_fh which was called: # once (15µs+51.8s) by Hailo::train at line 228 of lib/Hailo.pm
$self->add_method($name => sub {
41336µs local $Mouse::SUPER_PACKAGE = $package;
41434µs local $Mouse::SUPER_BODY = $super_body;
41537µs local @Mouse::SUPER_ARGS = @_;
416331µs351.8s &{$code};
417342µs322µs });
# spent 22µs making 3 calls to Mouse::Meta::Module::add_method, avg 7µs/call
418312µs 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 4.51ms (2.39+2.11) within Mouse::Meta::Class::does_role which was called 97 times, avg 46µs/call: # 81 times (1.88ms+1.59ms) by Mouse::Util::does_role at line 125 of Mouse/Util.pm, avg 43µs/call # 15 times (467µs+411µs) by Mouse::Meta::Role::Application::_append_roles at line 194 of Mouse/Meta/Role/Application.pm, avg 59µs/call # once (51µs+109µs) by MouseX::Getopt::Basic::new_with_options at line 26 of MouseX/Getopt/Basic.pm
sub does_role {
44297130µs my ($self, $role_name) = @_;
443
44497100µs (defined $role_name)
445 || $self->throw_error("You must supply a role name to look for");
446
44797157µs1521µs $role_name = $role_name->name if ref $role_name;
# spent 21µs making 15 calls to Mouse::Meta::Module::name, avg 1µs/call
448
44997655µs97220µs for my $class ($self->linearized_isa) {
# spent 220µs making 97 calls to Mouse::Meta::Class::linearized_isa, avg 2µs/call
450126463µs126355µs my $meta = Mouse::Util::get_metaclass_by_name($class)
# spent 355µs making 126 calls to Mouse::Meta::Module::_get_metaclass_by_name, avg 3µs/call
451 or next;
452
453100575µs100145µs for my $role (@{ $meta->roles }) {
# spent 145µs making 100 calls to Mouse::Meta::Class::roles, avg 1µs/call
454
45589519µs891.37ms return 1 if $role->does_role($role_name);
# spent 1.37ms making 89 calls to Mouse::Meta::Role::does_role, avg 15µs/call
456 }
457 }
458
4592688µs return 0;
460}
461
46214µs1;
463__END__
 
# spent 306µs within Mouse::Meta::Class::CORE:sort which was called 25 times, avg 12µs/call: # 25 times (306µs+0s) by Mouse::Meta::Class::_calculate_all_attributes at line 261, avg 12µs/call
sub Mouse::Meta::Class::CORE:sort; # opcode
# spent 104µs within Mouse::Meta::Class::CORE:subst which was called 68 times, avg 2µs/call: # 68 times (104µs+0s) by Mouse::Meta::Class::add_attribute at line 222, avg 2µs/call
sub Mouse::Meta::Class::CORE:subst; # opcode
# spent 1.13ms (308µs+820µs) within Mouse::Meta::Class::_initialize_object which was called 34 times, avg 33µs/call: # 28 times (235µs+710µs) by Mouse::Meta::Attribute::new at line 83 of Mouse/Meta/Attribute.pm, avg 34µs/call # 3 times (42µs+63µs) by Mouse::Meta::Role::_construct_meta at line 20 of Mouse/Meta/Role.pm, avg 35µs/call # 3 times (31µs+47µ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 103µs within Mouse::Meta::Class::attribute_metaclass which was called 61 times, avg 2µs/call: # 61 times (103µs+0s) by Mouse::Meta::Class::add_attribute at line 229, avg 2µs/call
sub Mouse::Meta::Class::attribute_metaclass; # xsub
# spent 13µs within Mouse::Meta::Class::constructor_class which was called 7 times, avg 2µs/call: # 7 times (13µs+0s) by Mouse::Meta::Class::make_immutable at line 290, avg 2µs/call
sub Mouse::Meta::Class::constructor_class; # xsub
# spent 10µs within Mouse::Meta::Class::destructor_class which was called 7 times, avg 1µs/call: # 7 times (10µs+0s) by Mouse::Meta::Class::make_immutable at line 296, avg 1µs/call
sub Mouse::Meta::Class::destructor_class; # xsub
# spent 3.22ms (236µs+2.98) within Mouse::Meta::Class::get_all_attributes which was called 26 times, avg 124µs/call: # 18 times (56µs+64µs) by Mouse::Meta::Attribute::new at line 69 of Mouse/Meta/Attribute.pm, avg 7µs/call # 7 times (150µs+2.48ms) by Mouse::Meta::Class::find_attribute_by_name at line 194, avg 376µs/call # once (31µs+437µs) by MouseX::Getopt::Basic::_compute_getopt_attrs at line 174 of MouseX/Getopt/Basic.pm
sub Mouse::Meta::Class::get_all_attributes; # xsub
# spent 23µs within Mouse::Meta::Class::is_anon_class which was called 16 times, avg 1µs/call: # 7 times (10µs+0s) by Mouse::Meta::Class::get_all_attributes at line 194, avg 1µs/call # 3 times (4µs+0s) by Mouse::Object::new at line 201 of lib/Hailo.pm, avg 1µs/call # 2 times (3µs+0s) by Mouse::Meta::Class::_initialize_object at line 83 of Mouse/Meta/Attribute.pm, avg 1µs/call # once (2µs+0s) by Mouse::Meta::Class::get_all_attributes at line 69 of Mouse/Meta/Attribute.pm # once (1µs+0s) by Mouse::Meta::Class::_initialize_object at line 20 of Mouse/Meta/Role.pm # once (1µs+0s) by Mouse::Meta::Class::get_all_attributes at line 174 of MouseX/Getopt/Basic.pm # once (1µ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 26µs within Mouse::Meta::Class::is_immutable which was called 16 times, avg 2µs/call: # 7 times (11µs+0s) by Mouse::Meta::Class::get_all_attributes at line 194, avg 2µs/call # 3 times (5µs+0s) by Mouse::Object::new at line 201 of lib/Hailo.pm, avg 2µs/call # 2 times (3µs+0s) by Mouse::Meta::Class::_initialize_object at line 83 of Mouse/Meta/Attribute.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::Meta::Class::_initialize_object at line 36 of Mouse/Meta/Role/Application.pm # once (2µs+0s) by Mouse::Meta::Class::get_all_attributes at line 174 of MouseX/Getopt/Basic.pm # once (2µs+0s) by Mouse::Meta::Class::get_all_attributes at line 69 of Mouse/Meta/Attribute.pm
sub Mouse::Meta::Class::is_immutable; # xsub
# spent 253µs within Mouse::Meta::Class::linearized_isa which was called 113 times, avg 2µs/call: # 97 times (220µs+0s) by Mouse::Meta::Class::does_role at line 449, avg 2µs/call # 16 times (33µs+0s) by Mouse::Meta::Class::_calculate_all_attributes at line 257, avg 2µs/call
sub Mouse::Meta::Class::linearized_isa; # xsub
# spent 145µs within Mouse::Meta::Class::roles which was called 100 times, avg 1µs/call: # 100 times (145µs+0s) by Mouse::Meta::Class::does_role at line 453, avg 1µs/call
sub Mouse::Meta::Class::roles; # xsub
# spent 59µs within Mouse::Meta::Class::strict_constructor which was called 21 times, avg 3µs/call: # 7 times (14µs+0s) by Mouse::Meta::Class::get_all_attributes at line 194, avg 2µs/call # 5 times (17µs+0s) by MouseX::StrictConstructor::init_meta at line 14 of MouseX/StrictConstructor.pm, avg 3µs/call # 3 times (7µs+0s) by Mouse::Object::new at line 201 of lib/Hailo.pm, avg 2µs/call # 2 times (10µs+0s) by Mouse::Meta::Class::_initialize_object at line 83 of Mouse/Meta/Attribute.pm, avg 5µs/call # once (3µs+0s) by Mouse::Meta::Class::get_all_attributes at line 69 of Mouse/Meta/Attribute.pm # 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::Meta::Class::get_all_attributes at line 174 of MouseX/Getopt/Basic.pm
sub Mouse::Meta::Class::strict_constructor; # xsub