Filename | /usr/local/lib/perl/5.18.2/Class/MOP/Method/Constructor.pm |
Statements | Executed 1162 statements in 3.95ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
58 | 2 | 2 | 1.86ms | 195ms | _generate_constructor_method_inline | Class::MOP::Method::Constructor::
30 | 1 | 1 | 595µs | 71.9ms | new | Class::MOP::Method::Constructor::
58 | 1 | 1 | 303µs | 35.3ms | _eval_environment | Class::MOP::Method::Constructor::
30 | 1 | 1 | 200µs | 200µs | _new | Class::MOP::Method::Constructor::
30 | 1 | 1 | 185µs | 71.0ms | _initialize_body | Class::MOP::Method::Constructor::
1 | 1 | 1 | 17µs | 42µs | BEGIN@8 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 9µs | 18µs | BEGIN@4 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 8µs | 11µs | BEGIN@5 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 7µs | 504µs | BEGIN@10 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 6µs | 31µs | BEGIN@7 | 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::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::MOP::Method::Constructor; | ||||
2 | 1 | 500ns | our $VERSION = '2.1604'; | ||
3 | |||||
4 | 2 | 20µs | 2 | 28µs | # spent 18µs (9+9) within Class::MOP::Method::Constructor::BEGIN@4 which was called:
# once (9µs+9µs) by Class::MOP::Class::BEGIN@10 at line 4 # spent 18µs making 1 call to Class::MOP::Method::Constructor::BEGIN@4
# spent 10µs making 1 call to strict::import |
5 | 2 | 22µs | 2 | 14µs | # spent 11µs (8+3) within Class::MOP::Method::Constructor::BEGIN@5 which was called:
# once (8µs+3µs) by Class::MOP::Class::BEGIN@10 at line 5 # spent 11µs making 1 call to Class::MOP::Method::Constructor::BEGIN@5
# spent 3µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 20µs | 2 | 56µs | # spent 31µs (6+25) within Class::MOP::Method::Constructor::BEGIN@7 which was called:
# once (6µs+25µs) by Class::MOP::Class::BEGIN@10 at line 7 # spent 31µs making 1 call to Class::MOP::Method::Constructor::BEGIN@7
# spent 25µs making 1 call to Exporter::import |
8 | 2 | 28µs | 2 | 66µs | # spent 42µs (17+25) within Class::MOP::Method::Constructor::BEGIN@8 which was called:
# once (17µs+25µs) by Class::MOP::Class::BEGIN@10 at line 8 # spent 42µs making 1 call to Class::MOP::Method::Constructor::BEGIN@8
# spent 25µs making 1 call to Exporter::import |
9 | |||||
10 | 2 | 382µs | 2 | 1.00ms | # spent 504µs (7+497) within Class::MOP::Method::Constructor::BEGIN@10 which was called:
# once (7µs+497µs) by Class::MOP::Class::BEGIN@10 at line 10 # spent 504µs making 1 call to Class::MOP::Method::Constructor::BEGIN@10
# spent 497µs making 1 call to parent::import |
11 | |||||
12 | # spent 71.9ms (595µs+71.3) within Class::MOP::Method::Constructor::new which was called 30 times, avg 2.40ms/call:
# 30 times (595µs+71.3ms) by Class::MOP::Class::_inline_constructor at line 1453 of Class/MOP/Class.pm, avg 2.40ms/call | ||||
13 | 30 | 11µs | my $class = shift; | ||
14 | 30 | 53µs | my %options = @_; | ||
15 | |||||
16 | 30 | 172µs | 60 | 48µs | (blessed $options{metaclass} && $options{metaclass}->isa('Class::MOP::Class')) # spent 24µs making 30 calls to Scalar::Util::blessed, avg 810ns/call
# spent 24µs making 30 calls to UNIVERSAL::isa, avg 807ns/call |
17 | || $class->_throw_exception( MustSupplyAMetaclass => params => \%options, | ||||
18 | class => $class | ||||
19 | ) | ||||
20 | if $options{is_inline}; | ||||
21 | |||||
22 | 30 | 14µs | ($options{package_name} && $options{name}) | ||
23 | || $class->_throw_exception( MustSupplyPackageNameAndName => params => \%options, | ||||
24 | class => $class | ||||
25 | ); | ||||
26 | |||||
27 | 30 | 51µs | 30 | 200µs | my $self = $class->_new(\%options); # spent 200µs making 30 calls to Class::MOP::Method::Constructor::_new, avg 7µs/call |
28 | |||||
29 | # we don't want this creating | ||||
30 | # a cycle in the code, if not | ||||
31 | # needed | ||||
32 | 30 | 200µs | 30 | 28µs | weaken($self->{'associated_metaclass'}); # spent 28µs making 30 calls to Scalar::Util::weaken, avg 933ns/call |
33 | |||||
34 | 30 | 35µs | 30 | 71.0ms | $self->_initialize_body; # spent 71.0ms making 30 calls to Class::MOP::Method::Constructor::_initialize_body, avg 2.37ms/call |
35 | |||||
36 | 30 | 81µs | return $self; | ||
37 | } | ||||
38 | |||||
39 | # spent 200µs within Class::MOP::Method::Constructor::_new which was called 30 times, avg 7µs/call:
# 30 times (200µs+0s) by Class::MOP::Method::Constructor::new at line 27, avg 7µs/call | ||||
40 | 30 | 8µ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 | 14µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
46 | |||||
47 | 30 | 204µs | 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 | }, $class; | ||||
66 | } | ||||
67 | |||||
68 | ## accessors | ||||
69 | |||||
70 | 58 | 142µs | sub options { (shift)->{'options'} } | ||
71 | 90 | 182µs | sub associated_metaclass { (shift)->{'associated_metaclass'} } | ||
72 | |||||
73 | ## method | ||||
74 | |||||
75 | # spent 71.0ms (185µs+70.8) within Class::MOP::Method::Constructor::_initialize_body which was called 30 times, avg 2.37ms/call:
# 30 times (185µs+70.8ms) by Class::MOP::Method::Constructor::new at line 34, avg 2.37ms/call | ||||
76 | 30 | 5µs | my $self = shift; | ||
77 | 30 | 6µs | my $method_name = '_generate_constructor_method'; | ||
78 | |||||
79 | 30 | 69µs | 30 | 15µs | $method_name .= '_inline' if $self->is_inline; # spent 15µs making 30 calls to Class::MOP::Method::Generated::is_inline, avg 513ns/call |
80 | |||||
81 | 30 | 127µs | 30 | 70.8ms | $self->{'body'} = $self->$method_name; # spent 70.8ms making 30 calls to Class::MOP::Method::Constructor::_generate_constructor_method_inline, avg 2.36ms/call |
82 | } | ||||
83 | |||||
84 | # spent 35.3ms (303µs+35.0) within Class::MOP::Method::Constructor::_eval_environment which was called 58 times, avg 609µs/call:
# 58 times (303µs+35.0ms) by Class::MOP::Method::Generated::_compile_code at line 52 of Class/MOP/Method/Generated.pm, avg 609µs/call | ||||
85 | 58 | 14µs | my $self = shift; | ||
86 | 58 | 221µs | 116 | 35.0ms | return $self->associated_metaclass->_eval_environment; # spent 26.6ms making 28 calls to Moose::Meta::Class::_eval_environment, avg 949µs/call
# spent 8.36ms making 30 calls to Class::MOP::Class::_eval_environment, avg 279µs/call
# spent 31µs making 28 calls to Class::MOP::Method::associated_metaclass, avg 1µs/call
# spent 27µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 897ns/call |
87 | } | ||||
88 | |||||
89 | sub _generate_constructor_method { | ||||
90 | return sub { Class::MOP::Class->initialize(shift)->new_object(@_) } | ||||
91 | } | ||||
92 | |||||
93 | # spent 195ms (1.86+193) within Class::MOP::Method::Constructor::_generate_constructor_method_inline which was called 58 times, avg 3.37ms/call:
# 30 times (810µs+70.0ms) by Class::MOP::Method::Constructor::_initialize_body at line 81, avg 2.36ms/call
# 28 times (1.05ms+123ms) by Moose::Meta::Method::Constructor::_initialize_body at line 54 of Moose/Meta/Method/Constructor.pm, avg 4.45ms/call | ||||
94 | 58 | 14µs | my $self = shift; | ||
95 | |||||
96 | 58 | 88µs | 58 | 68µs | my $meta = $self->associated_metaclass; # spent 45µs making 28 calls to Class::MOP::Method::associated_metaclass, avg 2µs/call
# spent 24µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 790ns/call |
97 | |||||
98 | 58 | 444µs | 58 | 114ms | my @source = ( # spent 114ms making 58 calls to Class::MOP::Class::_inline_new_object, avg 1.96ms/call |
99 | 'sub {', | ||||
100 | $meta->_inline_new_object, | ||||
101 | '}', | ||||
102 | ); | ||||
103 | |||||
104 | 58 | 149µs | 58 | 93µs | warn join("\n", @source) if $self->options->{debug}; # spent 93µs making 58 calls to Class::MOP::Method::Constructor::options, avg 2µs/call |
105 | |||||
106 | my $code = try { | ||||
107 | 58 | 190µs | 58 | 78.0ms | $self->_compile_code(\@source); # spent 78.0ms making 58 calls to Class::MOP::Method::Generated::_compile_code, avg 1.34ms/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 | 58 | 663µs | 116 | 79.5ms | }; # spent 79.3ms making 58 calls to Try::Tiny::try, avg 1.37ms/call
# spent 200µs making 58 calls to Try::Tiny::catch, avg 3µs/call |
116 | |||||
117 | 58 | 309µs | return $code; | ||
118 | } | ||||
119 | |||||
120 | 1 | 2µs | 1; | ||
121 | |||||
122 | # ABSTRACT: Method Meta Object for constructors | ||||
123 | |||||
124 | __END__ |