| Filename | /usr/share/perl5/Moo.pm |
| Statements | Executed 264 statements in 2.32ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 419µs | 470µs | Moo::BEGIN@5 |
| 2 | 2 | 2 | 180µs | 717µs | Moo::import |
| 7 | 7 | 1 | 126µs | 2.82ms | Moo::has |
| 8 | 2 | 2 | 94µs | 1.35ms | Moo::_constructor_maker_for |
| 12 | 4 | 1 | 52µs | 210µs | Moo::_install_tracked |
| 9 | 2 | 1 | 41µs | 80µs | Moo::_accessor_maker_for |
| 1 | 1 | 1 | 19µs | 70µs | Moo::BEGIN@3 |
| 7 | 1 | 1 | 12µs | 12µs | Moo::_maybe_reset_handlemoose |
| 1 | 1 | 1 | 11µs | 18µs | Moo::BEGIN@73 |
| 1 | 1 | 1 | 10µs | 24µs | Moo::BEGIN@108 |
| 1 | 1 | 1 | 9µs | 55µs | Moo::BEGIN@4 |
| 1 | 1 | 1 | 5µs | 9µs | Moo::__ANON__[:183] |
| 0 | 0 | 0 | 0s | 0s | Moo::__ANON__[:33] |
| 0 | 0 | 0 | 0s | 0s | Moo::__ANON__[:38] |
| 0 | 0 | 0 | 0s | 0s | Moo::__ANON__[:59] |
| 0 | 0 | 0 | 0s | 0s | Moo::__ANON__[:65] |
| 0 | 0 | 0 | 0s | 0s | Moo::_concrete_methods_of |
| 0 | 0 | 0 | 0s | 0s | Moo::_set_superclasses |
| 0 | 0 | 0 | 0s | 0s | Moo::after |
| 0 | 0 | 0 | 0s | 0s | Moo::around |
| 0 | 0 | 0 | 0s | 0s | Moo::before |
| 0 | 0 | 0 | 0s | 0s | Moo::extends |
| 0 | 0 | 0 | 0s | 0s | Moo::unimport |
| 0 | 0 | 0 | 0s | 0s | Moo::with |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moo; | ||||
| 2 | |||||
| 3 | 3 | 36µs | 3 | 121µs | # spent 70µs (19+51) within Moo::BEGIN@3 which was called:
# once (19µs+51µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 3 # spent 70µs making 1 call to Moo::BEGIN@3
# spent 28µs making 1 call to strictures::import
# spent 23µs making 1 call to strictures::VERSION |
| 4 | 2 | 72µs | 2 | 100µs | # spent 55µs (9+46) within Moo::BEGIN@4 which was called:
# once (9µs+46µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 4 # spent 55µs making 1 call to Moo::BEGIN@4
# spent 46µs making 1 call to Exporter::import |
| 5 | 2 | 626µs | 1 | 470µs | # spent 470µs (419+50) within Moo::BEGIN@5 which was called:
# once (419µs+50µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 5 # spent 470µs making 1 call to Moo::BEGIN@5 |
| 6 | |||||
| 7 | 1 | 400ns | our $VERSION = '1.006001'; | ||
| 8 | 1 | 15µs | $VERSION = eval $VERSION; # spent 2µs executing statements in string eval | ||
| 9 | |||||
| 10 | 1 | 104µs | require Moo::sification; | ||
| 11 | |||||
| 12 | 1 | 200ns | our %MAKERS; | ||
| 13 | |||||
| 14 | # spent 210µs (52+157) within Moo::_install_tracked which was called 12 times, avg 17µs/call:
# 6 times (21µs+70µs) by Moo::import at line 65, avg 15µs/call
# 2 times (13µs+40µs) by Moo::import at line 33, avg 27µs/call
# 2 times (11µs+24µs) by Moo::import at line 59, avg 17µs/call
# 2 times (7µs+24µs) by Moo::import at line 38, avg 15µs/call | ||||
| 15 | 12 | 6µs | my ($target, $name, $code) = @_; | ||
| 16 | 12 | 15µs | $MAKERS{$target}{exports}{$name} = $code; | ||
| 17 | 12 | 34µs | 12 | 157µs | _install_coderef "${target}::${name}" => "Moo::${name}" => $code; # spent 157µs making 12 calls to Moo::_Utils::_install_coderef, avg 13µs/call |
| 18 | } | ||||
| 19 | |||||
| 20 | # spent 717µs (180+537) within Moo::import which was called 2 times, avg 358µs/call:
# once (116µs+302µs) by Method::Generate::Constructor::BEGIN@202 at line 202 of Method/Generate/Constructor.pm
# once (64µs+234µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 29 of DBIx/Class/Storage/BlockRunner.pm | ||||
| 21 | 2 | 2µs | my $target = caller; | ||
| 22 | 2 | 800ns | my $class = shift; | ||
| 23 | 2 | 4µs | 2 | 43µs | _set_loaded(caller); # spent 43µs making 2 calls to Moo::_Utils::_set_loaded, avg 22µs/call |
| 24 | 2 | 13µs | 2 | 279µs | strictures->import::into(1); # spent 279µs making 2 calls to import::into, avg 140µs/call |
| 25 | 2 | 1µs | if ($INC{'Role/Tiny.pm'} and Role::Tiny->is_role($target)) { | ||
| 26 | die "Cannot import Moo into a role"; | ||||
| 27 | } | ||||
| 28 | 2 | 2µs | $MAKERS{$target} ||= {}; | ||
| 29 | _install_tracked $target => extends => sub { | ||||
| 30 | $class->_set_superclasses($target, @_); | ||||
| 31 | $class->_maybe_reset_handlemoose($target); | ||||
| 32 | return; | ||||
| 33 | 2 | 8µs | 2 | 53µs | }; # spent 53µs making 2 calls to Moo::_install_tracked, avg 27µs/call |
| 34 | _install_tracked $target => with => sub { | ||||
| 35 | require Moo::Role; | ||||
| 36 | Moo::Role->apply_roles_to_package($target, @_); | ||||
| 37 | $class->_maybe_reset_handlemoose($target); | ||||
| 38 | 2 | 6µs | 2 | 31µs | }; # spent 31µs making 2 calls to Moo::_install_tracked, avg 15µs/call |
| 39 | # spent 2.82ms (126µs+2.70) within Moo::has which was called 7 times, avg 403µs/call:
# once (26µs+1.32ms) by DBIx::Class::Storage::BEGIN@16 at line 46 of DBIx/Class/Storage/BlockRunner.pm
# once (16µs+407µs) by DBIx::Class::Storage::BEGIN@16 at line 66 of DBIx/Class/Storage/BlockRunner.pm
# once (18µs+392µs) by DBIx::Class::Storage::BEGIN@16 at line 78 of DBIx/Class/Storage/BlockRunner.pm
# once (23µs+268µs) by DBIx::Class::Storage::BEGIN@16 at line 92 of DBIx/Class/Storage/BlockRunner.pm
# once (14µs+120µs) by DBIx::Class::Storage::BEGIN@16 at line 57 of DBIx/Class/Storage/BlockRunner.pm
# once (14µs+99µs) by DBIx::Class::Storage::BEGIN@16 at line 73 of DBIx/Class/Storage/BlockRunner.pm
# once (14µs+93µs) by DBIx::Class::Storage::BEGIN@16 at line 51 of DBIx/Class/Storage/BlockRunner.pm | ||||
| 40 | 7 | 2µs | my $name_proto = shift; | ||
| 41 | 7 | 6µs | my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto; | ||
| 42 | 7 | 4µs | if (@_ % 2 != 0) { | ||
| 43 | require Carp; | ||||
| 44 | Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto) | ||||
| 45 | . " attribute(s): even number of arguments expected, got " . scalar @_) | ||||
| 46 | } | ||||
| 47 | 7 | 15µs | my %spec = @_; | ||
| 48 | 7 | 4µs | foreach my $name (@name_proto) { | ||
| 49 | # Note that when multiple attributes specified, each attribute | ||||
| 50 | # needs a separate \%specs hashref | ||||
| 51 | 7 | 5µs | my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec; | ||
| 52 | 7 | 16µs | 14 | 1.23ms | $class->_constructor_maker_for($target) # spent 1.18ms making 7 calls to Moo::_constructor_maker_for, avg 168µs/call
# spent 56µs making 7 calls to Method::Generate::Constructor::register_attribute_specs, avg 8µs/call |
| 53 | ->register_attribute_specs($name, $spec_ref); | ||||
| 54 | 7 | 17µs | 14 | 1.45ms | $class->_accessor_maker_for($target) # spent 1.44ms making 7 calls to Method::Generate::Accessor::generate_method, avg 206µs/call
# spent 12µs making 7 calls to Moo::_accessor_maker_for, avg 2µs/call |
| 55 | ->generate_method($target, $name, $spec_ref); | ||||
| 56 | 7 | 18µs | 7 | 12µs | $class->_maybe_reset_handlemoose($target); # spent 12µs making 7 calls to Moo::_maybe_reset_handlemoose, avg 2µs/call |
| 57 | } | ||||
| 58 | 7 | 21µs | return; | ||
| 59 | 2 | 9µs | 2 | 34µs | }; # spent 34µs making 2 calls to Moo::_install_tracked, avg 17µs/call |
| 60 | 2 | 2µs | foreach my $type (qw(before after around)) { | ||
| 61 | _install_tracked $target => $type => sub { | ||||
| 62 | require Class::Method::Modifiers; | ||||
| 63 | _install_modifier($target, $type, @_); | ||||
| 64 | return; | ||||
| 65 | 6 | 28µs | 6 | 91µs | }; # spent 91µs making 6 calls to Moo::_install_tracked, avg 15µs/call |
| 66 | } | ||||
| 67 | 2 | 1µs | return if $MAKERS{$target}{is_class}; # already exported into this package | ||
| 68 | 2 | 2µs | 2 | 4µs | my $stash = _getstash($target); # spent 4µs making 2 calls to Moo::_Utils::_getstash, avg 2µs/call |
| 69 | 2 | 25µs | my @not_methods = map { *$_{CODE}||() } grep !ref($_), values %$stash; | ||
| 70 | 2 | 31µs | @{$MAKERS{$target}{not_methods}={}}{@not_methods} = @not_methods; | ||
| 71 | 2 | 1µs | $MAKERS{$target}{is_class} = 1; | ||
| 72 | { | ||||
| 73 | 4 | 268µs | 2 | 25µs | # spent 18µs (11+7) within Moo::BEGIN@73 which was called:
# once (11µs+7µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 73 # spent 18µs making 1 call to Moo::BEGIN@73
# spent 7µs making 1 call to strict::unimport |
| 74 | @{"${target}::ISA"} = do { | ||||
| 75 | 4 | 2µs | require Moo::Object; ('Moo::Object'); | ||
| 76 | 2 | 18µs | } unless @{"${target}::ISA"}; | ||
| 77 | } | ||||
| 78 | 2 | 10µs | if ($INC{'Moo/HandleMoose.pm'}) { | ||
| 79 | Moo::HandleMoose::inject_fake_metaclass_for($target); | ||||
| 80 | } | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | sub unimport { | ||||
| 84 | my $target = caller; | ||||
| 85 | _unimport_coderefs($target, $MAKERS{$target}); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | sub _set_superclasses { | ||||
| 89 | my $class = shift; | ||||
| 90 | my $target = shift; | ||||
| 91 | foreach my $superclass (@_) { | ||||
| 92 | _load_module($superclass); | ||||
| 93 | if ($INC{'Role/Tiny.pm'} && Role::Tiny->is_role($superclass)) { | ||||
| 94 | require Carp; | ||||
| 95 | Carp::croak("Can't extend role '$superclass'"); | ||||
| 96 | } | ||||
| 97 | } | ||||
| 98 | # Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA | ||||
| 99 | @{*{_getglob("${target}::ISA")}{ARRAY}} = @_; | ||||
| 100 | if (my $old = delete $Moo::MAKERS{$target}{constructor}) { | ||||
| 101 | delete _getstash($target)->{new}; | ||||
| 102 | Moo->_constructor_maker_for($target) | ||||
| 103 | ->register_attribute_specs(%{$old->all_attribute_specs}); | ||||
| 104 | } | ||||
| 105 | elsif (!$target->isa('Moo::Object')) { | ||||
| 106 | Moo->_constructor_maker_for($target); | ||||
| 107 | } | ||||
| 108 | 2 | 698µs | 2 | 38µs | # spent 24µs (10+14) within Moo::BEGIN@108 which was called:
# once (10µs+14µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 108 # spent 24µs making 1 call to Moo::BEGIN@108
# spent 14µs making 1 call to warnings::unimport |
| 109 | $Moo::HandleMoose::MOUSE{$target} = [ | ||||
| 110 | grep defined, map Mouse::Util::find_meta($_), @_ | ||||
| 111 | ] if Mouse::Util->can('find_meta'); | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | # spent 12µs within Moo::_maybe_reset_handlemoose which was called 7 times, avg 2µs/call:
# 7 times (12µs+0s) by Moo::has at line 56, avg 2µs/call | ||||
| 115 | 7 | 3µs | my ($class, $target) = @_; | ||
| 116 | 7 | 14µs | if ($INC{"Moo/HandleMoose.pm"}) { | ||
| 117 | Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target); | ||||
| 118 | } | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | sub _accessor_maker_for { | ||||
| 122 | 9 | 3µs | my ($class, $target) = @_; | ||
| 123 | 9 | 3µs | return unless $MAKERS{$target}; | ||
| 124 | 9 | 19µs | $MAKERS{$target}{accessor} ||= do { | ||
| 125 | 2 | 800ns | my $maker_class = do { | ||
| 126 | 2 | 800ns | if (my $m = do { | ||
| 127 | 2 | 500ns | require Sub::Defer; | ||
| 128 | 2 | 12µs | 4 | 7µs | if (my $defer_target = # spent 4µs making 2 calls to Sub::Defer::defer_info, avg 2µs/call
# spent 3µs making 2 calls to UNIVERSAL::can, avg 1µs/call |
| 129 | (Sub::Defer::defer_info($target->can('new'))||[])->[0] | ||||
| 130 | ) { | ||||
| 131 | my ($pkg) = ($defer_target =~ /^(.*)::[^:]+$/); | ||||
| 132 | $MAKERS{$pkg} && $MAKERS{$pkg}{accessor}; | ||||
| 133 | } else { | ||||
| 134 | 2 | 300ns | undef; | ||
| 135 | } | ||||
| 136 | }) { | ||||
| 137 | ref($m); | ||||
| 138 | } else { | ||||
| 139 | 2 | 900ns | require Method::Generate::Accessor; | ||
| 140 | 2 | 700ns | 'Method::Generate::Accessor' | ||
| 141 | } | ||||
| 142 | }; | ||||
| 143 | 2 | 6µs | 2 | 32µs | $maker_class->new; # spent 32µs making 2 calls to Moo::Object::new, avg 16µs/call |
| 144 | } | ||||
| 145 | } | ||||
| 146 | |||||
| 147 | # spent 1.35ms (94µs+1.26) within Moo::_constructor_maker_for which was called 8 times, avg 169µs/call:
# 7 times (42µs+1.14ms) by Moo::has at line 52, avg 168µs/call
# once (53µs+120µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 208 of Method/Generate/Constructor.pm | ||||
| 148 | 8 | 3µs | my ($class, $target) = @_; | ||
| 149 | 8 | 3µs | return unless $MAKERS{$target}; | ||
| 150 | 8 | 21µs | $MAKERS{$target}{constructor} ||= do { | ||
| 151 | 2 | 1µs | require Method::Generate::Constructor; | ||
| 152 | 2 | 700ns | require Sub::Defer; | ||
| 153 | 2 | 300ns | my ($moo_constructor, $con); | ||
| 154 | |||||
| 155 | 2 | 22µs | 2 | 4µs | my $t_new = $target->can('new'); # spent 4µs making 2 calls to UNIVERSAL::can, avg 2µs/call |
| 156 | 2 | 1µs | if ($t_new) { | ||
| 157 | 2 | 13µs | 3 | 6µs | if ($t_new == Moo::Object->can('new')) { # spent 4µs making 1 call to Sub::Defer::defer_info
# spent 2µs making 2 calls to UNIVERSAL::can, avg 1µs/call |
| 158 | $moo_constructor = 1; | ||||
| 159 | } | ||||
| 160 | elsif (my $defer_target = (Sub::Defer::defer_info($t_new)||[])->[0]) { | ||||
| 161 | my ($pkg) = ($defer_target =~ /^(.*)::[^:]+$/); | ||||
| 162 | if ($MAKERS{$pkg}) { | ||||
| 163 | $moo_constructor = 1; | ||||
| 164 | $con = $MAKERS{$pkg}{constructor}; | ||||
| 165 | } | ||||
| 166 | } | ||||
| 167 | } | ||||
| 168 | else { | ||||
| 169 | $moo_constructor = 1; # no other constructor, make a Moo one | ||||
| 170 | } | ||||
| 171 | ($con ? ref($con) : 'Method::Generate::Constructor') | ||||
| 172 | ->new( | ||||
| 173 | package => $target, | ||||
| 174 | accessor_generator => $class->_accessor_maker_for($target), | ||||
| 175 | $moo_constructor ? ( | ||||
| 176 | $con ? (construction_string => $con->construction_string) : () | ||||
| 177 | ) : ( | ||||
| 178 | # spent 9µs (5+4) within Moo::__ANON__[/usr/share/perl5/Moo.pm:183] which was called:
# once (5µs+4µs) by Method::Generate::Constructor::_build_construction_string at line 68 of Method/Generate/Constructor.pm | ||||
| 179 | 1 | 11µs | 1 | 4µs | '$class->next::method(' # spent 4µs making 1 call to UNIVERSAL::can |
| 180 | .($target->can('FOREIGNBUILDARGS') ? | ||||
| 181 | '$class->FOREIGNBUILDARGS(@_)' : '@_') | ||||
| 182 | .')' | ||||
| 183 | }, | ||||
| 184 | ), | ||||
| 185 | subconstructor_handler => ( | ||||
| 186 | ' if ($Moo::MAKERS{$class}) {'."\n" | ||||
| 187 | .' if ($Moo::MAKERS{$class}{constructor}) {'."\n" | ||||
| 188 | .' return $class->'.$target.'::SUPER::new(@_);'."\n" | ||||
| 189 | .' }'."\n" | ||||
| 190 | .' '.$class.'->_constructor_maker_for($class);'."\n" | ||||
| 191 | .' return $class->new(@_)'.";\n" | ||||
| 192 | .' } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n" | ||||
| 193 | .' return $meta->new_object('."\n" | ||||
| 194 | .' $class->can("BUILDARGS") ? $class->BUILDARGS(@_)'."\n" | ||||
| 195 | .' : $class->Moo::Object::BUILDARGS(@_)'."\n" | ||||
| 196 | .' );'."\n" | ||||
| 197 | .' }'."\n" | ||||
| 198 | ), | ||||
| 199 | ) | ||||
| 200 | ->install_delayed | ||||
| 201 | 2 | 28µs | 8 | 1.20ms | ->register_attribute_specs(%{$con?$con->all_attribute_specs:{}}) # spent 1.05ms making 2 calls to Method::Generate::Constructor::new, avg 526µs/call
# spent 74µs making 2 calls to Method::Generate::Constructor::install_delayed, avg 37µs/call
# spent 68µs making 2 calls to Moo::_accessor_maker_for, avg 34µs/call
# spent 10µs making 2 calls to Method::Generate::Constructor::register_attribute_specs, avg 5µs/call |
| 202 | } | ||||
| 203 | } | ||||
| 204 | |||||
| 205 | sub _concrete_methods_of { | ||||
| 206 | my ($me, $role) = @_; | ||||
| 207 | my $makers = $MAKERS{$role}; | ||||
| 208 | # grab role symbol table | ||||
| 209 | my $stash = _getstash($role); | ||||
| 210 | # reverse so our keys become the values (captured coderefs) in case | ||||
| 211 | # they got copied or re-used since | ||||
| 212 | my $not_methods = { reverse %{$makers->{not_methods}||{}} }; | ||||
| 213 | +{ | ||||
| 214 | # grab all code entries that aren't in the not_methods list | ||||
| 215 | map { | ||||
| 216 | my $code = *{$stash->{$_}}{CODE}; | ||||
| 217 | ( ! $code or exists $not_methods->{$code} ) ? () : ($_ => $code) | ||||
| 218 | } grep !ref($stash->{$_}), keys %$stash | ||||
| 219 | }; | ||||
| 220 | } | ||||
| 221 | |||||
| 222 | 1 | 2µs | 1; | ||
| 223 | __END__ |