Filename | /usr/local/lib/perl/5.14.2/Class/MOP/Method/Constructor.pm |
Statements | Executed 936 statements in 3.23ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
35 | 2 | 2 | 1.04ms | 76.2ms | _generate_constructor_method_inline | Class::MOP::Method::Constructor::
30 | 1 | 1 | 454µs | 45.0ms | new | Class::MOP::Method::Constructor::
30 | 1 | 1 | 426µs | 426µs | _new | Class::MOP::Method::Constructor::
30 | 1 | 1 | 208µs | 44.1ms | _initialize_body | Class::MOP::Method::Constructor::
35 | 1 | 1 | 175µs | 8.06ms | _eval_environment | Class::MOP::Method::Constructor::
1 | 1 | 1 | 13µs | 16µs | BEGIN@10 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 10µs | 10µs | BEGIN@3 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 8µs | 57µs | BEGIN@15 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 8µs | 51µs | BEGIN@14 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 7µs | 12µs | BEGIN@11 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 7µs | 762µs | BEGIN@17 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 7µs | 36µs | BEGIN@13 | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:111] | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:115] | Class::MOP::Method::Constructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:93] | 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 | |||||
2 | package Class::MOP::Method::Constructor; | ||||
3 | # spent 10µs within Class::MOP::Method::Constructor::BEGIN@3 which was called:
# once (10µs+0s) by Class::MOP::Class::BEGIN@16 at line 5 | ||||
4 | 1 | 5µs | $Class::MOP::Method::Constructor::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 30µs | 1 | 10µs | } # spent 10µs making 1 call to Class::MOP::Method::Constructor::BEGIN@3 |
6 | { | ||||
7 | 2 | 1µs | $Class::MOP::Method::Constructor::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 24µs | 2 | 19µs | # spent 16µs (13+3) within Class::MOP::Method::Constructor::BEGIN@10 which was called:
# once (13µs+3µs) by Class::MOP::Class::BEGIN@16 at line 10 # spent 16µs making 1 call to Class::MOP::Method::Constructor::BEGIN@10
# spent 3µs making 1 call to strict::import |
11 | 2 | 23µs | 2 | 18µs | # spent 12µs (7+5) within Class::MOP::Method::Constructor::BEGIN@11 which was called:
# once (7µs+5µs) by Class::MOP::Class::BEGIN@16 at line 11 # spent 12µs making 1 call to Class::MOP::Method::Constructor::BEGIN@11
# spent 5µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 41µs | 2 | 65µs | # spent 36µs (7+29) within Class::MOP::Method::Constructor::BEGIN@13 which was called:
# once (7µs+29µs) by Class::MOP::Class::BEGIN@16 at line 13 # spent 36µs making 1 call to Class::MOP::Method::Constructor::BEGIN@13
# spent 29µs making 1 call to Exporter::import |
14 | 2 | 25µs | 2 | 94µs | # spent 51µs (8+43) within Class::MOP::Method::Constructor::BEGIN@14 which was called:
# once (8µs+43µs) by Class::MOP::Class::BEGIN@16 at line 14 # spent 51µs making 1 call to Class::MOP::Method::Constructor::BEGIN@14
# spent 43µs making 1 call to Exporter::import |
15 | 2 | 26µs | 2 | 107µs | # spent 57µs (8+49) within Class::MOP::Method::Constructor::BEGIN@15 which was called:
# once (8µs+49µs) by Class::MOP::Class::BEGIN@16 at line 15 # spent 57µs making 1 call to Class::MOP::Method::Constructor::BEGIN@15
# spent 49µs making 1 call to Exporter::import |
16 | |||||
17 | 2 | 452µs | 2 | 1.52ms | # spent 762µs (7+755) within Class::MOP::Method::Constructor::BEGIN@17 which was called:
# once (7µs+755µs) by Class::MOP::Class::BEGIN@16 at line 17 # spent 762µs making 1 call to Class::MOP::Method::Constructor::BEGIN@17
# spent 755µs making 1 call to base::import |
18 | |||||
19 | # spent 45.0ms (454µs+44.6) within Class::MOP::Method::Constructor::new which was called 30 times, avg 1.50ms/call:
# 30 times (454µs+44.6ms) by Class::MOP::Class::_inline_constructor at line 1438 of Class/MOP/Class.pm, avg 1.50ms/call | ||||
20 | 240 | 499µs | my $class = shift; | ||
21 | my %options = @_; | ||||
22 | |||||
23 | 60 | 48µs | (blessed $options{metaclass} && $options{metaclass}->isa('Class::MOP::Class')) # spent 25µs making 30 calls to UNIVERSAL::isa, avg 823ns/call
# spent 24µs making 30 calls to Scalar::Util::blessed, avg 787ns/call | ||
24 | || confess "You must pass a metaclass instance if you want to inline" | ||||
25 | if $options{is_inline}; | ||||
26 | |||||
27 | ($options{package_name} && $options{name}) | ||||
28 | || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; | ||||
29 | |||||
30 | 30 | 426µs | my $self = $class->_new(\%options); # spent 426µs making 30 calls to Class::MOP::Method::Constructor::_new, avg 14µs/call | ||
31 | |||||
32 | # we don't want this creating | ||||
33 | # a cycle in the code, if not | ||||
34 | # needed | ||||
35 | 30 | 31µs | weaken($self->{'associated_metaclass'}); # spent 31µs making 30 calls to Scalar::Util::weaken, avg 1µs/call | ||
36 | |||||
37 | 30 | 44.1ms | $self->_initialize_body; # spent 44.1ms making 30 calls to Class::MOP::Method::Constructor::_initialize_body, avg 1.47ms/call | ||
38 | |||||
39 | return $self; | ||||
40 | } | ||||
41 | |||||
42 | # spent 426µs within Class::MOP::Method::Constructor::_new which was called 30 times, avg 14µs/call:
# 30 times (426µs+0s) by Class::MOP::Method::Constructor::new at line 30, avg 14µs/call | ||||
43 | 120 | 457µs | my $class = shift; | ||
44 | |||||
45 | return Class::MOP::Class->initialize($class)->new_object(@_) | ||||
46 | if $class ne __PACKAGE__; | ||||
47 | |||||
48 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
49 | |||||
50 | return bless { | ||||
51 | # inherited from Class::MOP::Method | ||||
52 | body => $params->{body}, | ||||
53 | # associated_metaclass => $params->{associated_metaclass}, # overridden | ||||
54 | package_name => $params->{package_name}, | ||||
55 | name => $params->{name}, | ||||
56 | original_method => $params->{original_method}, | ||||
57 | |||||
58 | # inherited from Class::MOP::Generated | ||||
59 | is_inline => $params->{is_inline} || 0, | ||||
60 | definition_context => $params->{definition_context}, | ||||
61 | |||||
62 | # inherited from Class::MOP::Inlined | ||||
63 | _expected_method_class => $params->{_expected_method_class}, | ||||
64 | |||||
65 | # defined in this subclass | ||||
66 | options => $params->{options} || {}, | ||||
67 | associated_metaclass => $params->{metaclass}, | ||||
68 | }, $class; | ||||
69 | } | ||||
70 | |||||
71 | ## accessors | ||||
72 | |||||
73 | 35 | 82µs | sub options { (shift)->{'options'} } | ||
74 | 90 | 192µs | sub associated_metaclass { (shift)->{'associated_metaclass'} } | ||
75 | |||||
76 | ## method | ||||
77 | |||||
78 | # spent 44.1ms (208µs+43.9) within Class::MOP::Method::Constructor::_initialize_body which was called 30 times, avg 1.47ms/call:
# 30 times (208µs+43.9ms) by Class::MOP::Method::Constructor::new at line 37, avg 1.47ms/call | ||||
79 | 120 | 225µs | my $self = shift; | ||
80 | my $method_name = '_generate_constructor_method'; | ||||
81 | |||||
82 | 30 | 22µs | $method_name .= '_inline' if $self->is_inline; # spent 22µs making 30 calls to Class::MOP::Method::Generated::is_inline, avg 720ns/call | ||
83 | |||||
84 | 30 | 43.9ms | $self->{'body'} = $self->$method_name; # spent 43.9ms making 30 calls to Class::MOP::Method::Constructor::_generate_constructor_method_inline, avg 1.46ms/call | ||
85 | } | ||||
86 | |||||
87 | # spent 8.06ms (175µs+7.89) within Class::MOP::Method::Constructor::_eval_environment which was called 35 times, avg 230µs/call:
# 35 times (175µs+7.89ms) by Class::MOP::Method::Generated::_compile_code at line 59 of Class/MOP/Method/Generated.pm, avg 230µs/call | ||||
88 | 70 | 132µs | my $self = shift; | ||
89 | 70 | 7.89ms | return $self->associated_metaclass->_eval_environment; # spent 5.03ms making 30 calls to Class::MOP::Class::_eval_environment, avg 168µs/call
# spent 2.82ms making 5 calls to Moose::Meta::Class::_eval_environment, avg 565µs/call
# spent 32µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 1µs/call
# spent 10µs making 5 calls to Class::MOP::Method::associated_metaclass, avg 2µs/call | ||
90 | } | ||||
91 | |||||
92 | sub _generate_constructor_method { | ||||
93 | return sub { Class::MOP::Class->initialize(shift)->new_object(@_) } | ||||
94 | } | ||||
95 | |||||
96 | # spent 76.2ms (1.04+75.1) within Class::MOP::Method::Constructor::_generate_constructor_method_inline which was called 35 times, avg 2.18ms/call:
# 30 times (825µs+43.0ms) by Class::MOP::Method::Constructor::_initialize_body at line 84, avg 1.46ms/call
# 5 times (219µs+32.1ms) by Moose::Meta::Method::Constructor::_initialize_body at line 57 of Moose/Meta/Method/Constructor.pm, avg 6.46ms/call | ||||
97 | 210 | 911µs | my $self = shift; | ||
98 | |||||
99 | 35 | 33µs | my $meta = $self->associated_metaclass; # spent 28µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 920ns/call
# spent 6µs making 5 calls to Class::MOP::Method::associated_metaclass, avg 1µs/call | ||
100 | |||||
101 | 35 | 48.4ms | my @source = ( # spent 48.4ms making 35 calls to Class::MOP::Class::_inline_new_object, avg 1.38ms/call | ||
102 | 'sub {', | ||||
103 | $meta->_inline_new_object, | ||||
104 | '}', | ||||
105 | ); | ||||
106 | |||||
107 | 35 | 47µs | warn join("\n", @source) if $self->options->{debug}; # spent 47µs making 35 calls to Class::MOP::Method::Constructor::options, avg 1µs/call | ||
108 | |||||
109 | my $code = try { | ||||
110 | 35 | 104µs | 35 | 25.7ms | $self->_compile_code(\@source); # spent 25.7ms making 35 calls to Class::MOP::Method::Generated::_compile_code, avg 734µs/call |
111 | } | ||||
112 | catch { | ||||
113 | my $source = join("\n", @source); | ||||
114 | confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$_"; | ||||
115 | 70 | 26.7ms | }; # spent 26.6ms making 35 calls to Try::Tiny::try, avg 759µs/call
# spent 111µs making 35 calls to Try::Tiny::catch, avg 3µs/call | ||
116 | |||||
117 | return $code; | ||||
118 | } | ||||
119 | |||||
120 | 1 | 3µs | 1; | ||
121 | |||||
122 | # ABSTRACT: Method Meta Object for constructors | ||||
123 | |||||
124 | __END__ |