← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Moo.pm
StatementsExecuted 1249 statements in 3.88ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
49322.44ms3.95msMoo::::_accessor_maker_forMoo::_accessor_maker_for
34331.36ms11.6msMoo::::_constructor_maker_forMoo::_constructor_maker_for (recurses: max depth 1, inclusive time 3.79ms)
1212121.01ms16.6msMoo::::importMoo::import
111645µs934µsMoo::::BEGIN@4Moo::BEGIN@4
21215218µs13.0msMoo::::hasMoo::has
7241178µs770µsMoo::::_install_trackedMoo::_install_tracked
11193µs116µsMoo::::BEGIN@3Moo::BEGIN@3
312168µs95µsMoo::::_maybe_reset_handlemooseMoo::_maybe_reset_handlemoose
1010866µs68.7msMoo::::withMoo::with
1116µs13µsMoo::::BEGIN@112Moo::BEGIN@112
1115µs12µsMoo::::BEGIN@76Moo::BEGIN@76
0000s0sMoo::::__ANON__[:197]Moo::__ANON__[:197]
0000s0sMoo::::__ANON__[:205]Moo::__ANON__[:205]
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::::aroundMoo::around
0000s0sMoo::::beforeMoo::before
0000s0sMoo::::extendsMoo::extends
0000s0sMoo::::unimportMoo::unimport
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
3244µs2125µs
# spent 116µs (93+23) within Moo::BEGIN@3 which was called: # once (93µs+23µs) by CHI::Stats::BEGIN@6 at line 3
use Moo::_strictures;
# spent 116µs making 1 call to Moo::BEGIN@3 # spent 9µs making 1 call to Moo::_strictures::import
42331µs2967µs
# spent 934µs (645+289) within Moo::BEGIN@4 which was called: # once (645µs+289µs) by CHI::Stats::BEGIN@6 at line 4
use Moo::_Utils;
# spent 934µs making 1 call to Moo::BEGIN@4 # spent 34µs making 1 call to Exporter::import
5
61300nsour $VERSION = '2.000002';
719µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
8
9143µsrequire Moo::sification;
1011µs12.69msMoo::sification->import;
# spent 2.69ms making 1 call to Moo::sification::import
11
12our %MAKERS;
13
14
# spent 770µs (178+592) within Moo::_install_tracked which was called 72 times, avg 11µs/call: # 36 times (64µs+236µs) by Moo::import at line 68, avg 8µs/call # 12 times (61µs+181µs) by Moo::import at line 36, avg 20µs/call # 12 times (27µs+91µs) by Moo::import at line 41, avg 10µs/call # 12 times (26µs+84µs) by Moo::import at line 62, avg 9µs/call
sub _install_tracked {
157220µs my ($target, $name, $code) = @_;
167243µs $MAKERS{$target}{exports}{$name} = $code;
1772130µs72592µs _install_coderef "${target}::${name}" => "Moo::${name}" => $code;
# spent 592µs making 72 calls to Moo::_Utils::_install_coderef, avg 8µs/call
18}
19
20
# spent 16.6ms (1.01+15.6) within Moo::import which was called 12 times, avg 1.38ms/call: # once (54µs+5.22ms) by Search::Elasticsearch::CxnPool::Static::BEGIN@3 at line 3 of Search/Elasticsearch/CxnPool/Static.pm # once (46µs+4.69ms) by Method::Generate::Constructor::BEGIN@7 at line 7 of Method/Generate/Constructor.pm # once (409µs+772µs) by CHI::Stats::BEGIN@6 at line 6 of CHI/Stats.pm # once (79µs+717µs) by Search::Elasticsearch::Serializer::JSON::BEGIN@3 at line 3 of Search/Elasticsearch/Serializer/JSON.pm # once (67µs+638µs) by Search::Elasticsearch::Transport::BEGIN@3 at line 3 of Search/Elasticsearch/Transport.pm # once (69µs+620µs) by Search::Elasticsearch::Util::BEGIN@3 at line 3 of Search/Elasticsearch/Util.pm # once (52µs+590µs) by Search::Elasticsearch::Client::5_0::Direct::BEGIN@3 at line 3 of Search/Elasticsearch/Client/5_0/Direct.pm # once (52µs+541µs) by Search::Elasticsearch::Client::5_0::Direct::Indices::BEGIN@3 at line 3 of Search/Elasticsearch/Client/5_0/Direct/Indices.pm # once (49µs+488µs) by BenchmarkAnything::Storage::Search::Elasticsearch::Serializer::JSON::DontTouchMyUTF8::BEGIN@10 at line 10 of BenchmarkAnything/Storage/Search/Elasticsearch/Serializer/JSON/DontTouchMyUTF8.pm # once (45µs+478µs) by Search::Elasticsearch::Cxn::Factory::BEGIN@3 at line 3 of Search/Elasticsearch/Cxn/Factory.pm # once (50µs+423µs) by Search::Elasticsearch::Logger::LogAny::BEGIN@3 at line 3 of Search/Elasticsearch/Logger/LogAny.pm # once (39µs+420µs) by Search::Elasticsearch::Cxn::HTTPTiny::BEGIN@3 at line 3 of Search/Elasticsearch/Cxn/HTTPTiny.pm
sub import {
211211µs my $target = caller;
22124µs my $class = shift;
231227µs12225µs _set_loaded(caller);
# spent 225µs making 12 calls to Moo::_Utils::_set_loaded, avg 19µs/call
24
251217µs1220µs strict->import;
# spent 20µs making 12 calls to strict::import, avg 2µs/call
261216µs1253µs warnings->import;
# spent 53µs making 12 calls to warnings::import, avg 4µs/call
27
281225µs1016µs if ($INC{'Role/Tiny.pm'} and Role::Tiny->is_role($target)) {
# spent 16µs making 10 calls to Role::Tiny::is_role, avg 2µs/call
29 die "Cannot import Moo into a role";
30 }
311215µs $MAKERS{$target} ||= {};
32 _install_tracked $target => extends => sub {
33 $class->_set_superclasses($target, @_);
34 $class->_maybe_reset_handlemoose($target);
35 return;
361244µs12242µs };
# spent 242µs making 12 calls to Moo::_install_tracked, avg 20µs/call
37
# spent 68.7ms (66µs+68.6) within Moo::with which was called 10 times, avg 6.87ms/call: # once (8µs+32.4ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Cxn/HTTPTiny.pm # once (7µs+11.3ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+7.91ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/CxnPool/Static.pm # once (5µs+5.32ms) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Logger/LogAny.pm # once (9µs+3.99ms) by Module::Runtime::require_module at line 11 of Search/Elasticsearch/Transport.pm # once (4µs+3.66ms) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Client/5_0/Direct.pm # once (6µs+2.97ms) by Module::Runtime::require_module at line 15 of BenchmarkAnything/Storage/Search/Elasticsearch/Serializer/JSON/DontTouchMyUTF8.pm # once (6µs+447µs) by Module::Runtime::require_module at line 4 of Search/Elasticsearch/Client/5_0/Direct/Indices.pm # once (8µs+351µs) by Module::Runtime::require_module at line 8 of Search/Elasticsearch/Serializer/JSON.pm # once (4µs+259µs) by Module::Runtime::require_module at line 5 of Search/Elasticsearch/Client/5_0/Direct/Indices.pm
_install_tracked $target => with => sub {
38108µs require Moo::Role;
391024µs1068.6ms Moo::Role->apply_roles_to_package($target, @_);
# spent 68.6ms making 10 calls to Moo::Role::apply_roles_to_package, avg 6.86ms/call
401037µs1035µs $class->_maybe_reset_handlemoose($target);
# spent 35µs making 10 calls to Moo::_maybe_reset_handlemoose, avg 4µs/call
411226µs12118µs };
# spent 118µs making 12 calls to Moo::_install_tracked, avg 10µs/call
42
# spent 13.0ms (218µs+12.8) within Moo::has which was called 21 times, avg 619µs/call: # once (20µs+10.6ms) by CHI::BEGIN@5 at line 10 of CHI/Stats.pm # once (20µs+283µs) by Module::Runtime::require_module at line 6 of Search/Elasticsearch/Serializer/JSON.pm # once (17µs+249µs) by Module::Runtime::require_module at line 13 of BenchmarkAnything/Storage/Search/Elasticsearch/Serializer/JSON/DontTouchMyUTF8.pm # once (14µs+203µs) by Module::Runtime::require_module at line 7 of Search/Elasticsearch/Cxn/Factory.pm # once (14µs+140µs) by Module::Runtime::require_module at line 12 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+109µs) by CHI::BEGIN@5 at line 12 of CHI/Stats.pm # once (9µs+95µs) by Module::Runtime::require_module at line 13 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+92µs) by Module::Runtime::require_module at line 21 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+92µs) by Module::Runtime::require_module at line 17 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+90µs) by Module::Runtime::require_module at line 15 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+90µs) by Module::Runtime::require_module at line 14 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+91µs) by Module::Runtime::require_module at line 22 of Search/Elasticsearch/Client/5_0/Direct.pm # once (13µs+84µs) by CHI::BEGIN@5 at line 11 of CHI/Stats.pm # once (8µs+89µs) by Module::Runtime::require_module at line 16 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+88µs) by Module::Runtime::require_module at line 18 of Search/Elasticsearch/Client/5_0/Direct.pm # once (9µs+82µs) by Module::Runtime::require_module at line 8 of Search/Elasticsearch/Cxn/Factory.pm # once (8µs+77µs) by Module::Runtime::require_module at line 19 of Search/Elasticsearch/Client/5_0/Direct.pm # once (8µs+74µs) by Module::Runtime::require_module at line 10 of Search/Elasticsearch/Cxn/Factory.pm # once (8µs+69µs) by Module::Runtime::require_module at line 9 of Search/Elasticsearch/Cxn/Factory.pm # once (8µs+67µs) by CHI::BEGIN@5 at line 13 of CHI/Stats.pm # once (7µs+58µs) by Module::Runtime::require_module at line 20 of Search/Elasticsearch/Client/5_0/Direct.pm
_install_tracked $target => has => sub {
43215µs my $name_proto = shift;
442114µs my @name_proto = ref $name_proto eq 'ARRAY' ? @$name_proto : $name_proto;
45219µ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 }
502117µs my %spec = @_;
51218µs foreach my $name (@name_proto) {
52 # Note that when multiple attributes specified, each attribute
53 # needs a separate \%specs hashref
542110µs my $spec_ref = @name_proto > 1 ? +{%spec} : \%spec;
552130µs4211.1ms $class->_constructor_maker_for($target)
# spent 10.8ms making 21 calls to Moo::_constructor_maker_for, avg 515µs/call # spent 234µs making 21 calls to Method::Generate::Constructor::register_attribute_specs, avg 11µs/call
56 ->register_attribute_specs($name, $spec_ref);
572131µs421.67ms $class->_accessor_maker_for($target)
# spent 1.65ms making 21 calls to Method::Generate::Accessor::generate_method, avg 79µs/call # spent 17µs making 21 calls to Moo::_accessor_maker_for, avg 829ns/call
58 ->generate_method($target, $name, $spec_ref);
592126µs2160µs $class->_maybe_reset_handlemoose($target);
# spent 60µs making 21 calls to Moo::_maybe_reset_handlemoose, avg 3µs/call
60 }
612145µs return;
621237µs12110µs };
# spent 110µs making 12 calls to Moo::_install_tracked, avg 9µs/call
631211µs foreach my $type (qw(before after around)) {
64 _install_tracked $target => $type => sub {
65 require Class::Method::Modifiers;
66 _install_modifier($target, $type, @_);
67 return;
683649µs36299µs };
# spent 299µs making 36 calls to Moo::_install_tracked, avg 8µs/call
69 }
70126µs return if $MAKERS{$target}{is_class}; # already exported into this package
711216µs1218µs my $stash = _getstash($target);
# spent 18µs making 12 calls to Moo::_Utils::_getstash, avg 2µs/call
721254µs my @not_methods = map { *$_{CODE}||() } grep !ref($_), values %$stash;
731250µs @{$MAKERS{$target}{not_methods}={}}{@not_methods} = @not_methods;
74127µs $MAKERS{$target}{is_class} = 1;
75 {
7614158µs219µs
# spent 12µs (5+7) within Moo::BEGIN@76 which was called: # once (5µs+7µs) by CHI::Stats::BEGIN@6 at line 76
no strict 'refs';
# spent 12µs making 1 call to Moo::BEGIN@76 # spent 7µs making 1 call to strict::unimport
77 @{"${target}::ISA"} = do {
782452µs require Moo::Object; ('Moo::Object');
7912100µs } unless @{"${target}::ISA"};
80 }
811265µs1214.5ms if ($INC{'Moo/HandleMoose.pm'}) {
# spent 14.5ms making 12 calls to Moo::HandleMoose::inject_fake_metaclass_for, avg 1.21ms/call
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 }
11221.47ms220µs
# spent 13µs (6+7) within Moo::BEGIN@112 which was called: # once (6µs+7µs) by CHI::Stats::BEGIN@6 at line 112
no warnings 'once'; # piss off. -- mst
# spent 13µs making 1 call to Moo::BEGIN@112 # spent 7µ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 95µs (68+27) within Moo::_maybe_reset_handlemoose which was called 31 times, avg 3µs/call: # 21 times (42µs+18µs) by Moo::has at line 59, avg 3µs/call # 10 times (26µs+9µs) by Moo::with at line 40, avg 4µs/call
sub _maybe_reset_handlemoose {
119317µs my ($class, $target) = @_;
1203162µs3127µs if ($INC{"Moo/HandleMoose.pm"}) {
# spent 27µs making 31 calls to Moo::HandleMoose::maybe_reinject_fake_metaclass_for, avg 858ns/call
121 Moo::HandleMoose::maybe_reinject_fake_metaclass_for($target);
122 }
123}
124
125
# spent 3.95ms (2.44+1.52) within Moo::_accessor_maker_for which was called 49 times, avg 81µs/call: # 21 times (17µs+0s) by Moo::has at line 57, avg 829ns/call # 17 times (17µs+0s) by Moo::Role::_maybe_make_accessors at line 219 of Moo/Role.pm, avg 982ns/call # 11 times (2.40ms+1.52ms) by Moo::_constructor_maker_for at line 158, avg 356µs/call
sub _accessor_maker_for {
126498µs my ($class, $target) = @_;
1274915µs return unless $MAKERS{$target};
1284564µs $MAKERS{$target}{accessor} ||= do {
129117µs my $maker_class = do {
130116µs if (my $m = do {
131112µs require Sub::Defer;
1321195µs2256µs if (my $defer_target =
# spent 35µs making 11 calls to Sub::Defer::defer_info, avg 3µs/call # spent 21µs making 11 calls to UNIVERSAL::can, avg 2µ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 {
138112µs undef;
139 }
140 }) {
141 ref($m);
142 } else {
1431161µs require Method::Generate::Accessor;
1441113µs 'Method::Generate::Accessor'
145 }
146 };
1471120µs1190µs $maker_class->new;
# spent 90µs making 11 calls to Moo::Object::new, avg 8µs/call
148 }
149}
150
151
# spent 11.6ms (1.36+10.2) within Moo::_constructor_maker_for which was called 34 times, avg 341µs/call: # 21 times (1.15ms+9.68ms) by Moo::has at line 55, avg 515µs/call # 12 times (171µs+588µs) by Moo::Role::_handle_constructor at line 395 of Moo/Role.pm, avg 63µs/call # once (42µs+-42µs) by Moo::_constructor_maker_for at line 245 of Method/Generate/Constructor.pm
sub _constructor_maker_for {
1523410µs my ($class, $target) = @_;
1533414µs return unless $MAKERS{$target};
1543248µs $MAKERS{$target}{constructor} ||= do {
1551154µs require Method::Generate::Constructor;
156116µs require Sub::Defer;
157
1581168µs113.92ms my %construct_opts = (
# spent 3.92ms making 11 calls to Moo::_accessor_maker_for, avg 356µs/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 .' return $class->'.$target.'::SUPER::new(@_);'."\n"
165 .' }'."\n"
166 .' '.$class.'->_constructor_maker_for($class);'."\n"
167 .' return $class->new(@_)'.";\n"
168 .' } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {'."\n"
169 .' return $meta->new_object('."\n"
170 .' $class->can("BUILDARGS") ? $class->BUILDARGS(@_)'."\n"
171 .' : $class->Moo::Object::BUILDARGS(@_)'."\n"
172 .' );'."\n"
173 .' }'."\n"
174 ),
175 );
176
177112µs my $con;
1781144µs1113µs my @isa = @{mro::get_linear_isa($target)};
# spent 13µs making 11 calls to mro::get_linear_isa, avg 1µs/call
179114µs shift @isa;
1801135µs1118µs if (my ($parent_new) = grep { *{_getglob($_.'::new')}{CODE} } @isa) {
# spent 18µs making 11 calls to Moo::_Utils::_getglob, avg 2µs/call
181115µs if ($parent_new eq 'Moo::Object') {
182 # no special constructor needed
183 }
184 elsif (my $makers = $MAKERS{$parent_new}) {
185 $con = $makers->{constructor};
186 $construct_opts{construction_string} = $con->construction_string
187 if $con;
188 }
189 elsif ($parent_new->can('BUILDALL')) {
190 $construct_opts{construction_builder} = sub {
191 my $inv = $target->can('BUILDARGS') ? '' : 'Moo::Object::';
192 'do {'
193 .' my $args = $class->'.$inv.'BUILDARGS(@_);'
194 .' $args->{__no_BUILD__} = 1;'
195 .' $class->'.$target.'::SUPER::new($args);'
196 .'}'
197 };
198 }
199 else {
200 $construct_opts{construction_builder} = sub {
201 '$class->'.$target.'::SUPER::new('
202 .($target->can('FOREIGNBUILDARGS') ?
203 '$class->FOREIGNBUILDARGS(@_)' : '@_')
204 .')'
205 };
206 }
207 }
208 ($con ? ref($con) : 'Method::Generate::Constructor')
209 ->new(%construct_opts)
210 ->install_delayed
2111179µs331.43ms ->register_attribute_specs(%{$con?$con->all_attribute_specs:{}})
# spent 862µs making 11 calls to Method::Generate::Constructor::new, avg 78µs/call # spent 448µs making 11 calls to Method::Generate::Constructor::install_delayed, avg 41µs/call # spent 118µs making 11 calls to Method::Generate::Constructor::register_attribute_specs, avg 11µs/call
212 }
213}
214
215sub _concrete_methods_of {
216 my ($me, $role) = @_;
217 my $makers = $MAKERS{$role};
218 # grab role symbol table
219 my $stash = _getstash($role);
220 # reverse so our keys become the values (captured coderefs) in case
221 # they got copied or re-used since
222 my $not_methods = { reverse %{$makers->{not_methods}||{}} };
223 +{
224 # grab all code entries that aren't in the not_methods list
225 map {
226 my $code = *{$stash->{$_}}{CODE};
227 ( ! $code or exists $not_methods->{$code} ) ? () : ($_ => $code)
228 } grep !ref($stash->{$_}), keys %$stash
229 };
230}
231
23213µs1;
233__END__