| Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Module.pm |
| Statements | Executed 4184 statements in 13.6ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 298 | 4 | 4 | 2.38ms | 4.90ms | Mouse::Meta::Module::has_method |
| 260 | 2 | 1 | 2.13ms | 2.73ms | Mouse::Meta::Module::_get_method_body |
| 14 | 1 | 1 | 1.34ms | 4.97ms | Mouse::Meta::Module::get_method_list |
| 194 | 17 | 4 | 1.29ms | 2.03ms | Mouse::Meta::Module::initialize (recurses: max depth 1, inclusive time 47µs) |
| 199 | 10 | 7 | 1.28ms | 1.28ms | Mouse::Meta::Module::add_method (xsub) |
| 29 | 2 | 2 | 1.18ms | 3.41ms | Mouse::Meta::Module::create |
| 139 | 1 | 1 | 740µs | 740µs | Mouse::Meta::Module::_class_of |
| 223 | 6 | 4 | 661µs | 661µs | Mouse::Meta::Module::_get_metaclass_by_name |
| 56 | 1 | 1 | 366µs | 578µs | Mouse::Meta::Module::get_method_body |
| 198 | 7 | 4 | 276µs | 276µs | Mouse::Meta::Module::name (xsub) |
| 36 | 2 | 1 | 243µs | 438µs | Mouse::Meta::Class::__ANON__::2::meta |
| 9 | 4 | 2 | 122µs | 122µs | Mouse::Meta::Module::_collect_methods |
| 38 | 1 | 1 | 115µs | 115µs | Mouse::Meta::Module::get_attribute |
| 28 | 1 | 1 | 95µs | 95µs | Mouse::Meta::Module::has_attribute |
| 18 | 2 | 2 | 69µs | 69µs | Mouse::Meta::Module::get_attribute_list |
| 8 | 1 | 1 | 56µs | 101µs | Mouse::Meta::Class::__ANON__::1::meta |
| 34 | 2 | 2 | 53µs | 53µs | Mouse::Meta::Class::__ANON__::2::has_cmd_flag (xsub) |
| 26 | 1 | 1 | 41µs | 41µs | Mouse::Meta::Module::CORE:sort (opcode) |
| 14 | 1 | 1 | 37µs | 37µs | Mouse::Meta::Module::namespace (xsub) |
| 1 | 1 | 1 | 27µs | 124µs | Mouse::Meta::Module::BEGIN@2 |
| 17 | 1 | 1 | 26µs | 26µs | Mouse::Meta::Class::__ANON__::2::has_cmd_aliases (xsub) |
| 17 | 1 | 1 | 24µs | 24µs | Mouse::Meta::Class::__ANON__::2::cmd_flag (xsub) |
| 16 | 1 | 1 | 22µs | 22µs | Mouse::Meta::Class::__ANON__::2::cmd_aliases (xsub) |
| 1 | 1 | 1 | 12µs | 37µs | Mouse::Meta::Module::BEGIN@224 |
| 1 | 1 | 1 | 11µs | 33µs | Mouse::Meta::Module::BEGIN@303 |
| 1 | 1 | 1 | 6µs | 6µs | Mouse::Meta::Module::BEGIN@4 |
| 1 | 1 | 1 | 6µs | 6µs | Mouse::Meta::Module::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::DESTROY |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::__ANON__[:14] |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::__ANON__[:236] |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::_get_all_metaclass_instances |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::_get_all_metaclass_names |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::_metaclass_cache |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::get_attribute_map |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::get_method |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::reinitialize |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Module::remove_attribute |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Role::Composite::__ANON__::3::meta |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Role::Composite::__ANON__::4::meta |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Role::Composite::__ANON__::5::meta |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Mouse::Meta::Module; | ||||
| 2 | 2 | 30µs | 2 | 222µs | # spent 124µs (27+98) within Mouse::Meta::Module::BEGIN@2 which was called:
# once (27µs+98µs) by Mouse::BEGIN@4 at line 2 # spent 124µs making 1 call to Mouse::Meta::Module::BEGIN@2
# spent 98µs making 1 call to Mouse::Exporter::do_import |
| 3 | |||||
| 4 | 2 | 22µs | 1 | 6µs | # spent 6µs within Mouse::Meta::Module::BEGIN@4 which was called:
# once (6µs+0s) by Mouse::BEGIN@4 at line 4 # spent 6µs making 1 call to Mouse::Meta::Module::BEGIN@4 |
| 5 | 2 | 915µs | 1 | 6µs | # spent 6µs within Mouse::Meta::Module::BEGIN@5 which was called:
# once (6µs+0s) by Mouse::BEGIN@4 at line 5 # spent 6µs making 1 call to Mouse::Meta::Module::BEGIN@5 |
| 6 | |||||
| 7 | 1 | 1µs | my %METAS; | ||
| 8 | |||||
| 9 | 1 | 2µs | if(Mouse::Util::MOUSE_XS){ | ||
| 10 | # register meta storage for performance | ||||
| 11 | 1 | 8µs | 1 | 2µs | Mouse::Util::__register_metaclass_storage(\%METAS, 0); # spent 2µs making 1 call to Mouse::Util::__register_metaclass_storage |
| 12 | |||||
| 13 | # ensure thread safety | ||||
| 14 | 1 | 3µs | *CLONE = sub { Mouse::Util::__register_metaclass_storage(\%METAS, 1) }; | ||
| 15 | } | ||||
| 16 | |||||
| 17 | sub _metaclass_cache { # DEPRECATED | ||||
| 18 | my($self, $name) = @_; | ||||
| 19 | Carp::cluck('_metaclass_cache() has been deprecated. Use Mouse::Util::get_metaclass_by_name() instead'); | ||||
| 20 | return $METAS{$name}; | ||||
| 21 | } | ||||
| 22 | |||||
| 23 | # spent 2.03ms (1.29+747µs) within Mouse::Meta::Module::initialize which was called 194 times, avg 10µs/call:
# 50 times (290µs+0s) by Mouse::has at line 45 of Mouse.pm, avg 6µs/call
# 44 times (240µs+0s) by Mouse::Meta::Class::__ANON__::1::meta or Mouse::Meta::Class::__ANON__::2::meta at line 235, avg 5µs/call
# 15 times (153µs+237µs) by Mouse::init_meta at line 133 of Mouse.pm, avg 26µs/call
# 14 times (81µs+0s) by Mouse::Role::has at line 37 of Mouse/Role.pm, avg 6µs/call
# 11 times (72µs+0s) by Mouse::Util::apply_all_roles at line 276 of Mouse/Util.pm, avg 7µs/call
# 11 times (66µs+0s) by Hailo::Command::meta or Hailo::Engine::Default::meta or Hailo::Storage::SQLite::meta or Hailo::Storage::meta or Hailo::Tokenizer::Words::meta or Hailo::meta or MouseX::Getopt::Meta::Attribute::NoGetopt::meta or hailo::meta at line 136 of Mouse.pm, avg 6µs/call
# 11 times (59µs+0s) by Mouse::Role::requires at line 98 of Mouse/Role.pm, avg 5µs/call
# 10 times (118µs+207µs) by Mouse::Role::init_meta at line 117 of Mouse/Role.pm, avg 32µs/call
# 6 times (48µs+-9µs) by Mouse::Util::meta at line 345 of Mouse/Util.pm, avg 7µs/call
# 5 times (58µs+313µs) by Mouse::Meta::Module::create at line 229, avg 74µs/call
# 4 times (28µs+0s) by Mouse::extends at line 35 of Mouse.pm, avg 7µs/call
# 4 times (23µs+0s) by Mouse::before at line 58 of Mouse.pm, avg 6µs/call
# 3 times (17µs+0s) by Mouse::Role::around at line 68 of Mouse/Role.pm, avg 6µs/call
# 3 times (16µs+0s) by Mouse::override at line 98 of Mouse.pm, avg 5µs/call
# once (6µs+0s) by Mouse::around at line 76 of Mouse.pm
# once (6µs+0s) by MouseX::Getopt::GLD::meta at line 120 of Mouse/Role.pm
# once (5µs+0s) by Mouse::after at line 67 of Mouse.pm | ||||
| 24 | 194 | 318µs | my($class, $package_name, @args) = @_; | ||
| 25 | |||||
| 26 | 194 | 213µs | ($package_name && !ref($package_name)) | ||
| 27 | || $class->throw_error("You must pass a package name and it cannot be blessed"); | ||||
| 28 | |||||
| 29 | 194 | 957µs | 27 | 794µs | return $METAS{$package_name} # spent 474µs making 13 calls to Mouse::Meta::Role::_construct_meta, avg 36µs/call
# spent 320µs making 14 calls to Mouse::Meta::Class::_construct_meta, avg 23µs/call |
| 30 | ||= $class->_construct_meta(package => $package_name, @args); | ||||
| 31 | } | ||||
| 32 | |||||
| 33 | sub reinitialize { | ||||
| 34 | my($class, $package_name, @args) = @_; | ||||
| 35 | |||||
| 36 | $package_name = $package_name->name if ref $package_name; | ||||
| 37 | |||||
| 38 | ($package_name && !ref($package_name)) | ||||
| 39 | || $class->throw_error("You must pass a package name and it cannot be blessed"); | ||||
| 40 | |||||
| 41 | if(exists $METAS{$package_name}) { | ||||
| 42 | unshift @args, %{ $METAS{$package_name} }; | ||||
| 43 | } | ||||
| 44 | delete $METAS{$package_name}; | ||||
| 45 | return $class->initialize($package_name, @args); | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | # spent 740µs within Mouse::Meta::Module::_class_of which was called 139 times, avg 5µs/call:
# 139 times (740µs+0s) by Mouse::Util::does_role at line 120 of Mouse/Util.pm, avg 5µs/call | ||||
| 49 | 139 | 161µs | my($class_or_instance) = @_; | ||
| 50 | 139 | 151µs | return undef unless defined $class_or_instance; | ||
| 51 | 139 | 540µs | return $METAS{ ref($class_or_instance) || $class_or_instance }; | ||
| 52 | } | ||||
| 53 | |||||
| 54 | # Means of accessing all the metaclasses that have | ||||
| 55 | # been initialized thus far | ||||
| 56 | #sub _get_all_metaclasses { %METAS } | ||||
| 57 | sub _get_all_metaclass_instances { values %METAS } | ||||
| 58 | sub _get_all_metaclass_names { keys %METAS } | ||||
| 59 | 223 | 845µs | # spent 661µs within Mouse::Meta::Module::_get_metaclass_by_name which was called 223 times, avg 3µs/call:
# 126 times (355µs+0s) by Mouse::Meta::Class::does_role at line 450 of Mouse/Meta/Class.pm, avg 3µs/call
# 42 times (125µs+0s) by Mouse::Meta::Class::_calculate_all_attributes at line 258 of Mouse/Meta/Class.pm, avg 3µs/call
# 19 times (64µs+0s) by Any::Moose::_backer_of at line 103 of Any/Moose.pm, avg 3µs/call
# 16 times (50µs+0s) by Mouse::Meta::Class::superclasses at line 59 of Mouse/Meta/Class.pm, avg 3µs/call
# 14 times (48µs+0s) by Mouse::Util::apply_all_roles at line 293 of Mouse/Util.pm, avg 3µs/call
# 6 times (20µs+0s) by Mouse::Util::TypeConstraints::_find_or_create_regular_type at line 270 of Mouse/Util/TypeConstraints.pm, avg 3µs/call | ||
| 60 | #sub _store_metaclass_by_name { $METAS{$_[0]} = $_[1] } | ||||
| 61 | #sub _weaken_metaclass { weaken($METAS{$_[0]}) } | ||||
| 62 | #sub _does_metaclass_exist { defined $METAS{$_[0]} } | ||||
| 63 | #sub _remove_metaclass_by_name { delete $METAS{$_[0]} } | ||||
| 64 | |||||
| 65 | sub name; | ||||
| 66 | |||||
| 67 | sub namespace; | ||||
| 68 | |||||
| 69 | # add_attribute is an abstract method | ||||
| 70 | |||||
| 71 | sub get_attribute_map { # DEPRECATED | ||||
| 72 | Carp::cluck('get_attribute_map() has been deprecated. Use get_attribute_list() and get_attribute() instead'); | ||||
| 73 | return $_[0]->{attributes}; | ||||
| 74 | } | ||||
| 75 | |||||
| 76 | 28 | 124µs | # spent 95µs within Mouse::Meta::Module::has_attribute which was called 28 times, avg 3µs/call:
# 28 times (95µs+0s) by Mouse::Meta::Role::Application::apply_attributes at line 154 of Mouse/Meta/Role/Application.pm, avg 3µs/call | ||
| 77 | 38 | 153µs | # spent 115µs within Mouse::Meta::Module::get_attribute which was called 38 times, avg 3µs/call:
# 38 times (115µs+0s) by Mouse::Meta::Role::Application::apply_attributes at line 156 of Mouse/Meta/Role/Application.pm, avg 3µs/call | ||
| 78 | sub remove_attribute { delete $_[0]->{attributes}->{$_[1]} } | ||||
| 79 | |||||
| 80 | 18 | 90µs | # spent 69µs within Mouse::Meta::Module::get_attribute_list which was called 18 times, avg 4µs/call:
# 17 times (65µs+0s) by Mouse::Meta::Role::Application::apply_attributes at line 153 of Mouse/Meta/Role/Application.pm, avg 4µs/call
# once (4µs+0s) by hailo::BEGIN@8 at line 18 of lib/Hailo/Command.pm | ||
| 81 | |||||
| 82 | # XXX: not completely compatible with Moose | ||||
| 83 | 1 | 9µs | my %foreign = map{ $_ => undef } qw( | ||
| 84 | Mouse Mouse::Role Mouse::Util Mouse::Util::TypeConstraints | ||||
| 85 | Carp Scalar::Util List::Util | ||||
| 86 | ); | ||||
| 87 | sub _get_method_body { | ||||
| 88 | 260 | 300µs | my($self, $method_name) = @_; | ||
| 89 | 260 | 1.49ms | 260 | 524µs | my $code = Mouse::Util::get_code_ref($self->{package}, $method_name); # spent 524µs making 260 calls to Mouse::Util::get_code_ref, avg 2µs/call |
| 90 | 260 | 1.12ms | 52 | 83µs | return $code && !exists $foreign{ Mouse::Util::get_code_package($code) } # spent 83µs making 52 calls to Mouse::Util::get_code_package, avg 2µs/call |
| 91 | ? $code | ||||
| 92 | : undef; | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | sub add_method; | ||||
| 96 | |||||
| 97 | # spent 4.90ms (2.38+2.52) within Mouse::Meta::Module::has_method which was called 298 times, avg 16µs/call:
# 228 times (1.78ms+1.82ms) by Mouse::Meta::Module::get_method_list at line 133, avg 16µs/call
# 56 times (474µs+550µs) by Mouse::Meta::Role::Application::apply_methods at line 126 of Mouse/Meta/Role/Application.pm, avg 18µs/call
# 11 times (102µs+121µs) by Mouse::Meta::Role::add_required_methods at line 49 of Mouse/Meta/Role.pm, avg 20µs/call
# 3 times (26µs+31µs) by Mouse::Meta::Class::add_override_method_modifier at line 403 of Mouse/Meta/Class.pm, avg 19µs/call | ||||
| 98 | 298 | 398µs | my($self, $method_name) = @_; | ||
| 99 | 298 | 297µs | defined($method_name) | ||
| 100 | or $self->throw_error('You must define a method name'); | ||||
| 101 | |||||
| 102 | 298 | 1.73ms | 244 | 2.52ms | return defined( $self->{methods}{$method_name} ) # spent 2.52ms making 244 calls to Mouse::Meta::Module::_get_method_body, avg 10µs/call |
| 103 | || defined( $self->_get_method_body($method_name) ); | ||||
| 104 | } | ||||
| 105 | |||||
| 106 | # spent 578µs (366+212) within Mouse::Meta::Module::get_method_body which was called 56 times, avg 10µs/call:
# 56 times (366µs+212µs) by Mouse::Meta::Role::Application::apply_methods at line 124 of Mouse/Meta/Role/Application.pm, avg 10µs/call | ||||
| 107 | 56 | 78µs | my($self, $method_name) = @_; | ||
| 108 | 56 | 57µs | defined($method_name) | ||
| 109 | or $self->throw_error('You must define a method name'); | ||||
| 110 | |||||
| 111 | 56 | 266µs | 16 | 212µs | return $self->{methods}{$method_name} # spent 212µs making 16 calls to Mouse::Meta::Module::_get_method_body, avg 13µs/call |
| 112 | ||= $self->_get_method_body($method_name); | ||||
| 113 | } | ||||
| 114 | |||||
| 115 | sub get_method { | ||||
| 116 | my($self, $method_name) = @_; | ||||
| 117 | |||||
| 118 | if(my $code = $self->get_method_body($method_name)){ | ||||
| 119 | return Mouse::Util::load_class($self->method_metaclass)->wrap( | ||||
| 120 | body => $code, | ||||
| 121 | name => $method_name, | ||||
| 122 | package => $self->name, | ||||
| 123 | associated_metaclass => $self, | ||||
| 124 | ); | ||||
| 125 | } | ||||
| 126 | |||||
| 127 | return undef; | ||||
| 128 | } | ||||
| 129 | |||||
| 130 | # spent 4.97ms (1.34+3.64) within Mouse::Meta::Module::get_method_list which was called 14 times, avg 355µs/call:
# 14 times (1.34ms+3.64ms) by Mouse::Meta::Role::Application::apply_methods at line 121 of Mouse/Meta/Role/Application.pm, avg 355µs/call | ||||
| 131 | 14 | 19µs | my($self) = @_; | ||
| 132 | |||||
| 133 | 242 | 1.21ms | 242 | 3.64ms | return grep { $self->has_method($_) } keys %{ $self->namespace }; # spent 3.60ms making 228 calls to Mouse::Meta::Module::has_method, avg 16µs/call
# spent 37µs making 14 calls to Mouse::Meta::Module::namespace, avg 3µs/call |
| 134 | } | ||||
| 135 | |||||
| 136 | # spent 122µs within Mouse::Meta::Module::_collect_methods which was called 9 times, avg 14µs/call:
# 4 times (53µs+0s) by Mouse::before at line 60 of Mouse.pm, avg 13µs/call
# 3 times (42µs+0s) by Mouse::Role::around at line 70 of Mouse/Role.pm, avg 14µs/call
# once (14µs+0s) by Mouse::around at line 78 of Mouse.pm
# once (13µs+0s) by Mouse::after at line 69 of Mouse.pm | ||||
| 137 | 9 | 15µs | my($meta, @args) = @_; | ||
| 138 | |||||
| 139 | 9 | 8µs | my @methods; | ||
| 140 | 9 | 24µs | foreach my $arg(@args){ | ||
| 141 | 9 | 33µs | if(my $type = ref $arg){ | ||
| 142 | if($type eq 'Regexp'){ | ||||
| 143 | push @methods, grep { $_ =~ $arg } $meta->get_all_method_names; | ||||
| 144 | } | ||||
| 145 | elsif($type eq 'ARRAY'){ | ||||
| 146 | push @methods, @{$arg}; | ||||
| 147 | } | ||||
| 148 | else{ | ||||
| 149 | my $subname = ( caller(1) )[3]; | ||||
| 150 | $meta->throw_error( | ||||
| 151 | sprintf( | ||||
| 152 | 'Methods passed to %s must be provided as a list,' | ||||
| 153 | . ' ArrayRef or regular expression, not %s', | ||||
| 154 | $subname, | ||||
| 155 | $type, | ||||
| 156 | ) | ||||
| 157 | ); | ||||
| 158 | } | ||||
| 159 | } | ||||
| 160 | else{ | ||||
| 161 | 9 | 12µs | push @methods, $arg; | ||
| 162 | } | ||||
| 163 | } | ||||
| 164 | 9 | 39µs | return @methods; | ||
| 165 | } | ||||
| 166 | |||||
| 167 | 1 | 1µs | my $ANON_SERIAL = 0; # anonymous class/role id | ||
| 168 | 1 | 700ns | my %IMMORTALS; # immortal anonymous classes | ||
| 169 | |||||
| 170 | # spent 3.41ms (1.18+2.23) within Mouse::Meta::Module::create which was called 29 times, avg 118µs/call:
# 26 times (987µs+1.83ms) by Mouse::Meta::Class::create_anon_class at line 39 of Mouse/Meta/Class.pm, avg 108µs/call
# 3 times (190µs+404µs) by Mouse::Meta::Role::create_anon_role at line 28 of Mouse/Meta/Role.pm, avg 198µs/call | ||||
| 171 | 29 | 67µs | my($self, $package_name, %options) = @_; | ||
| 172 | |||||
| 173 | 29 | 37µs | my $class = ref($self) || $self; | ||
| 174 | 29 | 34µs | $self->throw_error('You must pass a package name') if @_ < 2; | ||
| 175 | |||||
| 176 | 29 | 25µs | my $superclasses; | ||
| 177 | 29 | 58µs | if(exists $options{superclasses}){ | ||
| 178 | 26 | 160µs | 26 | 39µs | if(Mouse::Util::is_a_metarole($self)){ # spent 39µs making 26 calls to Mouse::Util::is_a_metarole, avg 1µs/call |
| 179 | delete $options{superclasses}; | ||||
| 180 | } | ||||
| 181 | else{ | ||||
| 182 | 26 | 39µs | $superclasses = delete $options{superclasses}; | ||
| 183 | 26 | 37µs | (ref $superclasses eq 'ARRAY') | ||
| 184 | || $self->throw_error("You must pass an ARRAY ref of superclasses"); | ||||
| 185 | } | ||||
| 186 | } | ||||
| 187 | |||||
| 188 | 29 | 33µs | my $attributes = delete $options{attributes}; | ||
| 189 | 29 | 29µs | if(defined $attributes){ | ||
| 190 | (ref $attributes eq 'ARRAY' || ref $attributes eq 'HASH') | ||||
| 191 | || $self->throw_error("You must pass an ARRAY ref of attributes"); | ||||
| 192 | } | ||||
| 193 | 29 | 31µs | my $methods = delete $options{methods}; | ||
| 194 | 29 | 24µs | if(defined $methods){ | ||
| 195 | (ref $methods eq 'HASH') | ||||
| 196 | || $self->throw_error("You must pass a HASH ref of methods"); | ||||
| 197 | } | ||||
| 198 | 29 | 34µs | my $roles = delete $options{roles}; | ||
| 199 | 29 | 33µs | if(defined $roles){ | ||
| 200 | (ref $roles eq 'ARRAY') | ||||
| 201 | || $self->throw_error("You must pass an ARRAY ref of roles"); | ||||
| 202 | } | ||||
| 203 | 29 | 26µs | my $mortal; | ||
| 204 | 29 | 22µs | my $cache_key; | ||
| 205 | |||||
| 206 | 29 | 34µs | if(!defined $package_name){ # anonymous | ||
| 207 | 29 | 39µs | $mortal = !$options{cache}; | ||
| 208 | |||||
| 209 | # anonymous but immortal | ||||
| 210 | 29 | 33µs | if(!$mortal){ | ||
| 211 | # something like Super::Class|Super::Class::2=Role|Role::1 | ||||
| 212 | $cache_key = join '=' => ( | ||||
| 213 | join('|', @{$superclasses || []}), | ||||
| 214 | 26 | 157µs | 26 | 41µs | join('|', sort @{$roles || []}), # spent 41µs making 26 calls to Mouse::Meta::Module::CORE:sort, avg 2µs/call |
| 215 | ); | ||||
| 216 | 26 | 122µs | return $IMMORTALS{$cache_key} if exists $IMMORTALS{$cache_key}; | ||
| 217 | } | ||||
| 218 | 5 | 9µs | $options{anon_serial_id} = ++$ANON_SERIAL; | ||
| 219 | 5 | 11µs | $package_name = $class . '::__ANON__::' . $ANON_SERIAL; | ||
| 220 | } | ||||
| 221 | |||||
| 222 | # instantiate a module | ||||
| 223 | { | ||||
| 224 | 7 | 327µs | 2 | 62µs | # spent 37µs (12+25) within Mouse::Meta::Module::BEGIN@224 which was called:
# once (12µs+25µs) by Mouse::BEGIN@4 at line 224 # spent 37µs making 1 call to Mouse::Meta::Module::BEGIN@224
# spent 25µs making 1 call to strict::unimport |
| 225 | 5 | 8µs | ${ $package_name . '::VERSION' } = delete $options{version} if exists $options{version}; | ||
| 226 | 5 | 7µs | ${ $package_name . '::AUTHORITY' } = delete $options{authority} if exists $options{authority}; | ||
| 227 | } | ||||
| 228 | |||||
| 229 | 5 | 31µs | 5 | 371µs | my $meta = $self->initialize( $package_name, %options); # spent 371µs making 5 calls to Mouse::Meta::Module::initialize, avg 74µs/call |
| 230 | |||||
| 231 | 5 | 24µs | 3 | 7µs | Scalar::Util::weaken($METAS{$package_name}) # spent 7µs making 3 calls to Scalar::Util::weaken, avg 2µs/call |
| 232 | if $mortal; | ||||
| 233 | |||||
| 234 | # spent 101µs (56+45) within Mouse::Meta::Class::__ANON__::1::meta which was called 8 times, avg 13µs/call:
# 8 times (56µs+45µs) by Mouse::Meta::Attribute::new at line 83 of Mouse/Meta/Attribute.pm, avg 13µs/call
# spent 438µs (243+195) within Mouse::Meta::Class::__ANON__::2::meta which was called 36 times, avg 12µs/call:
# 18 times (124µs+99µs) by Mouse::Meta::Attribute::new at line 69 of Mouse/Meta/Attribute.pm, avg 12µs/call
# 18 times (120µs+96µs) by Mouse::Meta::Attribute::new at line 83 of Mouse/Meta/Attribute.pm, avg 12µs/call | ||||
| 235 | 44 | 263µs | 44 | 240µs | $self->initialize(ref($_[0]) || $_[0]); # spent 240µs making 44 calls to Mouse::Meta::Module::initialize, avg 5µs/call |
| 236 | 5 | 54µs | 5 | 115µs | }); # spent 95µs making 3 calls to Mouse::Meta::Role::Composite::add_method, avg 32µs/call
# spent 20µs making 2 calls to Mouse::Meta::Module::add_method, avg 10µs/call |
| 237 | |||||
| 238 | 5 | 11µs | 2 | 133µs | $meta->superclasses(@{$superclasses}) # spent 133µs making 2 calls to Mouse::Meta::Class::superclasses, avg 67µs/call |
| 239 | if defined $superclasses; | ||||
| 240 | |||||
| 241 | # NOTE: | ||||
| 242 | # process attributes first, so that they can | ||||
| 243 | # install accessors, but locally defined methods | ||||
| 244 | # can then overwrite them. It is maybe a little odd, but | ||||
| 245 | # I think this should be the order of things. | ||||
| 246 | 5 | 6µs | if (defined $attributes) { | ||
| 247 | if(ref($attributes) eq 'ARRAY'){ | ||||
| 248 | # array of Mouse::Meta::Attribute | ||||
| 249 | foreach my $attr (@{$attributes}) { | ||||
| 250 | $meta->add_attribute($attr); | ||||
| 251 | } | ||||
| 252 | } | ||||
| 253 | else{ | ||||
| 254 | # hash map of name and attribute spec pairs | ||||
| 255 | while(my($name, $attr) = each %{$attributes}){ | ||||
| 256 | $meta->add_attribute($name => $attr); | ||||
| 257 | } | ||||
| 258 | } | ||||
| 259 | } | ||||
| 260 | 5 | 6µs | if (defined $methods) { | ||
| 261 | while(my($method_name, $method_body) = each %{$methods}){ | ||||
| 262 | $meta->add_method($method_name, $method_body); | ||||
| 263 | } | ||||
| 264 | } | ||||
| 265 | 5 | 12µs | 2 | 0s | if (defined $roles){ # spent 1.53ms making 2 calls to Mouse::Util::apply_all_roles, avg 763µs/call, recursion: max depth 1, sum of overlapping time 1.53ms |
| 266 | Mouse::Util::apply_all_roles($package_name, @{$roles}); | ||||
| 267 | } | ||||
| 268 | |||||
| 269 | 5 | 8µs | if($cache_key){ | ||
| 270 | $IMMORTALS{$cache_key} = $meta; | ||||
| 271 | } | ||||
| 272 | |||||
| 273 | 5 | 23µs | return $meta; | ||
| 274 | } | ||||
| 275 | |||||
| 276 | sub DESTROY{ | ||||
| 277 | my($self) = @_; | ||||
| 278 | |||||
| 279 | return if $Mouse::Util::in_global_destruction; | ||||
| 280 | |||||
| 281 | my $serial_id = $self->{anon_serial_id}; | ||||
| 282 | return if !$serial_id; | ||||
| 283 | |||||
| 284 | # XXX: cleaning stash with threads causes panic/SEGV on legacy perls. | ||||
| 285 | if(exists $INC{'threads.pm'}) { | ||||
| 286 | # (caller)[2] indicates the caller's line number, | ||||
| 287 | # which is zero when the current thread is joining (destroying). | ||||
| 288 | return if( (caller)[2] == 0); | ||||
| 289 | } | ||||
| 290 | |||||
| 291 | # clean up mortal anonymous class stuff | ||||
| 292 | |||||
| 293 | # @ISA is a magical variable, so we must clear it manually. | ||||
| 294 | @{$self->{superclasses}} = () if exists $self->{superclasses}; | ||||
| 295 | |||||
| 296 | # Then, clear the symbol table hash | ||||
| 297 | %{$self->namespace} = (); | ||||
| 298 | |||||
| 299 | my $name = $self->name; | ||||
| 300 | delete $METAS{$name}; | ||||
| 301 | |||||
| 302 | $name =~ s/ $serial_id \z//xms; | ||||
| 303 | 2 | 52µs | 2 | 55µs | # spent 33µs (11+22) within Mouse::Meta::Module::BEGIN@303 which was called:
# once (11µs+22µs) by Mouse::BEGIN@4 at line 303 # spent 33µs making 1 call to Mouse::Meta::Module::BEGIN@303
# spent 22µs making 1 call to strict::unimport |
| 304 | delete ${$name}{ $serial_id . '::' }; | ||||
| 305 | return; | ||||
| 306 | } | ||||
| 307 | |||||
| 308 | |||||
| 309 | 1 | 6µs | 1; | ||
| 310 | __END__ | ||||
# spent 22µs within Mouse::Meta::Class::__ANON__::2::cmd_aliases which was called 16 times, avg 1µs/call:
# 16 times (22µs+0s) by MouseX::Getopt::Basic::_get_cmd_flags_for_attr at line 187 of MouseX/Getopt/Basic.pm, avg 1µs/call | |||||
# spent 24µs within Mouse::Meta::Class::__ANON__::2::cmd_flag which was called 17 times, avg 1µs/call:
# 17 times (24µs+0s) by MouseX::Getopt::Basic::_get_cmd_flags_for_attr at line 186 of MouseX/Getopt/Basic.pm, avg 1µs/call | |||||
# spent 26µs within Mouse::Meta::Class::__ANON__::2::has_cmd_aliases which was called 17 times, avg 2µs/call:
# 17 times (26µs+0s) by MouseX::Getopt::Basic::_get_cmd_flags_for_attr at line 187 of MouseX/Getopt/Basic.pm, avg 2µs/call | |||||
# spent 53µs within Mouse::Meta::Class::__ANON__::2::has_cmd_flag which was called 34 times, avg 2µs/call:
# 17 times (27µs+0s) by MouseX::Getopt::Basic::_get_cmd_flags_for_attr at line 186 of MouseX/Getopt/Basic.pm, avg 2µs/call
# 17 times (26µs+0s) by MouseX::Getopt::Dashes::__ANON__[/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/MouseX/Getopt/Dashes.pm:24] at line 19 of MouseX/Getopt/Dashes.pm, avg 2µs/call | |||||
# spent 41µs within Mouse::Meta::Module::CORE:sort which was called 26 times, avg 2µs/call:
# 26 times (41µs+0s) by Mouse::Meta::Module::create at line 214, avg 2µs/call | |||||
# spent 1.28ms within Mouse::Meta::Module::add_method which was called 199 times, avg 6µs/call:
# 90 times (595µs+0s) by Mouse::Meta::Attribute::install_accessors at line 258 of Mouse/Meta/Attribute.pm, avg 7µs/call
# 53 times (261µs+0s) by Mouse::Meta::Role::Application::apply_methods at line 126 of Mouse/Meta/Role/Application.pm, avg 5µs/call
# 15 times (123µs+0s) by Mouse::init_meta at line 137 of Mouse.pm, avg 8µs/call
# 10 times (92µs+0s) by Mouse::Role::init_meta at line 121 of Mouse/Role.pm, avg 9µs/call
# 9 times (58µs+0s) by Mouse::Meta::Class::_install_modifier at line 366 of Mouse/Meta/Class.pm, avg 6µs/call
# 7 times (42µs+0s) by Mouse::Meta::Class::make_immutable at line 290 of Mouse/Meta/Class.pm, avg 6µs/call
# 7 times (31µs+0s) by Mouse::Meta::Class::make_immutable at line 296 of Mouse/Meta/Class.pm, avg 4µs/call
# 3 times (34µs+0s) by Mouse::Meta::Role::Composite::add_method at line 39 of Mouse/Meta/Role/Composite.pm, avg 11µs/call
# 3 times (22µs+0s) by Mouse::Meta::Class::add_override_method_modifier at line 417 of Mouse/Meta/Class.pm, avg 7µs/call
# 2 times (20µs+0s) by Mouse::Meta::Module::create at line 236, avg 10µs/call | |||||
# spent 276µs within Mouse::Meta::Module::name which was called 198 times, avg 1µs/call:
# 126 times (166µs+0s) by Mouse::Meta::Role::does_role at line 117 of Mouse/Meta/Role.pm, avg 1µs/call
# 26 times (43µs+0s) by Mouse::Meta::Attribute::interpolate_class at line 129 of Mouse/Meta/Attribute.pm, avg 2µs/call
# 15 times (21µs+0s) by Mouse::Meta::Class::does_role at line 447 of Mouse/Meta/Class.pm, avg 1µs/call
# 11 times (16µs+0s) by Mouse::Meta::Role::does_role at line 114 of Mouse/Meta/Role.pm, avg 1µs/call
# 9 times (12µs+0s) by Mouse::Meta::Class::_install_modifier at line 318 of Mouse/Meta/Class.pm, avg 1µs/call
# 8 times (12µs+0s) by Mouse::Meta::Role::Application::check_required_methods at line 93 of Mouse/Meta/Role/Application.pm, avg 2µs/call
# 3 times (5µs+0s) by Mouse::Meta::Class::add_override_method_modifier at line 407 of Mouse/Meta/Class.pm, avg 2µs/call | |||||
# spent 37µs within Mouse::Meta::Module::namespace which was called 14 times, avg 3µs/call:
# 14 times (37µs+0s) by Mouse::Meta::Module::get_method_list at line 133, avg 3µs/call |