Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Method/Constructor.pm |
Statements | Executed 892 statements in 1.88ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
31 | 2 | 2 | 589µs | 49.2ms | _generate_constructor_method_inline | Class::MOP::Method::Constructor::
30 | 1 | 1 | 388µs | 48.0ms | new | Class::MOP::Method::Constructor::
30 | 1 | 1 | 166µs | 47.4ms | _initialize_body | Class::MOP::Method::Constructor::
30 | 1 | 1 | 134µs | 134µs | _new | Class::MOP::Method::Constructor::
31 | 1 | 1 | 99µs | 3.26ms | _eval_environment | Class::MOP::Method::Constructor::
31 | 1 | 1 | 60µs | 10.9ms | try {...} | Class::MOP::Method::Constructor::
1 | 1 | 1 | 9µs | 11µs | BEGIN@4 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 6µs | 440µs | BEGIN@10 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 4µs | 9µs | BEGIN@5 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 4µs | 25µs | BEGIN@7 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 4µs | 20µs | BEGIN@8 | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:108] | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:115] | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:90] | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | _generate_constructor_method | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | catch {...} | Class::MOP::Method::Constructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::MOP::Method::Constructor; | ||||
2 | 1 | 300ns | our $VERSION = '2.1605'; | ||
3 | |||||
4 | 2 | 15µs | 2 | 13µs | # spent 11µs (9+2) within Class::MOP::Method::Constructor::BEGIN@4 which was called:
# once (9µs+2µs) by Class::MOP::Class::BEGIN@10 at line 4 # spent 11µs making 1 call to Class::MOP::Method::Constructor::BEGIN@4
# spent 2µs making 1 call to strict::import |
5 | 2 | 14µs | 2 | 13µs | # spent 9µs (4+4) within Class::MOP::Method::Constructor::BEGIN@5 which was called:
# once (4µs+4µs) by Class::MOP::Class::BEGIN@10 at line 5 # spent 9µs making 1 call to Class::MOP::Method::Constructor::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 14µs | 2 | 46µs | # spent 25µs (4+21) within Class::MOP::Method::Constructor::BEGIN@7 which was called:
# once (4µs+21µs) by Class::MOP::Class::BEGIN@10 at line 7 # spent 25µs making 1 call to Class::MOP::Method::Constructor::BEGIN@7
# spent 21µs making 1 call to Exporter::import |
8 | 2 | 14µs | 2 | 36µs | # spent 20µs (4+16) within Class::MOP::Method::Constructor::BEGIN@8 which was called:
# once (4µs+16µs) by Class::MOP::Class::BEGIN@10 at line 8 # spent 20µs making 1 call to Class::MOP::Method::Constructor::BEGIN@8
# spent 16µs making 1 call to Exporter::import |
9 | |||||
10 | 2 | 269µs | 2 | 874µs | # spent 440µs (6+434) within Class::MOP::Method::Constructor::BEGIN@10 which was called:
# once (6µs+434µs) by Class::MOP::Class::BEGIN@10 at line 10 # spent 440µs making 1 call to Class::MOP::Method::Constructor::BEGIN@10
# spent 434µs making 1 call to parent::import |
11 | |||||
12 | # spent 48.0ms (388µs+47.6) within Class::MOP::Method::Constructor::new which was called 30 times, avg 1.60ms/call:
# 30 times (388µs+47.6ms) by Class::MOP::Class::_inline_constructor at line 1464 of Class/MOP/Class.pm, avg 1.60ms/call | ||||
13 | 30 | 8µs | my $class = shift; | ||
14 | 30 | 43µs | my %options = @_; | ||
15 | |||||
16 | (blessed $options{metaclass} && $options{metaclass}->isa('Class::MOP::Class')) | ||||
17 | || $class->_throw_exception( MustSupplyAMetaclass => params => \%options, | ||||
18 | class => $class | ||||
19 | ) | ||||
20 | 30 | 136µs | 60 | 30µs | if $options{is_inline}; # spent 15µs making 30 calls to Scalar::Util::blessed, avg 503ns/call
# spent 15µs making 30 calls to UNIVERSAL::isa, avg 487ns/call |
21 | |||||
22 | ($options{package_name} && $options{name}) | ||||
23 | 30 | 10µs | || $class->_throw_exception( MustSupplyPackageNameAndName => params => \%options, | ||
24 | class => $class | ||||
25 | ); | ||||
26 | |||||
27 | 30 | 33µs | 30 | 134µs | my $self = $class->_new(\%options); # spent 134µs making 30 calls to Class::MOP::Method::Constructor::_new, avg 4µs/call |
28 | |||||
29 | # we don't want this creating | ||||
30 | # a cycle in the code, if not | ||||
31 | # needed | ||||
32 | 30 | 97µs | 30 | 16µs | weaken($self->{'associated_metaclass'}); # spent 16µs making 30 calls to Scalar::Util::weaken, avg 550ns/call |
33 | |||||
34 | 30 | 27µs | 30 | 47.4ms | $self->_initialize_body; # spent 47.4ms making 30 calls to Class::MOP::Method::Constructor::_initialize_body, avg 1.58ms/call |
35 | |||||
36 | 30 | 58µs | return $self; | ||
37 | } | ||||
38 | |||||
39 | # spent 134µs within Class::MOP::Method::Constructor::_new which was called 30 times, avg 4µs/call:
# 30 times (134µs+0s) by Class::MOP::Method::Constructor::new at line 27, avg 4µs/call | ||||
40 | 30 | 6µs | my $class = shift; | ||
41 | |||||
42 | 30 | 7µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
43 | if $class ne __PACKAGE__; | ||||
44 | |||||
45 | 30 | 15µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
46 | |||||
47 | return bless { | ||||
48 | # inherited from Class::MOP::Method | ||||
49 | body => $params->{body}, | ||||
50 | # associated_metaclass => $params->{associated_metaclass}, # overridden | ||||
51 | package_name => $params->{package_name}, | ||||
52 | name => $params->{name}, | ||||
53 | original_method => $params->{original_method}, | ||||
54 | |||||
55 | # inherited from Class::MOP::Generated | ||||
56 | is_inline => $params->{is_inline} || 0, | ||||
57 | definition_context => $params->{definition_context}, | ||||
58 | |||||
59 | # inherited from Class::MOP::Inlined | ||||
60 | _expected_method_class => $params->{_expected_method_class}, | ||||
61 | |||||
62 | # defined in this subclass | ||||
63 | options => $params->{options} || {}, | ||||
64 | associated_metaclass => $params->{metaclass}, | ||||
65 | 30 | 127µs | }, $class; | ||
66 | } | ||||
67 | |||||
68 | ## accessors | ||||
69 | |||||
70 | 31 | 48µs | sub options { (shift)->{'options'} } | ||
71 | 90 | 111µs | sub associated_metaclass { (shift)->{'associated_metaclass'} } | ||
72 | |||||
73 | ## method | ||||
74 | |||||
75 | # spent 47.4ms (166µs+47.3) within Class::MOP::Method::Constructor::_initialize_body which was called 30 times, avg 1.58ms/call:
# 30 times (166µs+47.3ms) by Class::MOP::Method::Constructor::new at line 34, avg 1.58ms/call | ||||
76 | 30 | 5µs | my $self = shift; | ||
77 | 30 | 7µs | my $method_name = '_generate_constructor_method'; | ||
78 | |||||
79 | 30 | 50µs | 30 | 9µs | $method_name .= '_inline' if $self->is_inline; # spent 9µs making 30 calls to Class::MOP::Method::Generated::is_inline, avg 307ns/call |
80 | |||||
81 | 30 | 107µs | 30 | 47.3ms | $self->{'body'} = $self->$method_name; # spent 47.3ms making 30 calls to Class::MOP::Method::Constructor::_generate_constructor_method_inline, avg 1.58ms/call |
82 | } | ||||
83 | |||||
84 | # spent 3.26ms (99µs+3.16) within Class::MOP::Method::Constructor::_eval_environment which was called 31 times, avg 105µs/call:
# 31 times (99µs+3.16ms) by Class::MOP::Method::Generated::_compile_code at line 52 of Class/MOP/Method/Generated.pm, avg 105µs/call | ||||
85 | 31 | 6µs | my $self = shift; | ||
86 | 31 | 77µs | 62 | 3.16ms | return $self->associated_metaclass->_eval_environment; # spent 2.94ms making 30 calls to Class::MOP::Class::_eval_environment, avg 98µs/call
# spent 210µs making 1 call to Moose::Meta::Class::_eval_environment
# spent 15µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 490ns/call
# spent 500ns making 1 call to Class::MOP::Method::associated_metaclass |
87 | } | ||||
88 | |||||
89 | sub _generate_constructor_method { | ||||
90 | return sub { Class::MOP::Class->initialize(shift)->new_object(@_) } | ||||
91 | } | ||||
92 | |||||
93 | # spent 49.2ms (589µs+48.6) within Class::MOP::Method::Constructor::_generate_constructor_method_inline which was called 31 times, avg 1.59ms/call:
# 30 times (553µs+46.7ms) by Class::MOP::Method::Constructor::_initialize_body at line 81, avg 1.58ms/call
# once (36µs+1.92ms) by Moose::Meta::Method::Constructor::_initialize_body at line 54 of Moose/Meta/Method/Constructor.pm | ||||
94 | 31 | 4µs | my $self = shift; | ||
95 | |||||
96 | 31 | 23µs | 31 | 17µs | my $meta = $self->associated_metaclass; # spent 16µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 540ns/call
# spent 1µs making 1 call to Class::MOP::Method::associated_metaclass |
97 | |||||
98 | 31 | 155µs | 31 | 37.1ms | my @source = ( # spent 37.1ms making 31 calls to Class::MOP::Class::_inline_new_object, avg 1.20ms/call |
99 | 'sub {', | ||||
100 | $meta->_inline_new_object, | ||||
101 | '}', | ||||
102 | ); | ||||
103 | |||||
104 | 31 | 36µs | 31 | 26µs | warn join("\n", @source) if $self->options->{debug}; # spent 26µs making 31 calls to Class::MOP::Method::Constructor::options, avg 835ns/call |
105 | |||||
106 | # spent 10.9ms (60µs+10.8) within Class::MOP::Method::Constructor::try {...} which was called 31 times, avg 351µs/call:
# 31 times (60µs+10.8ms) by Try::Tiny::try at line 87 of Try/Tiny.pm, avg 351µs/call | ||||
107 | 31 | 59µs | 31 | 10.8ms | $self->_compile_code(\@source); # spent 10.8ms making 31 calls to Class::MOP::Method::Generated::_compile_code, avg 349µs/call |
108 | } | ||||
109 | catch { | ||||
110 | my $source = join("\n", @source); | ||||
111 | $self->_throw_exception( CouldNotEvalConstructor => constructor_method => $self, | ||||
112 | source => $source, | ||||
113 | error => $_ | ||||
114 | ); | ||||
115 | 31 | 206µs | 62 | 11.5ms | }; # spent 11.2ms making 31 calls to Try::Tiny::try, avg 362µs/call
# spent 231µs making 31 calls to Try::Tiny::catch, avg 7µs/call |
116 | |||||
117 | 31 | 85µs | return $code; | ||
118 | } | ||||
119 | |||||
120 | 1 | 2µs | 1; | ||
121 | |||||
122 | # ABSTRACT: Method Meta Object for constructors | ||||
123 | |||||
124 | __END__ |