| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Method/Constructor.pm |
| Statements | Executed 896 statements in 2.47ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 31 | 2 | 2 | 830µs | 69.3ms | Class::MOP::Method::Constructor::_generate_constructor_method_inline |
| 30 | 1 | 1 | 453µs | 55.3ms | Class::MOP::Method::Constructor::new |
| 30 | 1 | 1 | 170µs | 170µs | Class::MOP::Method::Constructor::_new |
| 30 | 1 | 1 | 159µs | 54.6ms | Class::MOP::Method::Constructor::_initialize_body |
| 31 | 1 | 1 | 134µs | 7.77ms | Class::MOP::Method::Constructor::_eval_environment |
| 1 | 1 | 1 | 10µs | 10µs | Class::MOP::Method::Constructor::BEGIN@3 |
| 1 | 1 | 1 | 7µs | 756µs | Class::MOP::Method::Constructor::BEGIN@17 |
| 1 | 1 | 1 | 6µs | 18µs | Class::MOP::Method::Constructor::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 29µs | Class::MOP::Method::Constructor::BEGIN@13 |
| 1 | 1 | 1 | 6µs | 30µs | Class::MOP::Method::Constructor::BEGIN@14 |
| 1 | 1 | 1 | 6µs | 32µs | Class::MOP::Method::Constructor::BEGIN@15 |
| 1 | 1 | 1 | 6µs | 10µs | Class::MOP::Method::Constructor::BEGIN@11 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:111] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:115] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::__ANON__[:93] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Constructor::_generate_constructor_method |
| 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 | 4µ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 | 900ns | $Class::MOP::Method::Constructor::VERSION = '2.1005'; | ||
| 8 | } | ||||
| 9 | |||||
| 10 | 2 | 21µs | 2 | 29µs | # spent 18µs (6+12) within Class::MOP::Method::Constructor::BEGIN@10 which was called:
# once (6µs+12µs) by Class::MOP::Class::BEGIN@16 at line 10 # spent 18µs making 1 call to Class::MOP::Method::Constructor::BEGIN@10
# spent 12µs making 1 call to strict::import |
| 11 | 2 | 26µs | 2 | 13µs | # spent 10µs (6+3) within Class::MOP::Method::Constructor::BEGIN@11 which was called:
# once (6µs+3µs) by Class::MOP::Class::BEGIN@16 at line 11 # spent 10µs making 1 call to Class::MOP::Method::Constructor::BEGIN@11
# spent 3µs making 1 call to warnings::import |
| 12 | |||||
| 13 | 2 | 24µs | 2 | 52µs | # spent 29µs (6+23) within Class::MOP::Method::Constructor::BEGIN@13 which was called:
# once (6µs+23µs) by Class::MOP::Class::BEGIN@16 at line 13 # spent 29µs making 1 call to Class::MOP::Method::Constructor::BEGIN@13
# spent 23µs making 1 call to Exporter::import |
| 14 | 2 | 21µs | 2 | 53µs | # spent 30µs (6+23) within Class::MOP::Method::Constructor::BEGIN@14 which was called:
# once (6µs+23µs) by Class::MOP::Class::BEGIN@16 at line 14 # spent 30µs making 1 call to Class::MOP::Method::Constructor::BEGIN@14
# spent 23µs making 1 call to Exporter::import |
| 15 | 2 | 22µs | 2 | 59µs | # spent 32µs (6+26) within Class::MOP::Method::Constructor::BEGIN@15 which was called:
# once (6µs+26µs) by Class::MOP::Class::BEGIN@16 at line 15 # spent 32µs making 1 call to Class::MOP::Method::Constructor::BEGIN@15
# spent 26µs making 1 call to Exporter::import |
| 16 | |||||
| 17 | 2 | 474µs | 2 | 1.51ms | # spent 756µs (7+750) within Class::MOP::Method::Constructor::BEGIN@17 which was called:
# once (7µs+750µs) by Class::MOP::Class::BEGIN@16 at line 17 # spent 756µs making 1 call to Class::MOP::Method::Constructor::BEGIN@17
# spent 750µs making 1 call to base::import |
| 18 | |||||
| 19 | # spent 55.3ms (453µs+54.8) within Class::MOP::Method::Constructor::new which was called 30 times, avg 1.84ms/call:
# 30 times (453µs+54.8ms) by Class::MOP::Class::_inline_constructor at line 1438 of Class/MOP/Class.pm, avg 1.84ms/call | ||||
| 20 | 30 | 4µs | my $class = shift; | ||
| 21 | 30 | 45µs | my %options = @_; | ||
| 22 | |||||
| 23 | 30 | 131µs | 60 | 38µs | (blessed $options{metaclass} && $options{metaclass}->isa('Class::MOP::Class')) # spent 20µs making 30 calls to Scalar::Util::blessed, avg 660ns/call
# spent 18µs making 30 calls to UNIVERSAL::isa, avg 610ns/call |
| 24 | || confess "You must pass a metaclass instance if you want to inline" | ||||
| 25 | if $options{is_inline}; | ||||
| 26 | |||||
| 27 | 30 | 7µ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 | 30µs | 30 | 170µs | my $self = $class->_new(\%options); # spent 170µs making 30 calls to Class::MOP::Method::Constructor::_new, avg 6µs/call |
| 31 | |||||
| 32 | # we don't want this creating | ||||
| 33 | # a cycle in the code, if not | ||||
| 34 | # needed | ||||
| 35 | 30 | 153µs | 30 | 25µs | weaken($self->{'associated_metaclass'}); # spent 25µs making 30 calls to Scalar::Util::weaken, avg 843ns/call |
| 36 | |||||
| 37 | 30 | 23µs | 30 | 54.6ms | $self->_initialize_body; # spent 54.6ms making 30 calls to Class::MOP::Method::Constructor::_initialize_body, avg 1.82ms/call |
| 38 | |||||
| 39 | 30 | 62µs | return $self; | ||
| 40 | } | ||||
| 41 | |||||
| 42 | # spent 170µs within Class::MOP::Method::Constructor::_new which was called 30 times, avg 6µs/call:
# 30 times (170µs+0s) by Class::MOP::Method::Constructor::new at line 30, avg 6µs/call | ||||
| 43 | 30 | 4µs | my $class = shift; | ||
| 44 | |||||
| 45 | 30 | 7µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
| 46 | if $class ne __PACKAGE__; | ||||
| 47 | |||||
| 48 | 30 | 10µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 49 | |||||
| 50 | 30 | 170µ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 | 60µs | sub options { (shift)->{'options'} } | ||
| 74 | 90 | 154µs | sub associated_metaclass { (shift)->{'associated_metaclass'} } | ||
| 75 | |||||
| 76 | ## method | ||||
| 77 | |||||
| 78 | # spent 54.6ms (159µs+54.4) within Class::MOP::Method::Constructor::_initialize_body which was called 30 times, avg 1.82ms/call:
# 30 times (159µs+54.4ms) by Class::MOP::Method::Constructor::new at line 37, avg 1.82ms/call | ||||
| 79 | 30 | 3µs | my $self = shift; | ||
| 80 | 30 | 4µs | my $method_name = '_generate_constructor_method'; | ||
| 81 | |||||
| 82 | 30 | 62µs | 30 | 14µs | $method_name .= '_inline' if $self->is_inline; # spent 14µs making 30 calls to Class::MOP::Method::Generated::is_inline, avg 470ns/call |
| 83 | |||||
| 84 | 30 | 85µs | 30 | 54.4ms | $self->{'body'} = $self->$method_name; # spent 54.4ms making 30 calls to Class::MOP::Method::Constructor::_generate_constructor_method_inline, avg 1.81ms/call |
| 85 | } | ||||
| 86 | |||||
| 87 | # spent 7.77ms (134µs+7.63) within Class::MOP::Method::Constructor::_eval_environment which was called 31 times, avg 251µs/call:
# 31 times (134µs+7.63ms) by Class::MOP::Method::Generated::_compile_code at line 59 of Class/MOP/Method/Generated.pm, avg 251µs/call | ||||
| 88 | 31 | 4µs | my $self = shift; | ||
| 89 | 31 | 78µs | 62 | 7.63ms | return $self->associated_metaclass->_eval_environment; # spent 4.20ms making 30 calls to Class::MOP::Class::_eval_environment, avg 140µs/call
# spent 3.40ms making 1 call to Moose::Meta::Class::_eval_environment
# spent 26µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 880ns/call
# spent 900ns 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 69.3ms (830µs+68.5) within Class::MOP::Method::Constructor::_generate_constructor_method_inline which was called 31 times, avg 2.24ms/call:
# 30 times (765µs+53.6ms) by Class::MOP::Method::Constructor::_initialize_body at line 84, avg 1.81ms/call
# once (65µs+14.9ms) by Moose::Meta::Method::Constructor::_initialize_body at line 57 of Moose/Meta/Method/Constructor.pm | ||||
| 97 | 31 | 3µs | my $self = shift; | ||
| 98 | |||||
| 99 | 31 | 22µs | 31 | 23µs | my $meta = $self->associated_metaclass; # spent 22µs making 30 calls to Class::MOP::Method::Constructor::associated_metaclass, avg 747ns/call
# spent 800ns making 1 call to Class::MOP::Method::associated_metaclass |
| 100 | |||||
| 101 | 31 | 170µs | 31 | 45.2ms | my @source = ( # spent 45.2ms making 31 calls to Class::MOP::Class::_inline_new_object, avg 1.46ms/call |
| 102 | 'sub {', | ||||
| 103 | $meta->_inline_new_object, | ||||
| 104 | '}', | ||||
| 105 | ); | ||||
| 106 | |||||
| 107 | 31 | 34µs | 31 | 32µs | warn join("\n", @source) if $self->options->{debug}; # spent 32µs making 31 calls to Class::MOP::Method::Constructor::options, avg 1µs/call |
| 108 | |||||
| 109 | my $code = try { | ||||
| 110 | 31 | 64µs | 31 | 22.5ms | $self->_compile_code(\@source); # spent 22.5ms making 31 calls to Class::MOP::Method::Generated::_compile_code, avg 727µ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 | 31 | 264µs | 62 | 23.2ms | }; # spent 23.1ms making 31 calls to Try::Tiny::try, avg 747µs/call
# spent 75µs making 31 calls to Try::Tiny::catch, avg 2µs/call |
| 116 | |||||
| 117 | 31 | 193µs | return $code; | ||
| 118 | } | ||||
| 119 | |||||
| 120 | 1 | 3µs | 1; | ||
| 121 | |||||
| 122 | # ABSTRACT: Method Meta Object for constructors | ||||
| 123 | |||||
| 124 | __END__ |