← Index
NYTProf Performance Profile   « line view »
For index.cgi
  Run on Sat May 9 17:18:47 2020
Reported on Sat May 9 17:19:07 2020

Filename/usr/local/share/perl/5.18.2/Moo.pm
StatementsExecuted 294 statements in 3.30ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11215.37ms10.2msMoo::::_accessor_maker_forMoo::_accessor_maker_for
10222.45ms22.2msMoo::::_constructor_maker_forMoo::_constructor_maker_for (recurses: max depth 1, inclusive time 10.5ms)
1112.27ms16.2msMoo::::BEGIN@4Moo::BEGIN@4
1111.60ms2.17msMoo::::aroundMoo::around
222864µs1.39msMoo::::importMoo::import
111215µs294µsMoo::::BEGIN@3Moo::BEGIN@3
771211µs24.2msMoo::::hasMoo::has
124167µs305µsMoo::::_install_trackedMoo::_install_tracked
91121µs21µsMoo::::_maybe_reset_handlemooseMoo::_maybe_reset_handlemoose
11112µs25µsMoo::::BEGIN@112Moo::BEGIN@112
1119µs25µsMoo::::BEGIN@76Moo::BEGIN@76
0000s0sMoo::::__ANON__[:198]Moo::__ANON__[:198]
0000s0sMoo::::__ANON__[:206]Moo::__ANON__[:206]
0000s0sMoo::::__ANON__[:36]Moo::__ANON__[:36]
0000s0sMoo::::__ANON__[:41]Moo::__ANON__[:41]
0000s0sMoo::::__ANON__[:62]Moo::__ANON__[:62]
0000s0sMoo::::__ANON__[:68]Moo::__ANON__[:68]
0000s0sMoo::::_concrete_methods_ofMoo::_concrete_methods_of
0000s0sMoo::::_set_superclassesMoo::_set_superclasses
0000s0sMoo::::afterMoo::after
0000s0sMoo::::beforeMoo::before
0000s0sMoo::::extendsMoo::extends
0000s0sMoo::::unimportMoo::unimport
0000s0sMoo::::withMoo::with
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moo;
2
32101µs2324µs
# spent 294µs (215+78) within Moo::BEGIN@3 which was called: # once (215µs+78µs) by String::Markov::BEGIN@8 at line 3
use Moo::_strictures;
# spent 294µs making 1 call to Moo::BEGIN@3 # spent 31µs making 1 call to Moo::_strictures::import
42710µs216.3ms
# spent 16.2ms (2.27+14.0) within Moo::BEGIN@4 which was called: # once (2.27ms+14.0ms) by String::Markov::BEGIN@8 at line 4
use Moo::_Utils;
# spent 16.2ms making 1 call to Moo::BEGIN@4 # spent 80µs making 1 call to Exporter::import
5
61800nsour $VERSION = '2.001000';
7163µs$VERSION = eval $VERSION;
# spent 3µs executing statements in string eval
8
9182µsrequire Moo::sification;
1017µs15µsMoo::sification->import;
# spent 5µs making 1 call to Moo::sification::import
11
121400nsour %MAKERS;
13
14
# spent 305µs (67+239) within Moo::_install_tracked which was called 12 times, avg 25µs/call: # 6 times (28µs+99µs) by Moo::import at line 68, avg 21µs/call # 2 times (17µs+74µs) by Moo::import at line 36, avg 46µs/call # 2 times (11µs+34µs) by Moo::import at line 41, avg 23µs/call # 2 times (10µs+32µs) by Moo::import at line 62, avg 21µs/call
sub _install_tracked {
15128µs my ($target, $name, $code) = @_;
161216µs $MAKERS{$target}{exports}{$name} = $code;
171242µs12239µs _install_coderef "${target}::${name}" => "Moo::${name}" => $code;
# spent 239µs making 12 calls to Moo::_Utils::_install_coderef, avg 20µs/call
18}
19
20
# spent 1.39ms (864µs+528µs) within Moo::import which was called 2 times, avg 696µs/call: # once (770µs+311µs) by String::Markov::BEGIN@8 at line 8 of String/Markov.pm # once (94µs+216µs) by Method::Generate::Constructor::BEGIN@8 at line 8 of Method/Generate/Constructor.pm
sub import {
2122µs my $target = caller;
2221µs my $class = shift;
2325µs2108µs _set_loaded(caller);
# spent 108µs making 2 calls to Moo::_Utils::_set_loaded, avg 54µs/call
24
2524µs229µs strict->import;
# spent 29µs making 2 calls to strict::import, avg 14µs/call
2624µs212µs warnings->import;
# spent 12µs making 2 calls to warnings::import, avg 6µs/call
27
2821µs if ($INC{'Role/Tiny.pm'} and Role::Tiny->is_role($target)) {
29 die "Cannot import Moo into a role";
30 }
3123µs $MAKERS{$target} ||= {};
32 _install_tracked $target => extends => sub {
33 $class->_set_superclasses($target, @_);
34 $class->_maybe_reset_handlemoose($target);
35 return;
36211µs291µs };
# spent 91µs making 2 calls to Moo::_install_tracked, avg 46µs/call
37 _install_tracked $target => with => sub {
38 require Moo::Role;
39 Moo::Role->apply_roles_to_package($target, @_);
40 $class->_maybe_reset_handlemoose($target);
4129µs245µs };
# spent 45µs making 2 calls to Moo::_install_tracked, avg 23µs/call
42
# spent 24.2ms (211µs+24.0) within Moo::has which was called 7 times, avg 3.45ms/call: # once (36µs+22.5ms) by main::BEGIN@7 at line 14 of String/Markov.pm # once (46µs+380µs) by main::BEGIN@7 at line 31 of String/Markov.pm # once (40µs+344µs) by main::BEGIN@7 at line 25 of String/Markov.pm # once (25µs+205µs) by main::BEGIN@7 at line 16 of String/Markov.pm # once (21µs+189µs) by main::BEGIN@7 at line 20 of String/Markov.pm # once (22µs+186µs) by main::BEGIN@7 at line 17 of String/Markov.pm # once (24µs+184µs) by main::BEGIN@7 at line 15 of String/Markov.pm
_install_tracked $target => has => sub {
4375µs my $name_proto = shift;
4479µs my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto;
4576µs if (@_ % 2 != 0) {
46 require Carp;
47 Carp::croak("Invalid options for " . join(', ', map "'$_'", @name_proto)
48 . " attribute(s): even number of arguments expected, got " . scalar @_)
49 }
50712µs my %spec = @_;
5176µs foreach my $name (@name_proto) {
52 # Note that when multiple attributes specified, each attribute
53 # needs a separate \%specs hashref
54916µs my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec;
55934µs1822.5ms $class->_constructor_maker_for($target)
# spent 22.2ms making 9 calls to Moo::_constructor_maker_for, avg 2.47ms/call # spent 246µs making 9 calls to Method::Generate::Constructor::register_attribute_specs, avg 27µs/call
56 ->register_attribute_specs($name, $spec_ref);
57935µs181.46ms $class->_accessor_maker_for($target)
# spent 1.43ms making 9 calls to Method::Generate::Accessor::generate_method, avg 159µs/call # spent 26µs making 9 calls to Moo::_accessor_maker_for, avg 3µs/call
58 ->generate_method($target, $name, $spec_ref);
59927µs921µs $class->_maybe_reset_handlemoose($target);
# spent 21µs making 9 calls to Moo::_maybe_reset_handlemoose, avg 2µs/call
60 }
61727µs return;
62210µs242µs };
# spent 42µs making 2 calls to Moo::_install_tracked, avg 21µs/call
6322µs foreach my $type (qw(before after around)) {
64
# spent 2.17ms (1.60+569µs) within Moo::around which was called: # once (1.60ms+569µs) by main::BEGIN@7 at line 45 of String/Markov.pm
_install_tracked $target => $type => sub {
65196µs require Class::Method::Modifiers;
6615µs1265µs _install_modifier($target, $type, @_);
# spent 265µs making 1 call to Moo::_Utils::_install_modifier
6713µs return;
68624µs6128µs };
# spent 128µs making 6 calls to Moo::_install_tracked, avg 21µs/call
69 }
7022µs return if $MAKERS{$target}{is_class}; # already exported into this package
7124µs26µs my $stash = _getstash($target);
# spent 6µs making 2 calls to Moo::_Utils::_getstash, avg 3µs/call
72218µs my @not_methods = map { *$_{CODE}||() } grep !ref($_), values %$stash;
73215µs @{$MAKERS{$target}{not_methods}={}}{@not_methods} = @not_methods;
7422µs $MAKERS{$target}{is_class} = 1;
75 {
764355µs240µs
# spent 25µs (9+15) within Moo::BEGIN@76 which was called: # once (9µs+15µs) by String::Markov::BEGIN@8 at line 76
no strict 'refs';
# spent 25µs making 1 call to Moo::BEGIN@76 # spent 16µs making 1 call to strict::unimport
77 @{"${target}::ISA"} = do {
78490µs require Moo::Object; ('Moo::Object');
79225µs } unless @{"${target}::ISA"};
80 }
81214µs if ($INC{'Moo/HandleMoose.pm'}) {
82 Moo::HandleMoose::inject_fake_metaclass_for($target);
83 }
84}
85
86sub unimport {
87 my $target = caller;
88 _unimport_coderefs($target, $MAKERS{$target});
89}
90
91sub _set_superclasses {
92 my $class = shift;
93 my $target = shift;
94 foreach my $superclass (@_) {
95 _load_module($superclass);
96 if ($INC{'Role/Tiny.pm'} && Role::Tiny->is_role($superclass)) {
97 require Carp;
98 Carp::croak("Can't extend role '$superclass'");
99 }
100 }
101 # Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA
102 @{*{_getglob("${target}::ISA")}{ARRAY}} = @_;
103 if (my $old = delete $Moo::MAKERS{$target}{constructor}) {
104 $old->assert_constructor;
105 delete _getstash($target)->{new};
106 Moo->_constructor_maker_for($target)
107 ->register_attribute_specs(%{$old->all_attribute_specs});
108 }
109 elsif (!$target->isa('Moo::Object')) {
110 Moo->_constructor_maker_for($target);
111 }
1122895µs239µs
# spent 25µs (12+13) within Moo::BEGIN@112 which was called: # once (12µs+13µs) by String::Markov::BEGIN@8 at line 112
no warnings 'once'; # piss off. -- mst
# spent 25µs making 1 call to Moo::BEGIN@112 # spent 13µs making 1 call to warnings::unimport
113 $Moo::HandleMoose::MOUSE{$target} = [
114 grep defined, map Mouse::Util::find_meta($_), @_
115 ] if Mouse::Util->can('find_meta');
116}
117
118
# spent 21µs within Moo::_maybe_reset_handlemoose which was called 9 times, avg 2µs/call: # 9 times (21µs+0s) by Moo::has at line 59, avg 2µs/call
sub _maybe_reset_handlemoose {
11996µs my ($class, $target) = @_;
120923µs if ($INC{"Moo/HandleMoose.pm"}) {
121 Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target);
122 }
123}
124
125
# spent 10.2ms (5.37+4.87) within Moo::_accessor_maker_for which was called 11 times, avg 930µs/call: # 9 times (26µs+0s) by Moo::has at line 57, avg 3µs/call # 2 times (5.34ms+4.87ms) by Moo::_constructor_maker_for at line 158, avg 5.10ms/call
sub _accessor_maker_for {
126116µs my ($class, $target) = @_;
127116µs return unless $MAKERS{$target};
1281146µs $MAKERS{$target}{accessor} ||= do {
12923µs my $maker_class = do {
13022µs if (my $m = do {
1312800ns require Sub::Defer;
132235µs419µs if (my $defer_target =
# spent 11µs making 2 calls to Sub::Defer::defer_info, avg 5µs/call # spent 8µs making 2 calls to UNIVERSAL::can, avg 4µs/call
133 (Sub::Defer::defer_info($target->can('new'))||[])->[0]
134 ) {
135 my ($pkg) = ($defer_target =~ /^(.*)::[^:]+$/);
136 $MAKERS{$pkg} && $MAKERS{$pkg}{accessor};
137 } else {
1382900ns undef;
139 }
140 }) {
141 ref($m);
142 } else {
143286µs require Method::Generate::Accessor;
14421µs 'Method::Generate::Accessor'
145 }
146 };
147212µs263µs $maker_class->new;
# spent 63µs making 2 calls to Moo::Object::new, avg 32µs/call
148 }
149}
150
151
# spent 22.2ms (2.45+19.8) within Moo::_constructor_maker_for which was called 10 times, avg 2.22ms/call: # 9 times (2.34ms+19.9ms) by Moo::has at line 55, avg 2.47ms/call # once (118µs+-118µs) by Moo::_constructor_maker_for at line 244 of Method/Generate/Constructor.pm
sub _constructor_maker_for {
152105µs my ($class, $target) = @_;
153107µs return unless $MAKERS{$target};
1541044µs $MAKERS{$target}{constructor} ||= do {
155283µs require Method::Generate::Constructor;
15622µs require Sub::Defer;
157
158229µs210.2ms my %construct_opts = (
# spent 10.2ms making 2 calls to Moo::_accessor_maker_for, avg 5.10ms/call
159 package => $target,
160 accessor_generator => $class->_accessor_maker_for($target),
161 subconstructor_handler => (
162 ' if ($Moo::MAKERS{$class}) {'."\n"
163 .' if ($Moo::MAKERS{$class}{constructor}) {'."\n"
164 .' package '.$target.';'."\n"
165 .' return $class->SUPER::new(@_);'."\n"
166 .' }'."\n"
167 .' '.$class.'->_constructor_maker_for($class);'."\n"
168 .' return $class->new(@_)'.";\n"
169 .' } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n"
170 .' return $meta->new_object('."\n"
171 .' $class->can("BUILDARGS") ? $class->BUILDARGS(@_)'."\n"
172 .' : $class->Moo::Object::BUILDARGS(@_)'."\n"
173 .' );'."\n"
174 .' }'."\n"
175 ),
176 );
177
1782900ns my $con;
179241µs214µs my @isa = @{mro::get_linear_isa($target)};
# spent 14µs making 2 calls to mro::get_linear_isa, avg 7µs/call
18022µs shift @isa;
181216µs28µs if (my ($parent_new) = grep { *{_getglob($_.'::new')}{CODE} } @isa) {
# spent 8µs making 2 calls to Moo::_Utils::_getglob, avg 4µs/call
18222µs if ($parent_new eq 'Moo::Object') {
183 # no special constructor needed
184 }
185 elsif (my $makers = $MAKERS{$parent_new}) {
186 $con = $makers->{constructor};
187 $construct_opts{construction_string} = $con->construction_string
188 if $con;
189 }
190 elsif ($parent_new->can('BUILDALL')) {
191 $construct_opts{construction_builder} = sub {
192 my $inv = $target->can('BUILDARGS') ? '' : 'Moo::Object::';
193 'do {'
194 .' my $args = $class->'.$inv.'BUILDARGS(@_);'
195 .' $args->{__no_BUILD__} = 1;'
196 .' $class->'.$target.'::SUPER::new($args);'
197 .'}'
198 };
199 }
200 else {
201 $construct_opts{construction_builder} = sub {
202 '$class->'.$target.'::SUPER::new('
203 .($target->can('FOREIGNBUILDARGS') ?
204 '$class->FOREIGNBUILDARGS(@_)' : '@_')
205 .')'
206 };
207 }
208 }
209 ($con ? ref($con) : 'Method::Generate::Constructor')
210 ->new(%construct_opts)
211 ->install_delayed
212226µs62.01ms ->register_attribute_specs(%{$con?$con->all_attribute_specs:{}})
# spent 1.70ms making 2 calls to Method::Generate::Constructor::new, avg 850µs/call # spent 251µs making 2 calls to Method::Generate::Constructor::install_delayed, avg 125µs/call # spent 55µs making 2 calls to Method::Generate::Constructor::register_attribute_specs, avg 27µs/call
213 }
214}
215
216sub _concrete_methods_of {
217 my ($me, $role) = @_;
218 my $makers = $MAKERS{$role};
219 # grab role symbol table
220 my $stash = _getstash($role);
221 # reverse so our keys become the values (captured coderefs) in case
222 # they got copied or re-used since
223 my $not_methods = { reverse %{$makers->{not_methods}||{}} };
224 +{
225 # grab all code entries that aren't in the not_methods list
226 map {
227 my $code = *{$stash->{$_}}{CODE};
228 ( ! $code or exists $not_methods->{$code} ) ? () : ($_ => $code)
229 } grep !ref($stash->{$_}), keys %$stash
230 };
231}
232
23314µs1;
234__END__