← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:31:38 2016

Filename/usr/share/perl5/Method/Generate/Constructor.pm
StatementsExecuted 349 statements in 2.08ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
211204µs969µsMethod::Generate::Constructor::::_assign_newMethod::Generate::Constructor::_assign_new
211130µs1.41msMethod::Generate::Constructor::::generate_methodMethod::Generate::Constructor::generate_method
1032103µs112µsMethod::Generate::Constructor::::register_attribute_specsMethod::Generate::Constructor::register_attribute_specs
21165µs71µsMethod::Generate::Constructor::::_check_requiredMethod::Generate::Constructor::_check_required
11123µs83µsMethod::Generate::Constructor::::BEGIN@3Method::Generate::Constructor::BEGIN@3
111123µs23µsMethod::Generate::Constructor::::_cap_callMethod::Generate::Constructor::_cap_call
11121µs428µsMethod::Generate::Constructor::::BEGIN@202Method::Generate::Constructor::BEGIN@202
21119µs2.76msMethod::Generate::Constructor::::__ANON__[:81]Method::Generate::Constructor::__ANON__[:81]
21117µs81µsMethod::Generate::Constructor::::install_delayedMethod::Generate::Constructor::install_delayed
21116µs28µsMethod::Generate::Constructor::::_build_construction_stringMethod::Generate::Constructor::_build_construction_string
21115µs43µsMethod::Generate::Constructor::::construction_stringMethod::Generate::Constructor::construction_string
21115µs35µsMethod::Generate::Constructor::::_handle_subconstructorMethod::Generate::Constructor::_handle_subconstructor
63112µs12µsMethod::Generate::Constructor::::CORE:sortMethod::Generate::Constructor::CORE:sort (opcode)
11110µs43µsMethod::Generate::Constructor::::BEGIN@4Method::Generate::Constructor::BEGIN@4
11110µs32µsMethod::Generate::Constructor::::BEGIN@5Method::Generate::Constructor::BEGIN@5
1119µs51µsMethod::Generate::Constructor::::__ANON__[:202]Method::Generate::Constructor::__ANON__[:202]
13119µs9µsMethod::Generate::Constructor::::CORE:substMethod::Generate::Constructor::CORE:subst (opcode)
1118µs34µsMethod::Generate::Constructor::::BEGIN@6Method::Generate::Constructor::BEGIN@6
3214µs4µsMethod::Generate::Constructor::::accessor_generatorMethod::Generate::Constructor::accessor_generator
2114µs4µsMethod::Generate::Constructor::::_generate_argsMethod::Generate::Constructor::_generate_args
0000s0sMethod::Generate::Constructor::::_generate_args_via_buildargsMethod::Generate::Constructor::_generate_args_via_buildargs
0000s0sMethod::Generate::Constructor::::all_attribute_specsMethod::Generate::Constructor::all_attribute_specs
0000s0sMethod::Generate::Constructor::::buildall_generatorMethod::Generate::Constructor::buildall_generator
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Method::Generate::Constructor;
2
3338µs3143µs
# spent 83µs (23+60) within Method::Generate::Constructor::BEGIN@3 which was called: # once (23µs+60µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 3
use strictures 1;
# spent 83µs making 1 call to Method::Generate::Constructor::BEGIN@3 # spent 37µs making 1 call to strictures::import # spent 23µs making 1 call to strictures::VERSION
4263µs276µs
# spent 43µs (10+33) within Method::Generate::Constructor::BEGIN@4 which was called: # once (10µs+33µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 4
use Sub::Quote qw(quote_sub unquote_sub quotify);
# spent 43µs making 1 call to Method::Generate::Constructor::BEGIN@4 # spent 33µs making 1 call to Exporter::import
5253µs253µs
# spent 32µs (10+22) within Method::Generate::Constructor::BEGIN@5 which was called: # once (10µs+22µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 5
use Sub::Defer;
# spent 32µs making 1 call to Method::Generate::Constructor::BEGIN@5 # spent 22µs making 1 call to Exporter::import
621.14ms260µs
# spent 34µs (8+26) within Method::Generate::Constructor::BEGIN@6 which was called: # once (8µs+26µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 6
use Moo::_Utils qw(_getstash);
# spent 34µs making 1 call to Method::Generate::Constructor::BEGIN@6 # spent 26µs making 1 call to Exporter::import
7
8
# spent 112µs (103+9) within Method::Generate::Constructor::register_attribute_specs which was called 10 times, avg 11µs/call: # 7 times (66µs+7µs) by Moo::has at line 52 of Moo.pm, avg 10µs/call # 2 times (12µs+0s) by Moo::_constructor_maker_for at line 201 of Moo.pm, avg 6µs/call # once (25µs+2µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 208
sub register_attribute_specs {
9109µs my ($self, @new_specs) = @_;
10109µs my $specs = $self->{attribute_specs}||={};
111021µs while (my ($name, $new_spec) = splice @new_specs, 0, 2) {
121335µs139µs if ($name =~ s/^\+//) {
# spent 9µs making 13 calls to Method::Generate::Constructor::CORE:subst, avg 692ns/call
13 die "has '+${name}' given but no ${name} attribute already exists"
14 unless my $old_spec = $specs->{$name};
15 foreach my $key (keys %$old_spec) {
16 if (!exists $new_spec->{$key}) {
17 $new_spec->{$key} = $old_spec->{$key}
18 unless $key eq 'handles';
19 }
20 elsif ($key eq 'moosify') {
21 $new_spec->{$key} = [
22 map { ref $_ eq 'ARRAY' ? @$_ : $_ }
23 ($old_spec->{$key}, $new_spec->{$key})
24 ];
25 }
26 }
27 }
28137µs if ($new_spec->{required}
29 && !(
30 exists $new_spec->{default}
31 || $new_spec->{builder}
32 || !exists $new_spec->{init_arg}
33 || defined $new_spec->{init_arg}
34 )
35 ) {
36 die "You cannot have a required attribute (${name})"
37 . " without a default, builder, or an init_arg";
38 }
391310µs $new_spec->{index} = scalar keys %$specs
40 unless defined $new_spec->{index};
41138µs $specs->{$name} = $new_spec;
42 }
431025µs $self;
44}
45
46sub all_attribute_specs {
47 $_[0]->{attribute_specs}
48}
49
50
# spent 4µs within Method::Generate::Constructor::accessor_generator which was called 3 times, avg 1µs/call: # 2 times (2µs+0s) by Method::Generate::Constructor::_assign_new at line 168, avg 1µs/call # once (2µs+0s) by Method::Generate::Constructor::_build_construction_string at line 68
sub accessor_generator {
51310µs $_[0]->{accessor_generator}
52}
53
54
# spent 43µs (15+28) within Method::Generate::Constructor::construction_string which was called 2 times, avg 22µs/call: # 2 times (15µs+28µs) by Method::Generate::Constructor::generate_method at line 101, avg 22µs/call
sub construction_string {
552600ns my ($self) = @_;
5629µs228µs $self->{construction_string}
# spent 28µs making 2 calls to Method::Generate::Constructor::_build_construction_string, avg 14µs/call
57 ||= $self->_build_construction_string;
58}
59
60sub buildall_generator {
61 require Method::Generate::BuildAll;
62 Method::Generate::BuildAll->new;
63}
64
65
# spent 28µs (16+12) within Method::Generate::Constructor::_build_construction_string which was called 2 times, avg 14µs/call: # 2 times (16µs+12µs) by Method::Generate::Constructor::construction_string at line 56, avg 14µs/call
sub _build_construction_string {
662600ns my ($self) = @_;
6721µs my $builder = $self->{construction_builder};
68215µs312µs $builder ? $self->$builder
# spent 9µs making 1 call to Moo::__ANON__[Moo.pm:183] # spent 2µs making 1 call to Method::Generate::Constructor::accessor_generator # spent 2µs making 1 call to Method::Generate::Accessor::default_construction_string
69 : 'bless('
70 .$self->accessor_generator->default_construction_string
71 .', $class);'
72}
73
74
# spent 81µs (17+64) within Method::Generate::Constructor::install_delayed which was called 2 times, avg 40µs/call: # 2 times (17µs+64µs) by Moo::_constructor_maker_for at line 201 of Moo.pm, avg 40µs/call
sub install_delayed {
752700ns my ($self) = @_;
7625µs my $package = $self->{package};
77
# spent 2.76ms (19µs+2.74) within Method::Generate::Constructor::__ANON__[/usr/share/perl5/Method/Generate/Constructor.pm:81] which was called 2 times, avg 1.38ms/call: # 2 times (19µs+2.74ms) by Sub::Defer::undefer_sub at line 22 of Sub/Defer.pm, avg 1.38ms/call
defer_sub "${package}::new" => sub {
78216µs42.74ms unquote_sub $self->generate_method(
# spent 1.41ms making 2 calls to Method::Generate::Constructor::generate_method, avg 705µs/call # spent 1.33ms making 2 calls to Sub::Quote::unquote_sub, avg 665µs/call
79 $package, 'new', $self->{attribute_specs}, { no_install => 1 }
80 )
8128µs264µs };
# spent 64µs making 2 calls to Sub::Defer::defer_sub, avg 32µs/call
8225µs $self;
83}
84
85
# spent 1.41ms (130µs+1.28) within Method::Generate::Constructor::generate_method which was called 2 times, avg 705µs/call: # 2 times (130µs+1.28ms) by Method::Generate::Constructor::__ANON__[/usr/share/perl5/Method/Generate/Constructor.pm:81] at line 78, avg 705µs/call
sub generate_method {
8622µs my ($self, $into, $name, $spec, $quote_opts) = @_;
87223µs foreach my $no_init (grep !exists($spec->{$_}{init_arg}), keys %$spec) {
881115µs $spec->{$no_init}{init_arg} = $no_init;
89 }
9023µs local $self->{captures} = {};
9121µs my $body = ' my $class = shift;'."\n"
92 .' $class = ref($class) if ref($class);'."\n";
9324µs235µs $body .= $self->_handle_subconstructor($into, $name);
# spent 35µs making 2 calls to Method::Generate::Constructor::_handle_subconstructor, avg 17µs/call
94216µs29µs my $into_buildargs = $into->can('BUILDARGS');
# spent 9µs making 2 calls to UNIVERSAL::can, avg 5µs/call
9523µs if ( $into_buildargs && $into_buildargs != \&Moo::Object::BUILDARGS ) {
96 $body .= $self->_generate_args_via_buildargs;
97 } else {
98214µs24µs $body .= $self->_generate_args;
# spent 4µs making 2 calls to Method::Generate::Constructor::_generate_args, avg 2µs/call
99 }
10024µs271µs $body .= $self->_check_required($spec);
# spent 71µs making 2 calls to Method::Generate::Constructor::_check_required, avg 36µs/call
10126µs243µs $body .= ' my $new = '.$self->construction_string.";\n";
# spent 43µs making 2 calls to Method::Generate::Constructor::construction_string, avg 22µs/call
10226µs2969µs $body .= $self->_assign_new($spec);
# spent 969µs making 2 calls to Method::Generate::Constructor::_assign_new, avg 484µs/call
103218µs211µs if ($into->can('BUILD')) {
# spent 11µs making 2 calls to UNIVERSAL::can, avg 6µs/call
104 $body .= $self->buildall_generator->buildall_body_for(
105 $into, '$new', '$args'
106 );
107 }
10821µs $body .= ' return $new;'."\n";
109211µs26µs if ($into->can('DEMOLISH')) {
# spent 6µs making 2 calls to UNIVERSAL::can, avg 3µs/call
110 require Method::Generate::DemolishAll;
111 Method::Generate::DemolishAll->new->generate_method($into);
112 }
113 quote_sub
114212µs2132µs "${into}::${name}" => $body,
# spent 132µs making 2 calls to Sub::Quote::quote_sub, avg 66µs/call
115 $self->{captures}, $quote_opts||{}
116 ;
117}
118
119
# spent 35µs (15+20) within Method::Generate::Constructor::_handle_subconstructor which was called 2 times, avg 17µs/call: # 2 times (15µs+20µs) by Method::Generate::Constructor::generate_method at line 93, avg 17µs/call
sub _handle_subconstructor {
12021µs my ($self, $into, $name) = @_;
121217µs220µs if (my $gen = $self->{subconstructor_handler}) {
# spent 20µs making 2 calls to Sub::Quote::quotify, avg 10µs/call
122 ' if ($class ne '.quotify($into).') {'."\n".
123 $gen.
124 ' }'."\n";
125 } else {
126 ''
127 }
128}
129
130
# spent 23µs within Method::Generate::Constructor::_cap_call which was called 11 times, avg 2µs/call: # 11 times (23µs+0s) by Method::Generate::Constructor::_assign_new at line 181, avg 2µs/call
sub _cap_call {
131113µs my ($self, $code, $captures) = @_;
1321111µs @{$self->{captures}}{keys %$captures} = values %$captures if $captures;
1331118µs $code;
134}
135
136sub _generate_args_via_buildargs {
137 my ($self) = @_;
138 q{ my $args = $class->BUILDARGS(@_);}."\n"
139 .q{ die "BUILDARGS did not return a hashref" unless ref($args) eq 'HASH';}
140 ."\n";
141}
142
143# inlined from Moo::Object - update that first.
144
# spent 4µs within Method::Generate::Constructor::_generate_args which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by Method::Generate::Constructor::generate_method at line 98, avg 2µs/call
sub _generate_args {
1452800ns my ($self) = @_;
14627µs return <<'_EOA';
147 my $args;
148 if ( scalar @_ == 1 ) {
149 unless ( defined $_[0] && ref $_[0] eq 'HASH' ) {
150 die "Single parameters to new() must be a HASH ref"
151 ." data => ". $_[0] ."\n";
152 }
153 $args = { %{ $_[0] } };
154 }
155 elsif ( @_ % 2 ) {
156 die "The new() method for $class expects a hash reference or a"
157 . " key/value list. You passed an odd number of arguments\n";
158 }
159 else {
160 $args = {@_};
161 }
162_EOA
163
164}
165
166
# spent 969µs (204+765) within Method::Generate::Constructor::_assign_new which was called 2 times, avg 484µs/call: # 2 times (204µs+765µs) by Method::Generate::Constructor::generate_method at line 102, avg 484µs/call
sub _assign_new {
1672900ns my ($self, $spec) = @_;
16823µs22µs my $ag = $self->accessor_generator;
# spent 2µs making 2 calls to Method::Generate::Constructor::accessor_generator, avg 1µs/call
1692700ns my %test;
170216µs22µs NAME: foreach my $name (sort keys %$spec) {
# spent 2µs making 2 calls to Method::Generate::Constructor::CORE:sort, avg 1µs/call
1711311µs my $attr_spec = $spec->{$name};
1721321µs2262µs next NAME unless defined($attr_spec->{init_arg})
# spent 262µs making 2 calls to Method::Generate::Accessor::has_eager_default, avg 131µs/call
173 or $ag->has_eager_default($name, $attr_spec);
1741114µs $test{$name} = $attr_spec->{init_arg};
175 }
1761125µs1135µs join '', map {
# spent 35µs making 11 calls to Sub::Quote::quotify, avg 3µs/call
177237µs23µs my $arg_key = quotify($test{$_});
# spent 3µs making 2 calls to Method::Generate::Constructor::CORE:sort, avg 2µs/call
178116µs my $test = "exists \$args->{$arg_key}";
179114µs my $source = "\$args->{$arg_key}";
180113µs my $attr_spec = $spec->{$_};
1811126µs22461µs $self->_cap_call($ag->generate_populate_set(
# spent 438µs making 11 calls to Method::Generate::Accessor::generate_populate_set, avg 40µs/call # spent 23µs making 11 calls to Method::Generate::Constructor::_cap_call, avg 2µs/call
182 '$new', $_, $attr_spec, $source, $test, $test{$_},
183 ));
184 } sort keys %test;
185}
186
187
# spent 71µs (65+7) within Method::Generate::Constructor::_check_required which was called 2 times, avg 36µs/call: # 2 times (65µs+7µs) by Method::Generate::Constructor::generate_method at line 100, avg 36µs/call
sub _check_required {
1882900ns my ($self, $spec) = @_;
189 my @required_init =
190 map $spec->{$_}{init_arg},
191 grep {
1921556µs27µs my %s = %{$spec->{$_}}; # ignore required if default or builder set
# spent 7µs making 2 calls to Method::Generate::Constructor::CORE:sort, avg 3µs/call
193138µs $s{required} and not($s{builder} or $s{default})
194 } sort keys %$spec;
19524µs return '' unless @required_init;
19616µs ' if (my @missing = grep !exists $args->{$_}, qw('
197 .join(' ',@required_init).')) {'."\n"
198 .q{ die "Missing required arguments: ".join(', ', sort @missing);}."\n"
199 ." }\n";
200}
201
2024136µs4876µs
# spent 51µs (9+42) within Method::Generate::Constructor::__ANON__[/usr/share/perl5/Method/Generate/Constructor.pm:202] which was called: # once (9µs+42µs) by import::into at line 36 of Import/Into.pm # spent 428µs (21+407) within Method::Generate::Constructor::BEGIN@202 which was called: # once (21µs+407µs) by DBIx::Class::Storage::BlockRunner::BEGIN@16 at line 202
use Moo;
# spent 428µs making 1 call to Method::Generate::Constructor::BEGIN@202 # spent 407µs making 1 call to Moo::import # spent 29µs making 1 call to strictures::import # spent 13µs making 1 call to Module::Runtime::use_module
203# bootstrap our own constructor
204sub new {
2051300ns my $class = shift;
20616µs16µs bless $class->BUILDARGS(@_), $class;
# spent 6µs making 1 call to Moo::Object::BUILDARGS
207}
20819µs2202µsMoo->_constructor_maker_for(__PACKAGE__)
# spent 175µs making 1 call to Moo::_constructor_maker_for # spent 27µs making 1 call to Method::Generate::Constructor::register_attribute_specs
209->register_attribute_specs(
210 attribute_specs => {
211 is => 'ro',
212 reader => 'all_attribute_specs',
213 },
214 accessor_generator => { is => 'ro' },
215 construction_string => { is => 'lazy' },
216 construction_builder => { is => 'bare' },
217 subconstructor_handler => { is => 'ro' },
218 package => { is => 'bare' },
219);
220
22114µs1;
 
# spent 12µs within Method::Generate::Constructor::CORE:sort which was called 6 times, avg 2µs/call: # 2 times (7µs+0s) by Method::Generate::Constructor::_check_required at line 192, avg 3µs/call # 2 times (3µs+0s) by Method::Generate::Constructor::_assign_new at line 177, avg 2µs/call # 2 times (2µs+0s) by Method::Generate::Constructor::_assign_new at line 170, avg 1µs/call
sub Method::Generate::Constructor::CORE:sort; # opcode
# spent 9µs within Method::Generate::Constructor::CORE:subst which was called 13 times, avg 692ns/call: # 13 times (9µs+0s) by Method::Generate::Constructor::register_attribute_specs at line 12, avg 692ns/call
sub Method::Generate::Constructor::CORE:subst; # opcode