Filename | /opt/perl-5.18.1/lib/site_perl/5.18.1/darwin-thread-multi-2level/Class/MOP/Method/Constructor.pm |
Statements | Executed 896 statements in 3.76ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
31 | 2 | 2 | 1.28ms | 81.9ms | _generate_constructor_method_inline | Class::MOP::Method::Constructor::
30 | 1 | 1 | 712µs | 81.0ms | new | Class::MOP::Method::Constructor::
30 | 1 | 1 | 267µs | 267µs | _new | Class::MOP::Method::Constructor::
30 | 1 | 1 | 235µs | 79.9ms | _initialize_body | Class::MOP::Method::Constructor::
31 | 1 | 1 | 198µs | 12.3ms | _eval_environment | Class::MOP::Method::Constructor::
1 | 1 | 1 | 12µs | 12µs | BEGIN@3 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 10µs | 53µs | BEGIN@15 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 10µs | 1.05ms | BEGIN@17 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 10µs | 15µs | BEGIN@11 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 9µs | 25µs | BEGIN@10 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 9µs | 40µs | BEGIN@13 | Class::MOP::Method::Constructor::
1 | 1 | 1 | 9µs | 42µs | BEGIN@14 | 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 12µs within Class::MOP::Method::Constructor::BEGIN@3 which was called:
# once (12µs+0s) by Class::MOP::Class::BEGIN@16 at line 5 | ||||
4 | 1 | 7µs | $Class::MOP::Method::Constructor::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 41µs | 1 | 12µs | } # spent 12µ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 | 32µs | 2 | 42µs | # spent 25µs (9+16) within Class::MOP::Method::Constructor::BEGIN@10 which was called:
# once (9µs+16µs) by Class::MOP::Class::BEGIN@16 at line 10 # spent 25µs making 1 call to Class::MOP::Method::Constructor::BEGIN@10
# spent 16µs making 1 call to strict::import |
11 | 2 | 32µs | 2 | 20µs | # spent 15µs (10+5) within Class::MOP::Method::Constructor::BEGIN@11 which was called:
# once (10µs+5µs) by Class::MOP::Class::BEGIN@16 at line 11 # spent 15µs making 1 call to Class::MOP::Method::Constructor::BEGIN@11
# spent 5µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 36µs | 2 | 70µs | # spent 40µs (9+31) within Class::MOP::Method::Constructor::BEGIN@13 which was called:
# once (9µs+31µs) by Class::MOP::Class::BEGIN@16 at line 13 # spent 40µs making 1 call to Class::MOP::Method::Constructor::BEGIN@13
# spent 31µs making 1 call to Exporter::import |
14 | 2 | 32µs | 2 | 74µs | # spent 42µs (9+33) within Class::MOP::Method::Constructor::BEGIN@14 which was called:
# once (9µs+33µs) by Class::MOP::Class::BEGIN@16 at line 14 # spent 42µs making 1 call to Class::MOP::Method::Constructor::BEGIN@14
# spent 33µs making 1 call to Exporter::import |
15 | 2 | 36µs | 2 | 96µs | # spent 53µs (10+43) within Class::MOP::Method::Constructor::BEGIN@15 which was called:
# once (10µs+43µs) by Class::MOP::Class::BEGIN@16 at line 15 # spent 53µs making 1 call to Class::MOP::Method::Constructor::BEGIN@15
# spent 43µs making 1 call to Exporter::import |
16 | |||||
17 | 2 | 643µs | 2 | 2.08ms | # spent 1.05ms (10µs+1.04) within Class::MOP::Method::Constructor::BEGIN@17 which was called:
# once (10µs+1.04ms) by Class::MOP::Class::BEGIN@16 at line 17 # spent 1.05ms making 1 call to Class::MOP::Method::Constructor::BEGIN@17
# spent 1.04ms making 1 call to base::import |
18 | |||||
19 | # spent 81.0ms (712µs+80.3) within Class::MOP::Method::Constructor::new which was called 30 times, avg 2.70ms/call:
# 30 times (712µs+80.3ms) by Class::MOP::Class::_inline_constructor at line 1438 of Class/MOP/Class.pm, avg 2.70ms/call | ||||
20 | 30 | 10µs | my $class = shift; | ||
21 | 30 | 74µs | my %options = @_; | ||
22 | |||||
23 | 30 | 202µs | 60 | 60µs | (blessed $options{metaclass} && $options{metaclass}->isa('Class::MOP::Class')) # spent 31µs making 30 calls to Scalar::Util::blessed, avg 1µs/call
# spent 30µs making 30 calls to UNIVERSAL::isa, avg 990ns/call |
24 | || confess "You must pass a metaclass instance if you want to inline" | ||||
25 | if $options{is_inline}; | ||||
26 | |||||
27 | 30 | 11µs | ($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 | 48µs | 30 | 267µs | my $self = $class->_new(\%options); # spent 267µs making 30 calls to Class::MOP::Method::Constructor::_new, avg 9µs/call |
31 | |||||
32 | # we don't want this creating | ||||
33 | # a cycle in the code, if not | ||||
34 | # needed | ||||
35 | 30 | 265µs | 30 | 37µs | weaken($self->{'associated_metaclass'}); # spent 37µs making 30 calls to Scalar::Util::weaken, avg 1µs/call |
36 | |||||
37 | 30 | 33µs | 30 | 79.9ms | $self->_initialize_body; # spent 79.9ms making 30 calls to Class::MOP::Method::Constructor::_initialize_body, avg 2.66ms/call |
38 | |||||
39 | 30 | 97µs | return $self; | ||
40 | } | ||||
41 | |||||
42 | # spent 267µs within Class::MOP::Method::Constructor::_new which was called 30 times, avg 9µs/call:
# 30 times (267µs+0s) by Class::MOP::Method::Constructor::new at line 30, avg 9µs/call | ||||
43 | 30 | 7µs | my $class = shift; | ||
44 | |||||
45 | 30 | 11µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
46 | if $class ne __PACKAGE__; | ||||
47 | |||||
48 | 30 | 18µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
49 | |||||
50 | 30 | 260µs | 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 | 31 | 88µs | sub options { (shift)->{'options'} } | ||
74 | 90 | 237µs | sub associated_metaclass { (shift)->{'associated_metaclass'} } | ||
75 | |||||
76 | ## method | ||||
77 | |||||
78 | # spent 79.9ms (235µs+79.7) within Class::MOP::Method::Constructor::_initialize_body which was called 30 times, avg 2.66ms/call:
# 30 times (235µs+79.7ms) by Class::MOP::Method::Constructor::new at line 37, avg 2.66ms/call | ||||
79 | 30 | 6µs | my $self = shift; | ||
80 | 30 | 6µs | my $method_name = '_generate_constructor_method'; | ||
81 | |||||
82 | 30 | 91µs | 30 | 20µs | $method_name .= '_inline' if $self->is_inline; # spent 20µs making 30 calls to Class::MOP::Method::Generated::is_inline, avg 657ns/call |
83 | |||||
84 | 30 | 127µs | 30 | 79.7ms | $self->{'body'} = $self->$method_name; # spent 79.7ms making 30 calls to Class::MOP::Method::Constructor::_generate_constructor_method_inline, avg 2.66ms/call |
85 | } | ||||
86 | |||||
87 | # spent 12.3ms (198µs+12.1) within Class::MOP::Method::Constructor::_eval_environment which was called 31 times, avg 396µs/call:
# 31 times (198µs+12.1ms) by Class::MOP::Method::Generated::_compile_code at line 59 of Class/MOP/Method/Generated.pm, avg 396µs/call | ||||
88 | 31 | 7µs | my $self = shift; | ||
89 | 31 | 123µs | 62 | 12.1ms | return $self->associated_metaclass->_eval_environment; # spent 11.8ms making 30 calls to Class::MOP::Class::_eval_environment, avg 394µs/call
# spent 218µs making 1 call to Moose::Meta::Class::_eval_environment
# spent 39µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 1µs/call
# spent 2µs making 1 call to Class::MOP::Method::associated_metaclass |
90 | } | ||||
91 | |||||
92 | sub _generate_constructor_method { | ||||
93 | return sub { Class::MOP::Class->initialize(shift)->new_object(@_) } | ||||
94 | } | ||||
95 | |||||
96 | # spent 81.9ms (1.28+80.6) within Class::MOP::Method::Constructor::_generate_constructor_method_inline which was called 31 times, avg 2.64ms/call:
# 30 times (1.22ms+78.4ms) by Class::MOP::Method::Constructor::_initialize_body at line 84, avg 2.66ms/call
# once (56µs+2.17ms) by Moose::Meta::Method::Constructor::_initialize_body at line 57 of Moose/Meta/Method/Constructor.pm | ||||
97 | 31 | 6µs | my $self = shift; | ||
98 | |||||
99 | 31 | 37µs | 31 | 40µs | my $meta = $self->associated_metaclass; # spent 38µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 1µs/call
# spent 2µs making 1 call to Class::MOP::Method::associated_metaclass |
100 | |||||
101 | 31 | 253µs | 31 | 47.7ms | my @source = ( # spent 47.7ms making 31 calls to Class::MOP::Class::_inline_new_object, avg 1.54ms/call |
102 | 'sub {', | ||||
103 | $meta->_inline_new_object, | ||||
104 | '}', | ||||
105 | ); | ||||
106 | |||||
107 | 31 | 53µs | 31 | 48µs | warn join("\n", @source) if $self->options->{debug}; # spent 48µs making 31 calls to Class::MOP::Method::Constructor::options, avg 2µs/call |
108 | |||||
109 | my $code = try { | ||||
110 | 31 | 111µs | 31 | 31.8ms | $self->_compile_code(\@source); # spent 31.8ms making 31 calls to Class::MOP::Method::Generated::_compile_code, avg 1.02ms/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 | 31 | 416µs | 62 | 32.8ms | }; # spent 32.7ms making 31 calls to Try::Tiny::try, avg 1.05ms/call
# spent 107µs making 31 calls to Try::Tiny::catch, avg 3µs/call |
116 | |||||
117 | 31 | 305µs | return $code; | ||
118 | } | ||||
119 | |||||
120 | 1 | 4µs | 1; | ||
121 | |||||
122 | # ABSTRACT: Method Meta Object for constructors | ||||
123 | |||||
124 | __END__ |